Supabase Auth
Let people who sign in with Supabase Auth call your API. Verify the access token Supabase signs, and read the user from its claims.
Supabase Auth signs an access token for everyone who signs in. Your API verifies it with @kizunajs/jwt against your project's public keys, so it never calls Supabase on a request.
Declare the identity
Replace <ref> with your project's reference, the part before .supabase.co in its URL:
Supabase signs with ES256 unless you picked RS256 for your signing key under Project Settings → JWT Keys.
The audience authenticated is what Supabase gives every signed-in user. The anon and publishable API keys are not a user's token, so they never pass.
Send the access token
supabase-js keeps the session and refreshes it. Read the current access token before every request:
Roles
Give a user their role in app_metadata, which only your server can change, and read it from the claims:
Never read a role from user_metadata. The user can change it from the browser.
A custom access token hook can put a role from your own tables straight into the claims instead.
Anonymous sign-ins
When anonymous sign-ins are on, those users also get the authenticated audience. Turn them away where a route needs a real account:
Projects on the legacy JWT secret
A project that has not moved to JWT signing keys signs with a shared secret, and its JWKS is empty. Verify with the secret from Project Settings → JWT Keys instead:
Moving to signing keys is better. Anyone holding the secret can sign a token, and your API no longer needs to hold it.