dabla commented on code in PR #76353:
URL: https://github.com/apache/airflow/pull/76353#discussion_r4591676659


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/middleware.py:
##########
@@ -82,6 +82,11 @@ async def dispatch(self, request: Request, call_next):
                 HTTPException,
             ):
                 new_token = ""
+                # The session ends here and the response clears the Airflow 
JWT. Hide it
+                # from the inner middlewares and the route too: resolving it 
again without
+                # the Keycloak tokens yields no user, which ``get_user`` would 
hand to the
+                # authorization checks instead of answering 401.
+                self._drop_cookie(request, COOKIE_NAME_JWT_TOKEN)

Review Comment:
   Follow-up: this changed in cf8845c955. Revoking in the middleware turned out 
to log users out when Keycloak rotates refresh tokens (a parallel request that 
still carries the old refresh token revoked the JWT of the request that had 
just refreshed, see the thread above on line 93).
   
   The middleware no longer revokes anything. On the core logout route it 
leaves the JWT in the request instead, so the route revokes it itself as on 
`main`. Your case is still pinned: 
`test_logout_of_an_ended_keycloak_session_revokes_the_token` goes through the 
real logout route with an expired refresh token and with no Keycloak cookies. 
The 401 for a rejected JWT and its test are unchanged.
   



-- 
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