vincbeck commented on code in PR #77209:
URL: https://github.com/apache/airflow/pull/77209#discussion_r4604617519
##########
providers/amazon/src/airflow/providers/amazon/aws/auth_manager/routes/login.py:
##########
@@ -205,6 +207,27 @@ def _start_login(request: Request, mode: str) ->
RedirectResponse:
}
)
_write_pending_logins(request, response, pending)
+ if mode == LOGIN_MODE_REDIRECT:
+ cookie_path = get_cookie_path()
+ secure = _is_secure_request(request)
+ next_url = request.query_params.get("next")
+ if next_url and is_safe_url(next_url, request=request):
+ response.set_cookie(
Review Comment:
`/login` returns a 500 when `next` contains a non-Latin-1 character.
Starlette encodes `Set-Cookie` as latin-1, so `next=/dags?search=日本` raises
`UnicodeEncodeError` here. Before this PR the same link still logged the user
in. Storing `next` in the pending entry (base64 JSON) fixes this too.
##########
providers/amazon/src/airflow/providers/amazon/aws/auth_manager/routes/login.py:
##########
@@ -205,6 +207,27 @@ def _start_login(request: Request, mode: str) ->
RedirectResponse:
}
)
_write_pending_logins(request, response, pending)
+ if mode == LOGIN_MODE_REDIRECT:
+ cookie_path = get_cookie_path()
+ secure = _is_secure_request(request)
+ next_url = request.query_params.get("next")
+ if next_url and is_safe_url(next_url, request=request):
+ response.set_cookie(
+ COOKIE_NAME_LOGIN_NEXT_URL,
Review Comment:
There is only one `_awsam_login_next_url` cookie per browser, but pending
logins are kept per tab. Example: tab A starts a login with `next=/dags/a`,
then tab B starts one with `next=/dags/b` (or without `next`, which deletes the
cookie). Tab A then lands on `/dags/b` (or the home page). A `/login/token`
callback also clears it for any UI login still pending. Fix: store `next` in
the pending entry next to `nonce` and `request_id`, read `matched.get("next")`
in `login_callback`, and drop the extra cookie. It is then signed, per tab,
cleared with its entry, and IdP-initiated logins fall back to `base_url`
instead of picking up a leftover target.
--
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]