Skip to content

[v3-3-test] Resolve the caller from the explicit credential, not the session cookie (#72225) - #72723

Merged
potiuk merged 1 commit into
apache:v3-3-testfrom
potiuk:backport-72225-to-v3-3-test
Sep 8, 2026
Merged

potiuk merged 1 commit into
apache:v3-3-testfrom
potiuk:backport-72225-to-v3-3-test

Conversation

@potiuk

@potiuk potiuk commented Sep 8, 2026

Copy link
Copy Markdown
Member

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

…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
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Sep 8, 2026
@potiuk potiuk added this to the Airflow 3.3.2 milestone Sep 8, 2026
@potiuk potiuk changed the title Resolve the caller from the explicit credential, not the session cookie (#72225) [v3-3-test] Resolve the caller from the explicit credential, not the session cookie (#72225) Sep 8, 2026
@potiuk
potiuk merged commit aa620e0 into apache:v3-3-test Sep 8, 2026
5 checks passed
@potiuk
potiuk deleted the backport-72225-to-v3-3-test branch September 8, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant