Fix: Ensure JWTValidator handles GUESS algorithm with JWKS#63115
Open
henry3260 wants to merge 3 commits intoapache:mainfrom
Open
Fix: Ensure JWTValidator handles GUESS algorithm with JWKS#63115henry3260 wants to merge 3 commits intoapache:mainfrom
henry3260 wants to merge 3 commits intoapache:mainfrom
Conversation
- Updated `avalidated_claims` to read the signing algorithm (`alg`) from the token header when `jwt_algorithm` is set to "GUESS". - Passed the raw key (`key.key`) instead of the `PyJWK` object to prevent pyjwt from overriding the algorithm with `PyJWK.algorithm_name`.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the FastAPI JWT auth implementation so JWTValidator can validate tokens when [api_auth] jwt_algorithm = GUESS is used together with a configured JWKS (local/remote), and adds a unit test to cover that configuration.
Changes:
- Allow
JWTValidatorto be constructed withalgorithm=["GUESS"]whenjwksis configured (previously rejected). - During validation, infer the concrete algorithm when using JWKS+GUESS so
jwt.decode()can proceed. - Add a unit test exercising JWKS validation with
jwt_algorithm=GUESSfor RSA and Ed25519 keys.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| airflow-core/src/airflow/api_fastapi/auth/tokens.py | Adjust JWT validation to support GUESS with JWKS by inferring an algorithm at decode time. |
| airflow-core/tests/unit/api_fastapi/auth/test_tokens.py | Add regression test for JWKS validation when jwt_algorithm is set to GUESS. |
You can also share your feedback on Copilot code review. Take the survey.
Contributor
SameerMesiah97
left a comment
There was a problem hiding this comment.
I think there may be a security concern here because this loosens the restriction on what party decides the verification algorithm. I have left a comment at the most critical line.
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.
What
algis now dynamically read from the JWT header instead of relying on a predefined or mismatched algorithm.key.key) is passed directly to thejwt.decodefunction, avoiding conflicts caused by thePyJWKobject enforcing its internalalgorithm_name.