baptistegh opened a new pull request, #77569:
URL: https://github.com/apache/airflow/pull/77569

   Logging out of Airflow only ended the Keycloak session if the browser 
completed the redirect to Keycloak's `end_session_endpoint`. When that redirect 
did not happen, the Keycloak session stayed active and its refresh token could 
still be used to get new tokens until it expired. That covers three cases:
   
   - the id token cookie was missing or invalid, so the provider's `/logout` 
route skipped Keycloak,
   - the user closed the tab before the redirect,
   - Keycloak refused the post-logout redirect URI.
   
   `KeycloakJWTMiddleware` now ends the Keycloak session with the refresh token 
during the core `/api/v2/auth/logout` request. This is the last request that 
still carries the refresh token cookie, since the logout response clears it. 
The call runs in a thread pool so the blocking HTTP request does not hold up 
the event loop. If Keycloak refuses or cannot be reached, a warning is logged 
and the Airflow logout completes as before.
   
   Scope:
   
   - Browser sessions on Airflow 3.3+ only. That is where the Keycloak tokens 
have their own cookies.
   - API and CLI tokens carry their refresh token in the Airflow JWT claims and 
are not covered. That can be a follow-up that overrides `revoke_token` in 
`KeycloakAuthManager`.
   
   Tested with:
   
   - `uv run --project providers/keycloak pytest 
providers/keycloak/tests/unit/keycloak`: 461 passed
   - `breeze run mypy` on the changed files: no issues
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Opus 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to