Repository navigation
[v3-3-test] Resolve the caller from the explicit credential, not the session cookie (#72225) - #72723
Merged
Merged
Conversation
…ie (apache#72225) * Resolve the caller from the explicit credential, not the session cookie `JWTRefreshMiddleware` resolves a user from the `_token` cookie alone and stamps it on `request.state` together with the trust sentinel. `get_user()` returned that cached user before it looked at `bearer_credentials` or `oauth_token`, so on every core-API route the effective precedence was cookie over bearer -- the inverse of the order the function itself codes. A request carrying both a session cookie and an explicit `Authorization: Bearer` token therefore executed, and was audit-logged, as the cookie's principal rather than the identity the client asked to act as. The cached user is now honoured only when the request carries no explicit credential, which is the case it exists for: a browser session whose token the middleware has just refreshed. When a bearer or OAuth2 token is present it is resolved instead. * Add newsfragment for the credential precedence change * Simplify credential resolution in get_user to early returns Review feedback: the intermediate `token_str = None` sentinel obscured the precedence the change is about. Returning at each credential source states the order directly, and the newsfragment now records that an invalid explicit credential fails loudly instead of silently falling back to the cookie. Generated-by: Claude Code (Opus 5) Claude-Session: https://claude.ai/code/session_01XS3bodTDYYGrPmorhtLsjP
potiuk
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
September 8, 2026 15:56
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.
Backport of #72225 to
v3-3-test, so the fix ships in 3.3.2.Cherry-picked from
d6b45d8e2f4202fbc9cada2c6783539e29987a1f— clean, no conflicts (both source files auto-merged).airflow-core/tests/unit/api_fastapi/core_api/test_security.py: 112 passed on this branch.🤖 Generated with Claude Code
https://claude.ai/code/session_015DKYM5PoVgKC5JqxLso8rn