Cargo A/C

Token Claims Hook

The database hook that enriches every access token with identity, email, role and permission claims.

Hook function

public.custom_access_token_hook runs on every token mint.

Execution

Execute is granted only to supabase_auth_admin — never to clients.

Activation

Enable under Authentication → Hooks → Custom Access Token, pointing to the function above.

Claim mapping
ClaimSourceNotes
cargo_account_numberprofiles.cargo_account_numberImmutable account identifier.
usernameprofiles.usernamePublic handle, if claimed.
user_typeprofiles.user_typeclient / internal classification.
identity_typeprofiles.identity_typeperson / organization / service.
full_nameprofiles.full_nameDisplay name.
login_emailuser_emails (is_login)Canonical sign-in email.
rolesuser_rolesAll assigned roles.
permissionsresolve_user_permissions()Effective keys: roles + grants − revokes.

Live claim preview

Pick an identity to see the exact claim payload the hook will emit into their JWT.

No user selected.