Repository navigation
fix(auth): raise AuthInvalidJwtError when get_claims JWT has no exp - #1603
Merged
grdsdev merged 1 commit intoSep 2, 2026
Conversation
`JWTPayload` is `total=False`, so `payload["exp"]` in `get_claims` leaked a
bare `KeyError` for a JWT without an `exp` claim, instead of the
`AuthInvalidJwtError("JWT has no expiration time")` that `validate_exp` is
written to raise. Use `payload.get("exp")` and widen `validate_exp` to
`Optional[int]`.
`iss`, `aud` and `nbf` are deliberately left unchecked: supabase-js
`getClaims` does not validate them either, and adding them in Python alone
would break parity and existing callers.
Fixes SDK-1680
Contributor
|
The following capabilities are marked
The following capabilities are marked
These may have been renamed, removed, or never registered. Please update the capability matrix. |
mandarini
approved these changes
Sep 2, 2026
grdsdev
deleted the
guilhermesouza/sdk-1680-auth-get_claims-verifies-only-signature-and-exp
branch
September 2, 2026 10:29
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.
Fixes SDK-1680
What changed
get_claimsreadpayload["exp"]directly.JWTPayloadistotal=False, so a JWT without anexpclaim leaked a bareKeyErrorinstead of theAuthInvalidJwtError("JWT has no expiration time")thatvalidate_exp(helpers.py:286) exists to raise.payload["exp"]→payload.get("exp")in_asyncand generated_syncgotrue_client.py.validate_expsignature widened toOptional[int]so mypy accepts the missing claim. The function already handled a falsyexp.test_get_claims_raises_when_exp_claim_is_missingin_async/_synctest_gotrue.py. It fails withKeyError: 'exp'before the fix.Verification
make auth.testsagainst local infra: 164 passed. mypy clean, ruff clean.