Skip to content

Revoke every credential presented to the Core API logout endpoint - #72649

Merged
vatsrahul1001 merged 1 commit into
apache:mainfrom
potiuk:security/logout-revokes-bearer
Sep 11, 2026
Merged

vatsrahul1001 merged 1 commit into
apache:mainfrom
potiuk:security/logout-revokes-bearer

Conversation

@potiuk

@potiuk potiuk commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

The Core API logout endpoint read only the _token cookie.

A client authenticating with an Authorization: Bearer header — the documented
way to call the Core API — therefore received a normal logout response while its
token was never revoked. The token stayed valid until it expired; the default
lifetime is 24 hours and is configurable.

The practical effect is that a copy of the token held by anyone else survives the
holder's logout: asking to be logged out did not end the session it was presented
for.

The change

  • Logout uses a new collect_request_tokens() and revokes all credentials
    presented, not just the precedence-selected one. Revoking only the winner would
    leave any other credential the caller presented valid after they asked to be
    logged out — and which credential wins is a question about authentication
    that should not decide what a logout terminates.
  • collect_request_tokens() walks the same order get_user() authenticates by,
    so logout does not hard-code its own separate answer to what a request's
    credentials are.
  • Revocation still happens before any redirect or cookie deletion, so an external
    auth-manager logout URL cannot skip it.

get_user() itself is not touched by this PR. Its precedence — bearer → OAuth
token → trusted-middleware cached user → cookie — is stated inline there as of
#72225, and collect_request_tokens() follows that same credential order.

Tests

Bearer-only logout, bearer plus cookie together, bearer before an external
redirect, and revocation when a user has been cached by JWTRefreshMiddleware
(so the trusted-user shortcut cannot cause logout to skip revocation).

Against unpatched sources the bearer tests fail with assert False is True —
the token is simply not revoked. The existing cookie tests are unchanged and
still pass, as do the 114 tests in test_security.py alongside this file's 18.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines

@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Sep 7, 2026
@potiuk
potiuk force-pushed the security/logout-revokes-bearer branch 2 times, most recently from cda57df to 2f1bf21 Compare September 7, 2026 19:40
logout() read only the _token cookie. A client authenticating with an
Authorization: Bearer header -- the documented way to call the Core API --
therefore received a normal logout response while its token was never revoked,
and that token stayed valid until it expired. The default lifetime is 24 hours.

A copy of the token held by anyone else survived the holder's logout, so asking
to be logged out did not end the session it was presented for.

Logout uses collect_request_tokens() and revokes all of them, not just the
precedence-selected one. It walks the same order get_user() authenticates by, so
logout does not hard-code its own separate answer to what a request's credentials
are. Revoking only the winner would leave any other credential the caller
presented valid after they asked to be logged out, and which credential wins is a
question about authentication that should not decide what a logout terminates.

Revocation still happens before any redirect or cookie deletion, so an external
auth-manager logout URL cannot skip it.

The bearer tests fail against unpatched sources with 'assert False is True' --
the token is simply not revoked.

Generated-by: Claude Code (Opus 5)
Claude-Session: https://claude.ai/code/session_01XS3bodTDYYGrPmorhtLsjP
@potiuk
potiuk force-pushed the security/logout-revokes-bearer branch from 2f1bf21 to 74039e0 Compare September 8, 2026 17:22
@potiuk potiuk added this to the Airflow 3.3.2 milestone Sep 10, 2026
@potiuk

potiuk commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Would love that one approved :)

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@vatsrahul1001
vatsrahul1001 merged commit 3f0a5d6 into apache:main Sep 11, 2026
155 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-3-test PR Link

aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Sep 11, 2026
…endpoint (apache#72649)

logout() read only the _token cookie. A client authenticating with an
Authorization: Bearer header -- the documented way to call the Core API --
therefore received a normal logout response while its token was never revoked,
and that token stayed valid until it expired. The default lifetime is 24 hours.

A copy of the token held by anyone else survived the holder's logout, so asking
to be logged out did not end the session it was presented for.

Logout uses collect_request_tokens() and revokes all of them, not just the
precedence-selected one. It walks the same order get_user() authenticates by, so
logout does not hard-code its own separate answer to what a request's credentials
are. Revoking only the winner would leave any other credential the caller
presented valid after they asked to be logged out, and which credential wins is a
question about authentication that should not decide what a logout terminates.

Revocation still happens before any redirect or cookie deletion, so an external
auth-manager logout URL cannot skip it.

The bearer tests fail against unpatched sources with 'assert False is True' --
the token is simply not revoked.
(cherry picked from commit 3f0a5d6)

Co-authored-by: Jarek Potiuk <[email protected]>
Generated-by: Claude Code (Opus 5)
Claude-Session: https://claude.ai/code/session_01XS3bodTDYYGrPmorhtLsjP
vatsrahul1001 pushed a commit that referenced this pull request Sep 11, 2026
…endpoint (#72649) (#72933)

logout() read only the _token cookie. A client authenticating with an
Authorization: Bearer header -- the documented way to call the Core API --
therefore received a normal logout response while its token was never revoked,
and that token stayed valid until it expired. The default lifetime is 24 hours.

A copy of the token held by anyone else survived the holder's logout, so asking
to be logged out did not end the session it was presented for.

Logout uses collect_request_tokens() and revokes all of them, not just the
precedence-selected one. It walks the same order get_user() authenticates by, so
logout does not hard-code its own separate answer to what a request's credentials
are. Revoking only the winner would leave any other credential the caller
presented valid after they asked to be logged out, and which credential wins is a
question about authentication that should not decide what a logout terminates.

Revocation still happens before any redirect or cookie deletion, so an external
auth-manager logout URL cannot skip it.

The bearer tests fail against unpatched sources with 'assert False is True' --
the token is simply not revoked.
(cherry picked from commit 3f0a5d6)


Generated-by: Claude Code (Opus 5)
Claude-Session: https://claude.ai/code/session_01XS3bodTDYYGrPmorhtLsjP

Co-authored-by: Jarek Potiuk <[email protected]>
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.

3 participants