pierrejeambrun commented on code in PR #64955:
URL: https://github.com/apache/airflow/pull/64955#discussion_r3065142209


##########
airflow-core/src/airflow/api_fastapi/auth/middlewares/refresh_token.py:
##########
@@ -61,16 +61,29 @@ async def dispatch(self, request: Request, call_next):
             response = await call_next(request)
 
             if new_token is not None:
+                cookie_path = get_cookie_path()
                 secure = bool(conf.get("api", "ssl_cert", fallback=""))
                 response.set_cookie(
                     COOKIE_NAME_JWT_TOKEN,
                     new_token,
-                    path=get_cookie_path(),
+                    path=cookie_path,
                     httponly=True,
                     secure=secure,
                     samesite="lax",
                     max_age=0 if new_token == "" else None,
                 )
+                # Clear any stale _token cookie at root path "/".
+                # Older Airflow instances may have set the cookie there;
+                # without this, the root-path cookie keeps being sent on
+                # every request, causing an infinite redirect loop.
+                if new_token == "" and cookie_path != "/":

Review Comment:
   Were you able to test this locally with the setup you mention, did it fix 
the loop?



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