mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
Swaps the caller's live inbound token for a token bound to server.resource at the IdP's exchange endpoint, via a new TokenExchanger port (hand-rolled RFC 8693 body deferred, faked in tests). The inbound token is sent ONLY to the exchanger, never to the upstream - the upstream gets the exchanged token; that is the core invariant distinguishing it from passthrough, and is locked by a test. No inbound token -> unauthorized. Reuses the per-user TokenStore + Clock + StoredToken; 'refresh' means re-exchange (no refresh token). Folds in the scoping decisions: drop TokenExchangeConfig.audience (use server.resource for the RFC 8707 indicator) and make token_exchange_endpoint optional (discovered via RFC 8414), so an empty token_exchange config is valid. Error mapping via the exchanger: subject_token invalid -> 401 (user re-auths), config -> 500, endpoint down -> 503. Cache is best-effort (read failure re-exchanges, write failure ignored), deliberately differing from authorization_code on the same TokenStore since the exchanged token is re-exchangeable. Tests: the swap invariant (inbound->exchanger, exchanged->upstream, bound to resource), no-inbound->401, cached-fresh (no exchange), re-mint near expiry, subject-invalid->401, config->500, down->503, cache-degrades, and discovery-default config. 48 tests, gates green. |
||
|---|---|---|
| .. | ||
| gateway | ||
| test_configs | ||
| conftest.py | ||
| mcp_server.py | ||
| test_aresponses_api_with_mcp.py | ||
| test_mcp_auth_header_extraction.py | ||
| test_mcp_auth_priority.py | ||
| test_mcp_chat_completions.py | ||
| test_mcp_client_unit.py | ||
| test_mcp_guardrails.py | ||
| test_mcp_hooks.py | ||
| test_mcp_litellm_client.py | ||
| test_mcp_logging.py | ||
| test_mcp_server.py | ||
| test_oauth2_mcp_config.yaml | ||
| test_openapi_spec_path_url.py | ||
| test_per_user_oauth_cache.py | ||
| test_proxy_mcp_e2e.py | ||
| test_semantic_tool_filter_e2e.py | ||