Repository navigation
Conversation
This branch has not been deployed
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 #1869. Fixes #1868 (duplicate).
get_claims()raised a raw pydanticValidationErrorfor tokens whose segments base64-decode but don't matchJWTHeaderorJWTPayload, so a malformedAuthorizationheader became a 500 instead of a catchableAuthError.Changes
decode_jwtvalidates the header and payload inside the sametryas the base64 decoding, and re-raisesValidationErrorasAuthInvalidJwtError("Invalid JWT structure").JWTHeader.typis optional, sincetypis optional per RFC 7515 §4.1.9 and a valid token without it was rejected._fetch_jwksmatches keys withjwk.get("kid"), so a JWKS containing keys without akid(optional per RFC 7517) no longer raisesKeyError.Tests
decode_jwtraisesAuthInvalidJwtErrorfor a non-JSON header or payload,alg: none,alg: EdDSA, a header that is a JSON array, and a stringexp, and accepts a header withouttyp.get_claimsraiseAuthInvalidJwtErrorfor a malformed header, and_fetch_jwksskips supplied keys without akid.mainand pass with the fix. mypy and ruff pass.