SachinyadavAug20 opened a new issue, #77208:
URL: https://github.com/apache/airflow/issues/77208

   ### Under which category would you file this issue?
   Providers
   
   ### Apache Airflow version
   main (Airflow 3.0+)
   
   ### Apache Airflow Provider(s)
   amazon
   
   ### What happened and how to reproduce it?
   
   **Issue Description**
   When an unauthenticated user visits a deep link (such as a specific DAG, 
task run, or log page), Airflow routes them to `/auth/login?next=<destination>`.
   
   In `AwsAuthManager`, this destination is completely lost:
   1. `AwsAuthManager.get_url_login(next_url=...)` ignores the `next_url` kwarg 
and returns a bare `/auth/login` without query parameters 
(`providers/amazon/.../aws_auth_manager.py:540`).
   2. Even when `next` is passed as a query param to `/auth/login`, 
`_start_login()` in `providers/amazon/.../routes/login.py` does not read or 
retain it.
   3. Upon completing the SAML authentication round trip at 
`/auth/login_callback`, the handler hardcodes a redirect to `conf.get("api", 
"base_url", fallback="/")`, always sending users to the home page instead of 
their requested page.
   
   The same bug was previously resolved for:
   - `SimpleAuthManager` in #67483 and #67965 (#67476)
   - `FabAuthManager` in #73134 (#73133)
   - `KeycloakAuthManager` in #76362
   
   `AwsAuthManager` is currently the only auth manager where `next_url` is not 
preserved.
   
   **Steps to reproduce:**
   1. Configure Airflow to use `AwsAuthManager`.
   2. As a logged-out user, navigate to a direct link such as 
`http://localhost:8080/dags/my_dag/runs/run_id/tasks/my_task`.
   3. Complete the login flow with the IdP.
   4. After callback, observe that the browser is redirected to `/` instead of 
`/dags/my_dag/runs/run_id/tasks/my_task`.
   
   ### What you think should happen instead?
   1. `AwsAuthManager.get_url_login(next_url=...)` should append `?next=<url>`.
   2. The login route should validate `next` using `is_safe_url` and retain it 
in a short-lived HTTP-only cookie.
   3. `login_callback` should redirect to the stored `next` URL (falling back 
to `[api] base_url` if unset or unsafe) and clear the cookie.
   
   ### Operating System
   Linux
   
   ### Deployment
   Other
   
   ### Are you willing to submit PR?
   [✓] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   [✓] I agree to follow this project's Code of Conduct
   


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