vincbeck commented on code in PR #77619:
URL: https://github.com/apache/airflow/pull/77619#discussion_r4711021115
##########
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
Review Comment:
Since the `session` cookie is now kept, I think the session id survives
logout. FAB's `/logout/` only calls `logout_user()`, which removes the user
keys but keeps the session (e.g. `csrf_token` is still in it), and nothing
gives it a new id on the next login. Example: on a shared browser, user A notes
their session id and logs out, user B logs in and gets the same id, so A can
replay it and be signed in as B. Before, deleting the cookie gave B a new id.
Should we clear the session on logout (e.g. override `logout` in our custom
auth views to call `session.clear()`), or delete the cookie once the Flask
logout has run?
##########
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:
After the Flask logout, the user now goes to `FabIndexView` and then to
`base_url` instead of straight to the login page. Is that intended? With a
public role configured, they would land on the UI as anonymous instead of
seeing the login form.
--
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]