mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
The oauth2_id_jag egress arm spends the user's IdP id_token as its RFC 8693 subject_token, but a front-door client presents only a gateway-minted llm_session_ bearer, so hop A had nothing usable and EMA was unreachable end to end for exactly the clients it exists for — while a gateway-issued credential presented via Authorization was forwarded verbatim to the IdP. One rule per concern, each with a single owner: - Provenance (credential_provenance.py, new): the inbound bearer is classified once at the edge (absent / gateway_credential / external_jwt / external_opaque) by the one property every gateway mint shares and no external token has: it verifies under this gateway's master key. A new mint format is refused as exchange material by construction, with no denylist to grow stale. id_jag exchanges the inbound bearer only when it is an external JWT; token_exchange (OBO) keeps exchange-what-was-presented but refuses gateway credentials. - Header selection (_subject_bearer_token): every egress surface (tools call/list, prompts, resources, templates, OpenAPI) selects the caller's bearer through one manager rule; for id_jag the bearer must also be the credential that admitted the caller, so a free-riding Authorization value bound to nobody is never exchanged. - Sourcing (_id_jag_subject_token): the caller's presented id_token when the inbound bearer is one, else the stored SSO assertion, else fail closed — shared verbatim by resolve and invalidate. - Storage (sso_assertion_store.py): the generic-SSO callback persists the IdP id_token + refresh token as one encrypted row per user (latest login wins), write-through to the DB so every pod sees it, gated on an id_jag server existing per the config and DB authorities (never the registry snapshot). Reads compose the shared per-user credential stack — Cached(Refreshing(db)) — for positive-only caching, expiry-skewed renewal and per-user single-flight; the TokenRefresher protocol now documents the raise-through contract the EMA refresher relies on. - Renewal lifecycle: expiry is judged by readers (30s buffer). A dead grant requires proof about the GRANT, and RFC 6749 has exactly one code that states it: invalid_grant. Every other outcome (invalid_client and friends are the gateway's own client config failing — ops-fixable), a 429, a 4xx without an error object, a 5xx, or a transport failure reads retryable and never touches the row. A proven verdict is recorded ON the row by stripping its refresh token — never in a cache beside it — so it holds on every pod, costs one POST total, and a re-login lifts it by construction. The verdict write re-reads the row and strips only a row still carrying the exact rejected token, preserving the row's other material, so a losing pod in a cross-pod rotation race cannot clobber the winner's renewed assertion. - Failure semantics, same story on every surface: absence -> 412 naming the gateway-SSO remedy; dead grant -> 401 + re-authenticate challenge; outage -> retryable 503, never a false re-login and never absence. Single-server routes surface these at the transport edge via preflight_id_jag (sibling of the OBO preflight), where an HTTP status and WWW-Authenticate still reach the client — in-session list handlers can only serialize a raise into a JSON-RPC error. The aggregate absorbs per-server faults, and tools/list outcomes now preserve the retryable-vs-terminal class (unavailable -> 503, precondition -> 412) instead of reporting a dependency outage as the gateway's own 500. Tests pin the rules, not the mechanisms: provenance totality over every current mint plus adversarial input, the one-POST-per-dead-grant bound, the re-signed-in caller never refused, absence-vs-outage by remedy, the cross-pod clobber no-op, the invalid_grant-only proof predicate, scope identity between login and refresh, winner-and-waiter verdict sharing in the shared stack, and the preflight wiring gated to single-server routes. Part of LIT-3856 (PR 2 of the EMA stack, on the #34072 assertion store). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| agent_tests | ||
| audio_tests | ||
| basic_proxy_startup_tests | ||
| batches_tests | ||
| benchmarks | ||
| code_coverage_tests | ||
| documentation_tests | ||
| e2e | ||
| enterprise | ||
| guardrails_tests | ||
| image_gen_tests | ||
| integration | ||
| litellm | ||
| litellm-proxy-extras | ||
| litellm_core_utils | ||
| litellm_utils_tests | ||
| llm_responses_api_testing | ||
| llm_translation | ||
| load_tests | ||
| local_testing | ||
| logging_callback_tests | ||
| mcp_tests | ||
| multi_instance_e2e_tests | ||
| ocr_tests | ||
| old_proxy_tests/tests | ||
| openai_endpoints_tests | ||
| otel_tests | ||
| pass_through_tests | ||
| pass_through_unit_tests | ||
| proxy_admin_ui_tests | ||
| proxy_behavior | ||
| proxy_e2e_anthropic_messages_tests | ||
| proxy_migration_tests | ||
| proxy_security_tests | ||
| proxy_unit_tests | ||
| router_unit_tests | ||
| scim_tests | ||
| search_tests | ||
| spend_tracking_tests | ||
| store_model_in_db_tests | ||
| test_litellm | ||
| unified_google_tests | ||
| vector_store_tests | ||
| windows_tests | ||
| __init__.py | ||
| _fake_openai_endpoint_server.py | ||
| _flush_vcr_cache.py | ||
| _live_test_helpers.py | ||
| _openai_record_replay_proxy.py | ||
| _vcr_conftest_common.py | ||
| _vcr_redis_persister.py | ||
| _ws_vcr.py | ||
| eval_swe_bench.py | ||
| fake_openai_endpoint.py | ||
| gettysburg.wav | ||
| large_text.py | ||
| openai_batch_completions.jsonl | ||
| pyrightconfig.json | ||
| README.MD | ||
| test_anthropic_compaction_usage.py | ||
| test_budget_management.py | ||
| test_callbacks_on_proxy.py | ||
| test_config.py | ||
| test_debug_warning.py | ||
| test_default_encoding_non_root.py | ||
| test_end_users.py | ||
| test_entrypoint.py | ||
| test_fallbacks.py | ||
| test_gpt5_azure_temperature_support.py | ||
| test_health.py | ||
| test_keys.py | ||
| test_litellm_proxy_responses_config.py | ||
| test_logging.conf | ||
| test_models.py | ||
| test_new_vector_store_endpoints.py | ||
| test_openai_endpoints.py | ||
| test_organizations.py | ||
| test_otel_thread_leak.py | ||
| test_passthrough_endpoints.py | ||
| test_presidio_latency.py | ||
| test_proxy_server_non_root.py | ||
| test_ratelimit.py | ||
| test_resource_cleanup.py | ||
| test_service_logger_otel.py | ||
| test_spend_logs.py | ||
| test_team.py | ||
| test_team_logging.py | ||
| test_team_members.py | ||
| test_users.py | ||
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/test_litellm
This folder can only run mock tests.