feat: validate jwt audience and issuer - #160
Open
mandar1045 wants to merge 1 commit into
Open
mandar1045 wants to merge 1 commit into
mandar1045 wants to merge 1 commit into
Conversation
kallebysantos
requested changes
Sep 14, 2026
commit: |
mandarini
requested changes
Sep 15, 2026
mandarini
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for picking this up and for moving the options off resolveEnv. The logic is right and every call site gets the options. Three small changes before merge.
- Drop
| nullfrom the new field types and pass the options straight tojwtVerify(or guard with!== undefined). With the current truthiness check, an empty string turns validation off with no warning and an empty array rejects every token. - Fix the example in
docs/security.md. Supabase Auth setsaudtoauthenticatedandisstohttps://<ref>.supabase.co/auth/v1, soaudience: 'my-service'would reject every Supabase token. Useissuer: fromSupabaseUrl(SUPABASE_URL)as the example and point towithRequiredClaimsrather thanwithClaims, sincewithClaimslets requests with no token through. - Add a one-line JSDoc to each new field, matching the fields around them. Mention that they apply to
usermode only.
On your question about grouping: top level is fine. It matches where jwks sits on withClaims.
mandar1045
force-pushed
the
fix/validate-jwt-audience-issuer
branch
from
September 15, 2026 15:58
37e7297 to
383648e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TL;DR
Validate the JWT
audandissclaims during user token verification through config overrides.Problem
Token verification currently doesn't validate the audience or issuer claims. This means a valid token issued for one service could potentially be accepted by another service.
Solution
Adds optional
audienceandissuerconfig overrides toverifyCredentials,withClaims, andwithRequiredClaims.This works with both symmetric and asymmetric keys, and doesn't read from any reserved environment variables.
Ref