sjyangkevin commented on code in PR #77619:
URL: https://github.com/apache/airflow/pull/77619#discussion_r4713554405
##########
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py:
##########
@@ -129,22 +131,20 @@ def create_token_cli(request: Request, body: dict[str,
Any] = Body(...)) -> Logi
status_code=status.HTTP_307_TEMPORARY_REDIRECT,
)
def logout(request: Request) -> RedirectResponse:
- """Clear session cookies and redirect to the login page."""
- with _get_flask_app().app_context(), _release_scoped_session():
- login_url = get_auth_manager().get_url_login()
- secure = request.base_url.scheme == "https" or bool(conf.get("api",
"ssl_cert", fallback=""))
- cookie_path = get_cookie_path()
- response = RedirectResponse(login_url)
- response.delete_cookie(
- key="session",
- path=cookie_path,
- secure=secure,
- httponly=True,
- )
- response.delete_cookie(
- key=COOKIE_NAME_JWT_TOKEN,
- path=cookie_path,
- secure=secure,
- httponly=True,
- )
- return response
+ """Clear the API token cookie and redirect to the Flask logout view, which
ends the session."""
+ # The trailing slash routes to the Flask app's own logout view. The
``session`` cookie is
+ # left in place so that the browser sends it there and the Flask session
it points at is
+ # signed out.
+ flask_logout_url = urljoin(
+ get_fab_auth_manager().apiserver_endpoint,
f"{AUTH_MANAGER_FASTAPI_APP_PREFIX}/logout/"
Review Comment:
That's not intended, and thanks for catching it. FAB's logout redirects to
the index page, and `FabIndexView` then sends the user to `[api] base_url`, so
the user lands on the main UI instead of the login form.
To check it, I set `[fab] auth_role_public = Viewer`, signed in as `admin`
through `/auth/login/`, and logged out. On the previous head, logout took me
back to the main UI as the anonymous user, without showing the login page.
With the latest commit, the logout override redirects to the login page, or
to `LOGOUT_REDIRECT_URL` if one is configured. Here are the redirect hops from
the browser's developer tools:
<img width="1527" height="470" alt="Screenshot from 2026-11-26 15-41-17"
src="https://github.com/user-attachments/assets/ea285090-80eb-4a9a-96ce-bff6a7109fc1"
/>
<img width="1527" height="470" alt="Screenshot from 2026-11-26 15-41-43"
src="https://github.com/user-attachments/assets/4f4b02db-42d6-48ed-a336-4f8711c22898"
/>
--
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]