SachinyadavAug20 opened a new pull request, #77368: URL: https://github.com/apache/airflow/pull/77368
closes: #77365 In `AwsAuthManager` routes (`airflow/providers/amazon/aws/auth_manager/routes/login.py`), `_prepare_request(request)` constructed the SAML request context dict with: ```python "https": "on" if request.url.scheme == "https" else "off", "http_host": host, "server_port": request.url.port, ``` where `host = parsed.hostname`. In production setups where Airflow runs behind a reverse proxy or load balancer with TLS termination (e.g. AWS Application Load Balancer, CloudFront, Nginx): 1. The container receives requests over internal HTTP (e.g., scheme is `"http"` and port is `8000`), while the canonical public `base_url` is `https://airflow.example.com`. 2. Because `assertionConsumerService` is built from `base_url` (`https://...`), the IdP issues SAML assertions with `Destination="https://airflow.example.com/api/v2/auth/login_callback"`. 3. `python3-saml` reconstructs the callback URL using `data` from `_prepare_request()`. Because `https` is set to `"off"` and `server_port` is `8000`, it detects a destination mismatch and raises `OneLogin_Saml2_Error: The response was received at http://airflow.example.com:8000/... instead of https://airflow.example.com/...`. This update aligns `_prepare_request()` with `base_url` and `_is_secure_request()`: - Use `parsed.netloc or parsed.hostname` so ports in `base_url` are preserved in `http_host`. - Check `parsed.scheme == "https" or _is_secure_request(request)` to correctly mark `"https": "on"`. - Determine `server_port` consistently (using `parsed.port` if set, 443 for HTTPS, or falling back to `request.url.port or 80`). - Add parametrized unit tests in `test_login.py` covering standard HTTP, TLS reverse proxy, custom HTTPS port, and default HTTP port scenarios. Was generative AI tooling used to co-author this PR? Yes (Antigravity) Generated-by: Antigravity following the guidelines -- 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]
