-
Notifications
You must be signed in to change notification settings - Fork 436
feat: add hybrid jwt verification #4721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
avallete
merged 7 commits into
supabase:develop
from
kallebysantos:fix-update-functions-verify-jwt
Mar 10, 2026
+53
−6
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
39176e3
feat: adding hybrid jwt verification
kallebysantos 00c30af
stamp: detect algorithm before verify JWT
kallebysantos 2258e81
feat: passing down JWKs as internal env
kallebysantos 55d59c9
stamp: using URL object instead of string concatenation
kallebysantos 4ab6860
Merge branch 'develop' into fix-update-functions-verify-jwt
kallebysantos 964f3bc
stamp: codegen
kallebysantos 067e8ee
Merge branch 'develop' into fix-update-functions-verify-jwt
avallete File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: supabase/cli
Length of output: 102
🏁 Script executed:
cat -n internal/functions/serve/templates/main.ts | head -150Repository: supabase/cli
Length of output: 5779
🌐 Web query:
@panva/jose createLocalJWKSet vs createRemoteJWKSet behavior key rotation💡 Result:
Key rotation behavior differences
createLocalJWKSet(jwks)kid), you must replace/update the JWKS in your app (e.g., refetch + rebuild your verifier) for verification to start working again. [1]createRemoteJWKSet(url, options?)jwks_urilazily and refreshes when needed:alg/kid) doesn’t match any cached key, it will fetch the JWKS again (but rate-limited bycooldownDurationto prevent abuse). This is the main mechanism that makes key rotation “just work” in steady state. [2]cacheMaxAgebetween successful HTTP fetches (default 10 minutes), so it will periodically refresh even without rotation-triggered misses. [3]Practical summary for rotation
kidtriggers a refetch (subject tocooldownDuration), then verification succeeds once the new key appears in JWKS. [2]Sources:
[1]
createLocalJWKSetdocs (panva/jose) (github.com)[2]
createRemoteJWKSetdocs (panva/jose) (github.com)[3]
RemoteJWKSetOptions(cacheMaxAge,cooldownDuration, defaults) (github.com)[4] panva guidance on not recreating RemoteJWKSet instance (github.com)
Citations:
🏁 Script executed:
Repository: supabase/cli
Length of output: 1384
🏁 Script executed:
Repository: supabase/cli
Length of output: 139
Don't freeze asymmetric verification to the startup JWKS snapshot.
If
SUPABASE_INTERNAL_JWKSis present,jwksis set to acreateLocalJWKSetat startup and never reaches the remote resolver.createLocalJWKSetonly resolves against the supplied local keys and does not refresh, whilecreateRemoteJWKSetrefetches when encountering an unknownkid(key ID). After a signing-key rotation, valid ES256/RS256 tokens will fail verification until the process restarts. This breaks the stated migration scenario. Either fall back to remote resolution when the local set misses a key, or prefer the remote resolver when available.🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really true, the previous one also freeze the
jwksand was only fetching it at 1º startup.Also since its local dev, its already expected to users full restart after
config.tomlchanges or similar.