vincbeck commented on code in PR #75913:
URL: https://github.com/apache/airflow/pull/75913#discussion_r4630371578


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/keycloak_auth_manager.py:
##########
@@ -269,6 +294,9 @@ def refresh_tokens(self, *, user: KeycloakAuthManagerUser) 
-> dict[str, str]:
             client = self.get_keycloak_client()
             return client.refresh_token(user.refresh_token)
         except KeycloakPostError as exc:
+            if is_keycloak_outage(exc):
+                # The session may still be valid: ending it would log users 
out on a Keycloak blip.
+                raise

Review Comment:
   This also changes the browser flow. On a Keycloak 5xx, `refresh_user` now 
raises `KeycloakPostError`, which `KeycloakJWTMiddleware` doesn't catch, so 
every browser request with an expired access token returns a 500 until Keycloak 
recovers. Before, the session ended. Is that intended? If yes, maybe the 
middleware should return a 503 instead.



##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/token.py:
##########
@@ -37,7 +37,9 @@
 @token_router.post(
     "/token",
     status_code=status.HTTP_201_CREATED,
-    responses=create_openapi_http_exception_doc([status.HTTP_400_BAD_REQUEST, 
status.HTTP_403_FORBIDDEN]),
+    responses=create_openapi_http_exception_doc(
+        [status.HTTP_400_BAD_REQUEST, status.HTTP_403_FORBIDDEN, 
status.HTTP_503_SERVICE_UNAVAILABLE]

Review Comment:
   nit: only the password grant returns this 503. A Keycloak outage on 
`client_credentials` still gives a 500, and `jwt-bearer` turns it into a 403 
`Invalid Keycloak assertion`. Can you wrap them in `translate_keycloak_outage` 
as well?



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