SachinyadavAug20 opened a new pull request, #77282:
URL: https://github.com/apache/airflow/pull/77282

   ## Intent
   
   Honor next_url in AwsAuthManager.get_url_login() to resolve issue #77280. 
Update AwsAuthManager.get_url_login() to accept next_url via kwargs and append 
?next=<url> using urllib.parse.urlencode when present, aligning with 
KeycloakAuthManager (#76362), FabAuthManager (#73134), and SimpleAuthManager 
(#67483). Add comprehensive unit test coverage with parametrization for with 
and without next_url in 
providers/amazon/tests/unit/amazon/aws/auth_manager/test_aws_auth_manager.py. 
Ensure code formatting passes ruff check and ruff format.
   
   ## What Changed
   
   - Updated `AwsAuthManager.get_url_login()` to extract `next_url` from 
keyword arguments and append it as a URL-encoded `next` query parameter when 
present.
   - Updated `TestAwsAuthManager.test_get_url_login` to be a parametrized test 
verifying login URL output without arguments, with a target `next_url`, and 
with `next_url=None`.
   
   ## Risk Assessment
   
   ✅ Low: The change is minimal, well-bounded, and aligns 
AwsAuthManager.get_url_login() with Airflow's other auth managers to support 
post-login redirection with parametrized unit tests.
   
   ## Testing
   
   Successfully verified unit test suite (91 passed) and executed 6 live 
scenarios against real AwsAuthManager instances and a live running FastAPI 
server process over TCP, capturing complete HTTP traffic and cookie state 
evidence proving next_url is preserved and encoded without regressions.
   
   - Live validation: ✅ go - 6 of 6 scenarios driven live against the product
   
   | Scenario | Result | Live | Evidence |
   | --- | --- | --- | --- |
   | AwsAuthManager.get_url_login(next_url=...) appends URL-encoded next query 
parameter | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_1_get_url_login_with_next_url
 |
   | AwsAuthManager.get_url_login() with empty kwargs returns clean base login 
URL | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_2_get_url_login_without_next_url
 |
   | AwsAuthManager.get_url_login(next_url=None) ignores None and returns clean 
base login URL | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_3_get_url_login_with_none_next_url
 |
   | AwsAuthManager.get_url_login(next_url=...) adversarial encoding for 
complex parameters, spaces, and fragments | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_4_get_url_login_with_complex_next_url
 |
   | AwsAuthManager.get_url_login(next_url=...) with custom configured [api] 
base_url | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_5_get_url_login_with_custom_base_url
 |
   | Live HTTP GET to generated login URL verifies server redirects to IdP and 
stores next_url in signed cookie | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/http_traffic_capture.txt |
   
   
   <details>
   <summary>Evidence: Live HTTP Request and Cookie Capture Transcript</summary>
   
   <code>Generated Login URL: 
http://127.0.0.1:53139/auth/login?next=%2Fdags%2Fmy_target_dag%2Fruns%2Frun_01&#10;HTTP
 Status: 307&#10;Location: 
http://127.0.0.1:53139/idp/sso?SAMLRequest=...&amp;RelayState=login-redirect%3AgdSpxBzgcZAH9712yerWrw&#10;Set-Cookie:
 
_awsam_login_state=&#34;W3sibm9uY2UiOiJnZFNweEJ6Z2NaQUg5NzEyeWVyV3J3IiwicmVxdWVzdF9pZCI6Ik9ORUxPR0lOXzE3NGNlZWMxNDg1NGY5OTNiNWIxODMyMTc3ODk3YWNjMWU0YjgyNzYiLCJtb2RlIjoibG9naW4tcmVkaXJlY3QiLCJleHAiOjE3OTUwNjAyMDcuOTE1NTk0LCJuZXh0IjoiL2RhZ3MvbXlfdGFyZ2V0X2RhZy9ydW5zL3J1bl8wMSJ9XQ==.f7a0f193954de7d36280381372533ba753f2e18ad27013e80d6f95dc614fd708&#34;;
 HttpOnly; Max-Age=600; Path=/; SameSite=lax&#10;Decoded _awsam_login_state 
cookie entries:&#10;[&#10;{&#10;&#34;nonce&#34;: 
&#34;gdSpxBzgcZAH9712yerWrw&#34;,&#10;&#34;request_id&#34;: 
&#34;ONELOGIN_174ceec14854f993b5b1832177897acc1e4b8276&#34;,&#10;&#34;mode&#34;:
 &#34;login-redirect&#34;,&#10;&#34;exp&#34;: 
1795060207.915594,&#10;&#34;next&#34;: &#34;/dags/my_target_dag/runs/run_0
 1&#34;&#10;}&#10;]</code>
   
   ```text
   Generated Login URL: 
http://127.0.0.1:53139/auth/login?next=%2Fdags%2Fmy_target_dag%2Fruns%2Frun_01
   Sending HTTP GET to 
http://127.0.0.1:53139/auth/login?next=%2Fdags%2Fmy_target_dag%2Fruns%2Frun_01 
(allow_redirects=False)...
   HTTP Status: 307
   Response Headers:
     date: Thu, 19 Nov 2026 03:40:07 GMT
     server: uvicorn
     content-length: 0
     location: 
http://127.0.0.1:53139/idp/sso?SAMLRequest=fVNdb5swFH3vr0C8UzCQEqwEKUv2ESlLUEL7sJfKmJvUmrGZbZbs38%2BmyZpKa%2BAB6d5zjs%2B5vkw0aXmHZ715EVv41YM2d553arnQeGhN%2FV4JLIlmGgvSgsaG4t3s%2BwrH9xHulDSSSu6%2FI93mEK1BGSaFIy0XU3%2Bz%2FrzafF2un1GWUgCK0vEo3ed5Uo9qNE5ilGXjPCOUIkjrcZw9OOITKG01pr6VHIS07mEptCHC2GIUPwQIBSivogSnEY6yHw61sPmYIGZgvhjT4TBEcXYf2RfhUYKSPGRNF2otHbw8x%2FvERMPE4Xau%2BhWk8beqKoNys6ucxOySdi6F7ltQO1C%2FGYXH7epDB8TeRsjlgYlnSjivCf3pF1bL8yZuvHjIqgpy1IGDBi0R5AAqcM2AcgbCTMJr5Bu3w2trfLkoJWf0z1B3zxepWmI%2BzoesN1dhTbAfoLgXugPK9gwa%2F5%2FMjHN5nCsgBqa%2BUT34Xvju8POKQTMsnB2JgZPx5rLtiGLaXQqcCDXntG%2BJr%2BFzbjdoC%2Fvi5pJRTB3Olkv7OUrVuMsEas%2BuFLHmpboM6b%2Fir67DG7aLu0v7%2Bu8p%2FgI%3D&RelayState=login-redirect%3AgdSpxBzgcZAH9712yerWrw
     set-cookie: 
_awsam_login_state="W3sibm9uY2UiOiJnZFNweEJ6Z2NaQUg5NzEyeWVyV3J3IiwicmVxdWVzdF9pZCI6Ik9ORUxPR0lOXzE3NGNlZWMxNDg1NGY5OTNiNWIxODMyMTc3ODk3YWNjMWU0YjgyNzYiLCJtb2RlIjoibG9naW4tcmVkaXJlY3QiLCJleHAiOjE3OTUwNjAyMDcuOTE1NTk0LCJuZXh0IjoiL2RhZ3MvbXlfdGFyZ2V0X2RhZy9ydW5zL3J1bl8wMSJ9XQ==.f7a0f193954de7d36280381372533ba753f2e18ad27013e80d6f95dc614fd708";
 HttpOnly; Max-Age=600; Path=/; SameSite=lax
   Decoded _awsam_login_state cookie entries: [
     {
       "nonce": "gdSpxBzgcZAH9712yerWrw",
       "request_id": "ONELOGIN_174ceec14854f993b5b1832177897acc1e4b8276",
       "mode": "login-redirect",
       "exp": 1795060207.915594,
       "next": "/dags/my_target_dag/runs/run_01"
     }
   ]
   ```
   </details>
   <details>
   <summary>Evidence: Live Scenarios Execution Transcript</summary>
   
   <code>=== LIVE PRODUCT SCENARIO VALIDATION FOR AwsAuthManager.get_url_login 
===&#10;[PASS] scenario_1_get_url_login_with_next_url&#10;[PASS] 
scenario_2_get_url_login_without_next_url&#10;[PASS] 
scenario_3_get_url_login_with_none_next_url&#10;[PASS] 
scenario_4_get_url_login_with_complex_next_url&#10;[PASS] 
scenario_5_get_url_login_with_custom_base_url&#10;[PASS] 
scenario_6_live_http_server_navigation_and_cookie_state</code>
   
   ```text
   === LIVE PRODUCT SCENARIO VALIDATION FOR AwsAuthManager.get_url_login ===
   Execution timestamp: 2026-11-19T03:40:07Z
   
   [PASS] scenario_1_get_url_login_with_next_url
       description: Calling get_url_login(next_url='/dags/example_dag') appends 
encoded ?next= parameter
       input_kwargs: {'next_url': '/dags/example_dag'}
       actual_url: /auth/login?next=%2Fdags%2Fexample_dag
       expected_url: /auth/login?next=%2Fdags%2Fexample_dag
   
   [PASS] scenario_2_get_url_login_without_next_url
       description: Calling get_url_login() with empty kwargs returns clean 
base URL without query string
       input_kwargs: {}
       actual_url: /auth/login
       expected_url: /auth/login
   
   [PASS] scenario_3_get_url_login_with_none_next_url
       description: Calling get_url_login(next_url=None) returns clean base URL 
without query string
       input_kwargs: {'next_url': None}
       actual_url: /auth/login
       expected_url: /auth/login
   
   [PASS] scenario_4_get_url_login_with_complex_next_url
       description: Complex next_url containing query parameters, spaces, 
colons and fragments is safely URL-encoded
       input_kwargs: {'next_url': '/dags/test_dag/grid?tab=graph&search=my 
tag&run_id=manual__2026-11-19T08:00:00#row-5'}
       actual_url: 
/auth/login?next=%2Fdags%2Ftest_dag%2Fgrid%3Ftab%3Dgraph%26search%3Dmy+tag%26run_id%3Dmanual__2026-11-19T08%3A00%3A00%23row-5
       expected_url: 
/auth/login?next=%2Fdags%2Ftest_dag%2Fgrid%3Ftab%3Dgraph%26search%3Dmy+tag%26run_id%3Dmanual__2026-11-19T08%3A00%3A00%23row-5
       decoded_next_param: /dags/test_dag/grid?tab=graph&search=my 
tag&run_id=manual__2026-11-19T08:00:00#row-5
   
   [PASS] scenario_5_get_url_login_with_custom_base_url
       description: Custom [api] base_url is respected and correctly joined 
with auth prefix and next_url parameter
       custom_base_url: https://airflow.internal.net:8443
       input_kwargs: {'next_url': '/dags/analytics_dag'}
       actual_url: 
https://airflow.internal.net:8443/auth/login?next=%2Fdags%2Fanalytics_dag
       expected_url: 
https://airflow.internal.net:8443/auth/login?next=%2Fdags%2Fanalytics_dag
   
   [PASS] scenario_6_live_http_server_navigation_and_cookie_state
       description: Live HTTP GET against URL generated by get_url_login 
preserves next_url in server login state cookie
       login_url: 
http://127.0.0.1:53139/auth/login?next=%2Fdags%2Fmy_target_dag%2Fruns%2Frun_01
       http_status_code: 307
       redirect_location: 
http://127.0.0.1:53139/idp/sso?SAMLRequest=fVNdb5swFH3vr0C8UzCQEqwEKUv2ESlLUEL7sJfKmJvUmrGZbZbs38%2BmyZpKa%2BAB6d5zjs%2B5vkw0aXmHZ715EVv41YM2d553arnQeGhN%2FV4JLIlmGgvSgsaG4t3s%2BwrH9xHulDSSSu6%2FI93mEK1BGSaFIy0XU3%2Bz%2FrzafF2un1GWUgCK0vEo3ed5Uo9qNE5ilGXjPCOUIkjrcZw9OOITKG01pr6VHIS07mEptCHC2GIUPwQIBSivogSnEY6yHw61sPmYIGZgvhjT4TBEcXYf2RfhUYKSPGRNF2otHbw8x%2FvERMPE4Xau%2BhWk8beqKoNys6ucxOySdi6F7ltQO1C%2FGYXH7epDB8TeRsjlgYlnSjivCf3pF1bL8yZuvHjIqgpy1IGDBi0R5AAqcM2AcgbCTMJr5Bu3w2trfLkoJWf0z1B3zxepWmI%2BzoesN1dhTbAfoLgXugPK9gwa%2F5%2FMjHN5nCsgBqa%2BUT34Xvju8POKQTMsnB2JgZPx5rLtiGLaXQqcCDXntG%2BJr%2BFzbjdoC%2Fvi5pJRTB3Olkv7OUrVuMsEas%2BuFLHmpboM6b%2Fir67DG7aLu0v7%2Bu8p%2FgI%3D&RelayState=login-redirect%3AgdSpxBzgcZAH9712yerWrw
       stored_next_in_cookie: /dags/my_target_dag/runs/run_01
       expected_stored_next: /dags/my_target_dag/runs/run_01
   ```
   </details>
   <details>
   <summary>Evidence: Live Scenarios JSON Output</summary>
   
   ```text
   {
     "scenario_1_get_url_login_with_next_url": {
       "status": "PASS",
       "details": {
         "description": "Calling get_url_login(next_url='/dags/example_dag') 
appends encoded ?next= parameter",
         "input_kwargs": {
           "next_url": "/dags/example_dag"
         },
         "actual_url": "/auth/login?next=%2Fdags%2Fexample_dag",
         "expected_url": "/auth/login?next=%2Fdags%2Fexample_dag"
       }
     },
     "scenario_2_get_url_login_without_next_url": {
       "status": "PASS",
       "details": {
         "description": "Calling get_url_login() with empty kwargs returns 
clean base URL without query string",
         "input_kwargs": {},
         "actual_url": "/auth/login",
         "expected_url": "/auth/login"
       }
     },
     "scenario_3_get_url_login_with_none_next_url": {
       "status": "PASS",
       "details": {
         "description": "Calling get_url_login(next_url=None) returns clean 
base URL without query string",
         "input_kwargs": {
           "next_url": null
         },
         "actual_url": "/auth/login",
         "expected_url": "/auth/login"
       }
     },
     "scenario_4_get_url_login_with_complex_next_url": {
       "status": "PASS",
       "details": {
         "description": "Complex next_url containing query parameters, spaces, 
colons and fragments is safely URL-encoded",
         "input_kwargs": {
           "next_url": "/dags/test_dag/grid?tab=graph&search=my 
tag&run_id=manual__2026-11-19T08:00:00#row-5"
         },
         "actual_url": 
"/auth/login?next=%2Fdags%2Ftest_dag%2Fgrid%3Ftab%3Dgraph%26search%3Dmy+tag%26run_id%3Dmanual__2026-11-19T08%3A00%3A00%23row-5",
         "expected_url": 
"/auth/login?next=%2Fdags%2Ftest_dag%2Fgrid%3Ftab%3Dgraph%26search%3Dmy+tag%26run_id%3Dmanual__2026-11-19T08%3A00%3A00%23row-5",
         "decoded_next_param": "/dags/test_dag/grid?tab=graph&search=my 
tag&run_id=manual__2026-11-19T08:00:00#row-5"
       }
     },
     "scenario_5_get_url_login_with_custom_base_url": {
       "status": "PASS",
       "details": {
         "description": "Custom [api] base_url is respected and correctly 
joined with auth prefix and next_url parameter",
         "custom_base_url": "https://airflow.internal.net:8443";,
         "input_kwargs": {
           "next_url": "/dags/analytics_dag"
         },
         "actual_url": 
"https://airflow.internal.net:8443/auth/login?next=%2Fdags%2Fanalytics_dag";,
         "expected_url": 
"https://airflow.internal.net:8443/auth/login?next=%2Fdags%2Fanalytics_dag";
       }
     },
     "scenario_6_live_http_server_navigation_and_cookie_state": {
       "status": "PASS",
       "details": {
         "description": "Live HTTP GET against URL generated by get_url_login 
preserves next_url in server login state cookie",
         "login_url": 
"http://127.0.0.1:53139/auth/login?next=%2Fdags%2Fmy_target_dag%2Fruns%2Frun_01";,
         "http_status_code": 307,
         "redirect_location": 
"http://127.0.0.1:53139/idp/sso?SAMLRequest=fVNdb5swFH3vr0C8UzCQEqwEKUv2ESlLUEL7sJfKmJvUmrGZbZbs38%2BmyZpKa%2BAB6d5zjs%2B5vkw0aXmHZ715EVv41YM2d553arnQeGhN%2FV4JLIlmGgvSgsaG4t3s%2BwrH9xHulDSSSu6%2FI93mEK1BGSaFIy0XU3%2Bz%2FrzafF2un1GWUgCK0vEo3ed5Uo9qNE5ilGXjPCOUIkjrcZw9OOITKG01pr6VHIS07mEptCHC2GIUPwQIBSivogSnEY6yHw61sPmYIGZgvhjT4TBEcXYf2RfhUYKSPGRNF2otHbw8x%2FvERMPE4Xau%2BhWk8beqKoNys6ucxOySdi6F7ltQO1C%2FGYXH7epDB8TeRsjlgYlnSjivCf3pF1bL8yZuvHjIqgpy1IGDBi0R5AAqcM2AcgbCTMJr5Bu3w2trfLkoJWf0z1B3zxepWmI%2BzoesN1dhTbAfoLgXugPK9gwa%2F5%2FMjHN5nCsgBqa%2BUT34Xvju8POKQTMsnB2JgZPx5rLtiGLaXQqcCDXntG%2BJr%2BFzbjdoC%2Fvi5pJRTB3Olkv7OUrVuMsEas%2BuFLHmpboM6b%2Fir67DG7aLu0v7%2Bu8p%2FgI%3D&RelayState=login-redirect%3AgdSpxBzgcZAH9712yerWrw";,
         "stored_next_in_cookie": "/dags/my_target_dag/runs/run_01",
         "expected_stored_next": "/dags/my_target_dag/runs/run_01"
       }
     }
   }
   ```
   </details>
   
   ## Pipeline
   
   Updates from [git push 
no-mistakes](https://github.com/kunchenguid/no-mistakes)
   
   <!-- no-mistakes-pipeline-attestation:v1 
{"head_sha":"8769eb9691c90fd68bc7ea2beb3dfb754d1e38e5","steps":[{"step":"intent","status":"completed"},{"step":"rebase","status":"completed"},{"step":"review","status":"completed"},{"step":"test","status":"completed"},{"step":"document","status":"completed"},{"step":"lint","status":"completed"},{"step":"push","status":"completed"},{"step":"pr","status":"running"},{"step":"ci","status":"pending"}],"live_validation":{"verdict":"go","live":6,"total":6}}
 -->
   
   <details>
   <summary>✅ **Intent** - passed</summary>
   
   ✅ No issues found.
   </details>
   
   <details>
   <summary>✅ **Rebase** - passed</summary>
   
   ✅ No issues found.
   </details>
   
   <details>
   <summary>✅ **Review** - passed</summary>
   
   ✅ No issues found.
   </details>
   
   <details>
   <summary>✅ **Test** - passed</summary>
   
   ✅ No issues found.
   - Live validation: ✅ go - 6 of 6 scenarios driven live against the product
   
   | Scenario | Result | Live | Evidence |
   | --- | --- | --- | --- |
   | AwsAuthManager.get_url_login(next_url=...) appends URL-encoded next query 
parameter | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_1_get_url_login_with_next_url
 |
   | AwsAuthManager.get_url_login() with empty kwargs returns clean base login 
URL | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_2_get_url_login_without_next_url
 |
   | AwsAuthManager.get_url_login(next_url=None) ignores None and returns clean 
base login URL | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_3_get_url_login_with_none_next_url
 |
   | AwsAuthManager.get_url_login(next_url=...) adversarial encoding for 
complex parameters, spaces, and fragments | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_4_get_url_login_with_complex_next_url
 |
   | AwsAuthManager.get_url_login(next_url=...) with custom configured [api] 
base_url | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/live_scenarios_output.json#scenario_5_get_url_login_with_custom_base_url
 |
   | Live HTTP GET to generated login URL verifies server redirects to IdP and 
stores next_url in signed cookie | ✅ pass | live | 
~/.no-mistakes/evidence/01M7RXB1R6F1GMV6NS1ZYT2V2R/http_traffic_capture.txt |
   
   - `uv run --project providers/amazon pytest 
providers/amazon/tests/unit/amazon/aws/auth_manager/test_aws_auth_manager.py::TestAwsAuthManager::test_get_url_login
 -xvs`
   - `uv run --project providers/amazon pytest 
providers/amazon/tests/unit/amazon/aws/auth_manager/ -xvs`
   - `Live execution of AwsAuthManager.get_url_login() under standard, None, 
empty, adversarial, and custom [api] base_url configurations`
   - `Live HTTP GET request driven against an ephemeral running FastAPI server 
mounting AwsAuthManager login routes to verify HTTP 307 redirect and 
_awsam_login_state cookie preservation`
   </details>
   
   <details>
   <summary>✅ **Document** - passed</summary>
   
   ✅ No issues found.
   </details>
   
   <details>
   <summary>✅ **Lint** - passed</summary>
   
   ✅ No issues found.
   </details>
   
   <details>
   <summary>✅ **Push** - passed</summary>
   
   ✅ No issues found.
   </details>
   
   
   ## Issues
   
   Closes #77280


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