Skip to content

Stop Keycloak middleware from reissuing a JWT revoked during the request - #73695

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:keycloak-logout-session-invalidation
Sep 27, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:keycloak-logout-session-invalidation

Conversation

@potiuk

@potiuk potiuk commented Sep 24, 2026

Copy link
Copy Markdown
Member

When the Keycloak access token had expired, KeycloakJWTMiddleware refreshed
the user before the endpoint ran and, after it returned, always set a newly
signed Airflow JWT on the response. On /auth/logout the endpoint revokes the
JWT the request came with, so the middleware replaced the revoked token with
a fresh, unrevoked one and the session stayed usable after logout.

After the endpoint returns, the middleware now checks that the JWT sent with
the request is still accepted before issuing a replacement. If it has been
revoked, no new JWT is issued and the Airflow and Keycloak token cookies are
cleared instead. A JWT that merely expired while the request was handled is
still replaced as before.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Claude Opus 5)

Generated-by: Claude Opus 5 following the guidelines

🤖 Generated with Claude Code

When the Keycloak access token had expired, KeycloakJWTMiddleware refreshed
the user before the endpoint ran and, after it returned, always set a newly
signed Airflow JWT on the response. On /auth/logout the endpoint revokes the
JWT the request came with, so the middleware replaced the revoked token with
a fresh, unrevoked one and the session stayed usable after logout.

After the endpoint returns, the middleware now checks that the JWT sent with
the request is still accepted before issuing a replacement. If it has been
revoked, no new JWT is issued and the Airflow and Keycloak token cookies are
cleared instead. A JWT that merely expired while the request was handled is
still replaced as before.

Generated-by: Claude Opus 5 following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
@potiuk
potiuk merged commit 22f6bb0 into apache:main Sep 27, 2026
78 of 79 checks passed
@potiuk
potiuk deleted the keycloak-logout-session-invalidation branch September 27, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants