litellm/tests/test_litellm/proxy/middleware
yucheng-berri 5637b3212e
feat(proxy): configurable response headers and login-page hint (#30792)
* feat(proxy): add configurable response headers middleware

Adds a small ASGI middleware that sets standard response headers
(X-Frame-Options, Content-Security-Policy frame-ancestors, X-Content-Type-Options)
on proxy and UI responses. Strict-Transport-Security is optional and gated
behind LITELLM_ENABLE_HSTS for HTTPS deployments. Values use setdefault so a
route that sets its own header is preserved.

* feat(proxy/ui): make login page credentials hint configurable

build_ui_login_form accepts a hide_default_credentials_hint parameter and
google_login reads LITELLM_HIDE_DEFAULT_CREDENTIALS_HINT (or general_settings)
so the legacy login page behaves consistently with the new UI. Also collapses
a duplicated branch and removes an unused variable and module-level constant.

* fix(proxy/ui): apply credentials hint flag on /fallback/login

The /fallback/login handler still rendered the default-credentials hint
regardless of LITELLM_HIDE_DEFAULT_CREDENTIALS_HINT. Collapse its duplicate
branch and forward the flag, matching google_login, so all login surfaces
behave consistently. Adds regression tests for /fallback/login and makes the
ui_sso test helper restore os.environ so env vars do not leak across tests.
2026-06-18 18:12:45 -07:00
..
test_in_flight_requests_middleware.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_auth_middleware.py fix(proxy): point /metrics 401 at the opt-out flag 2026-05-08 18:09:14 -07:00
test_prometheus_auth_middleware_asgi.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_security_headers_middleware.py feat(proxy): configurable response headers and login-page hint (#30792) 2026-06-18 18:12:45 -07:00