Fix Airflow JWT getting cleared in KeycloakAuthManager /login_callback route - #71077
Merged
Merged
Conversation
stephen-bracken
force-pushed
the
fix-keycloak-login
branch
2 times, most recently
from
August 4, 2026 09:58
cb35cf4 to
278794b
Compare
stephen-bracken
force-pushed
the
fix-keycloak-login
branch
from
August 4, 2026 10:02
278794b to
59c69c8
Compare
stephen-bracken
marked this pull request as ready for review
August 4, 2026 12:13
This was referenced Aug 6, 2026
vincbeck
approved these changes
Aug 10, 2026
stegololz
added a commit
to stegololz/airflow
that referenced
this pull request
Aug 12, 2026
KeycloakJWTMiddleware clears the JWT cookie when token validation fails. When the failing token arrives on the login callback request itself (a re-login after the previous JWT expired, with the stale cookie still in the browser jar), the clearing Set-Cookie is appended after the fresh token the callback just set. The browser applies the deletion last, the new session dies in the response that created it, and the user is sent back to login indefinitely. apache#71077 fixed the same clobber for requests carrying no token at all; this covers the remaining path where an expired token is present. The login callback now signals via request.state.jwt_token_issued that the response carries a freshly issued JWT, and the middleware skips the cookie clear in that case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
stegololz
added a commit
to stegololz/airflow
that referenced
this pull request
Aug 12, 2026
KeycloakJWTMiddleware clears the JWT cookie when token validation fails. When the failing token arrives on the login callback request itself (a re-login after the previous JWT expired, with the stale cookie still in the browser jar), the clearing Set-Cookie is appended after the fresh token the callback just set. The browser applies the deletion last, the new session dies in the response that created it, and the user is sent back to login indefinitely. apache#71077 fixed the same clobber for requests carrying no token at all; this covers the remaining path where an expired token is present. The login callback now signals via request.state.jwt_token_issued that the response carries a freshly issued JWT, and the middleware skips the cookie clear in that case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
stegololz
added a commit
to stegololz/airflow
that referenced
this pull request
Aug 12, 2026
KeycloakJWTMiddleware clears the JWT cookie when token validation fails. When the failing token arrives on the login callback request itself (a re-login after the previous JWT expired, with the stale cookie still in the browser jar), the clearing Set-Cookie is appended after the fresh token the callback just set. The browser applies the deletion last, the new session dies in the response that created it, and the user is sent back to login indefinitely. apache#71077 fixed the same clobber for requests carrying no token at all; this covers the remaining path where an expired token is present. The login callback now signals via request.state.jwt_token_issued that the response carries a freshly issued JWT, and the middleware skips the cookie clear in that case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Merged
2 tasks
stegololz
added a commit
to stegololz/airflow
that referenced
this pull request
Aug 13, 2026
KeycloakJWTMiddleware clears the JWT cookie when token validation fails. When the failing token arrives on the login callback request itself (a re-login after the previous JWT expired, with the stale cookie still in the browser jar), the clearing Set-Cookie is appended after the fresh token the callback just set. The browser applies the deletion last, the new session dies in the response that created it, and the user is sent back to login indefinitely. apache#71077 fixed the same clobber for requests carrying no token at all; this covers the remaining path where an expired token is present. The login callback now signals via request.state.jwt_token_issued that the response carries a freshly issued JWT, and the middleware skips the cookie clear in that case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
vincbeck
pushed a commit
that referenced
this pull request
Aug 13, 2026
…#71506) KeycloakJWTMiddleware clears the JWT cookie when token validation fails. When the failing token arrives on the login callback request itself (a re-login after the previous JWT expired, with the stale cookie still in the browser jar), the clearing Set-Cookie is appended after the fresh token the callback just set. The browser applies the deletion last, the new session dies in the response that created it, and the user is sent back to login indefinitely. #71077 fixed the same clobber for requests carrying no token at all; this covers the remaining path where an expired token is present. The login callback now signals via request.state.jwt_token_issued that the response carries a freshly issued JWT, and the middleware skips the cookie clear in that case.
dabla
pushed a commit
to dabla/airflow
that referenced
this pull request
Aug 14, 2026
dabla
pushed a commit
to dabla/airflow
that referenced
this pull request
Aug 14, 2026
…apache#71506) KeycloakJWTMiddleware clears the JWT cookie when token validation fails. When the failing token arrives on the login callback request itself (a re-login after the previous JWT expired, with the stale cookie still in the browser jar), the clearing Set-Cookie is appended after the fresh token the callback just set. The browser applies the deletion last, the new session dies in the response that created it, and the user is sent back to login indefinitely. apache#71077 fixed the same clobber for requests carrying no token at all; this covers the remaining path where an expired token is present. The login callback now signals via request.state.jwt_token_issued that the response carries a freshly issued JWT, and the middleware skips the cookie clear in that case.
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.
Fix Airflow JWT getting cleared in KeycloakAuthManager /login_callback route
related: #70800
In the /login_callback route the request has no
_tokenproperty because the/login_callbackroute is going to set_tokenin the response. TheKeycloakJWTMiddlewarewas incorrectly raising a 401 status and clearing the_tokencookie, preventing logins. Gracefully handle this scenario by returningNone, Nonefor the user.Was generative AI tooling used to co-author this PR?