vincbeck commented on code in PR #61339:
URL: https://github.com/apache/airflow/pull/61339#discussion_r2754741541
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/auth.py:
##########
@@ -55,6 +62,25 @@ def logout(request: Request, auth_manager: AuthManagerDep)
-> RedirectResponse:
if logout_url:
return RedirectResponse(logout_url)
+ # Revoke the current token before deleting the cookie
+ token_str = request.cookies.get(COOKIE_NAME_JWT_TOKEN)
+ if token_str:
+ try:
+ header = jwt.get_unverified_header(token_str)
+ claims = jwt.decode(
+ token_str,
+ options={"verify_exp": False, "verify_signature": False},
+ algorithms=[header.get("alg", "HS256")],
+ )
+ jti = claims.get("jti")
+ exp = claims.get("exp")
+ if jti and exp:
+ from airflow.models.revoked_token import RevokedToken
+
+ RevokedToken.revoke(jti, datetime.fromtimestamp(exp,
tz=timezone.utc))
+ except (jwt.InvalidTokenError, SQLAlchemyError):
+ log.warning("Failed to revoke token during logout", exc_info=True)
Review Comment:
Agree
--
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]