litellm/tests/unit/proxy/auth
moe-berri ab51f3fe40
feat(realtime)!: serve GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband (#53282)
* feat(realtime): GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): pin sidebands to the session's deployment and authorize Live WebRTC like Live WebSocket

Run model-aware auth and the guardrail check before the provider session is created, authorize the attaching key for the session model, release an unmetered attach's budget hold and slot, forward call_id to Azure, and hand back provider errors on create.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): refuse WebRTC calls the proxy cannot meter, attach by creating key only, and pin Realtime sidebands

Wait for the billing sideband to join before returning the SDP answer, limit Live attach to the key that created the session, keep a Realtime WebRTC call on the deployment that minted its client secret, and select the Live deployment with the caller's request data.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): narrow the minted client secret to a string before it is encoded

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): resolve a deployment's stored credential when creating a Live WebRTC session

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): stop a billing sideband that did not join in time

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): let a refused billing sideband release its holds before it is stopped

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(realtime): rejoin a billing sideband that drops while its WebRTC call still runs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): carry the seconds each sideband billed to the one that rejoins, and stop a sideband given up on while it connects

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(realtime): authorize GPT-Live delegation against the key and keep retrying a dropped billing sideband

A Live session can delegate work to a second model and to vector stores. The delegated model and vector store ids are now checked against the calling key on WebRTC create, on the WebSocket session.start, and on later client frames that pass through the proxy.

A billing sideband that drops mid-call is now rejoined with a bounded, growing wait (1s up to 30s, 8 tries) and stops as soon as the provider reports the call gone. The caller's call is never ended by the proxy.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): check JSON-escaped delegation frames and enforce the tool allowlist on GPT-Live delegation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(realtime): walk a GPT-Live delegation without recursion

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): join an Azure WebRTC call's sideband on the GA route when the deployment is configured for beta

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): keep the billing sideband out of the call, bound its rejoins, add meter_webrtc_calls, shrink the client secret

The proxy's sideband no longer runs guardrails or sends anything into a WebRTC call.
A rejoin the proxy refuses itself is tried at most three times and logs one warning.
general_settings.meter_webrtc_calls set to false starts WebRTC calls without the billing sideband.
The realtime client secret carries the key's hash and the key is read again when the call starts.
POST /v1/live/sessions refuses any transport other than webrtc.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): send a delegated GPT-Live model under its provider name and hold it to its model budget

A GPT-Live session that delegates to a proxy model group now reaches the provider with the model that group is configured to call, on WebRTC create, on the WebSocket session.start and on later client frames the proxy relays.

A delegation to a model whose model_max_budget is used up is refused before the provider is called, and what a delegated response cost is charged to the delegated model's budget while the session's own model pays for the rest.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response to every budgeted model group that calls its model

The provider reports a delegated response under its own model name, so when two proxy model groups call that model the charge went to the first one by name and the budget that admitted the delegation could stay untouched. Each budgeted group that calls the model is now charged.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response to a team model's public name

A team-scoped deployment is routed under an internal name while its budget is keyed by the public name, so the public name now counts as a name the delegated model's budget can be charged under.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response once to a budget that covers several of its names

A wildcard or access-group budget resolves every name of the delegated model to one counter, so the counters are now deduplicated per delegated response before they are charged.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response only to deployments of that model or a dated snapshot of it

A deployment of gpt-4o no longer matches a delegated gpt-4o-mini response by prefix.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response to its model's budget at the session's regional price

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): check a delegation against every budget it is charged to, keep tool schemas unchanged, and read the minting key from the key cache

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): rename delegated models by walking past tool schemas, linear in the size of the delegation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): a token always names its minting key, and a delegation the proxy cannot fully read is refused

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): drop the token fallback for an unreadable minting key, and never look the master key up as a stored key

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-21 22:49:26 -08:00
..
host fix(auth): carry the user row's email on refreshed session tokens (#53184) 2026-11-21 11:57:49 -08:00
__init__.py ci: move tests/proxy_unit_tests to tests/unit/proxy and run the proxy-db shards from litellm-tests (#42903) 2026-09-24 22:59:11 +00:00
_user_table.py feat(db): rust repositories for user, end user and budget auth objects (#52170) 2026-11-18 22:32:05 +00:00
conftest.py refactor(proxy): move non-auth writers out of the auth cache (#51599) 2026-11-20 17:57:38 +09:00
test_access_group_rules.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_admin_viewer_handler_access.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_app_auth.py feat(proxy): add app groups with shared budgets and usage (#53232) 2026-11-21 12:50:58 -08:00
test_auth_checks.py feat(proxy): require customer headers by gateway, team, or key (#53045) 2026-11-21 20:20:26 +00:00
test_auth_checks_object_access_and_lookup.py fix(auth): retry a team read that loses its database connection and answer 503 when the database is down (#53260) 2026-11-21 12:18:19 -08:00
test_auth_exception_handler.py fix(auth): retry a team read that loses its database connection and answer 503 when the database is down (#53260) 2026-11-21 12:18:19 -08:00
test_auth_hot_path_network_requests.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_auth_object_prefetch.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_auth_utils.py feat(realtime)!: serve GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband (#53282) 2026-11-21 22:49:26 -08:00
test_authorization.py fix(proxy): share ownership permissions for spend logs and traces (#44239) 2026-10-03 01:38:54 +00:00
test_banned_params_extra_body.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_cli_auth.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_core.py refactor(proxy): move non-auth writers out of the auth cache (#51599) 2026-11-20 17:57:38 +09:00
test_custom_auth_end_user_budget.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_customer_hierarchy_auth.py fix(proxy): name configured customer headers in authorization errors (#53043) 2026-11-20 16:33:39 -08:00
test_customer_member_auto_create.py fix(proxy): register new customer org aliases one at a time per worker so a burst of first requests is served (#52080) 2026-11-16 14:00:04 -08:00
test_customer_provisioning.py feat(proxy): require customer headers by gateway, team, or key (#53045) 2026-11-21 20:20:26 +00:00
test_customer_spend.py fix(proxy): enforce settled customer budgets across workers (#51568) 2026-11-13 07:33:24 -08:00
test_default_end_user_budget_simple.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_denial.py fix(auth): check a mapped JWT's end-user claim and keep the error classes of refused keys and JWTs (#52397) 2026-11-18 03:36:46 +00:00
test_fallback_budget.py refactor(router): delete router code nothing calls (#52516) 2026-11-19 06:11:10 +09:00
test_fallback_model_access.py feat(customer-portal): complete hierarchy management (#51521) 2026-11-13 17:58:34 +00:00
test_fallback_rate_limit.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_fallback_rate_limit_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_impersonation.py feat(proxy)!: let every key read its own spend logs and return 403 for filters outside the caller's scope (#52449) 2026-11-19 03:14:35 +00:00
test_info_routes.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_jwt.py fix(proxy): accept audience and public_key_url in litellm_jwtauth (#53288) 2026-11-21 10:51:37 -08:00
test_legacy_empty_models_check.py Serialize legacy empty model boot counts (#52378) 2026-11-18 04:31:46 +00:00
test_litellm_license.py fix(proxy): stop logging license values during verification (#44956) 2026-10-06 17:05:07 -07:00
test_login_utils.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_master_key_boot_check.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_mcp_ip_filtering.py refactor(mcp): drop the experimental label from the MCP server and client paths (#48513) 2026-10-27 17:47:50 +00:00
test_model_access_group_budgets.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_model_checks.py chore(cost-map): fill Bedrock regional and Azure Government pricing gaps, rolling registry audit 2026-11-18 (#52458) 2026-11-18 07:02:05 -08:00
test_model_checks_fallbacks.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_models_fallback_endpoint.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_multi_budget_windows.py feat(proxy): support budget_limits windows on internal users (#51763) 2026-11-14 07:44:35 -05:00
test_multipart_bypass_repro.py ci: move tests/proxy_unit_tests to tests/unit/proxy and run the proxy-db shards from litellm-tests (#42903) 2026-09-24 22:59:11 +00:00
test_network.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_oauth2_proxy_hook.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_object_permission_loading.py refactor(auth-store): shape the cached virtual key in Rust and load it through one Python path (#53325) 2026-11-21 22:06:13 +09:00
test_onboarding.py feat(proxy): hash UI passwords with PBKDF2 in FIPS mode (#49874) 2026-11-06 01:31:59 -08:00
test_organization_budget_enforcement.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_password_hashing.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_password_policy.py feat(proxy): hash UI passwords with PBKDF2 in FIPS mode (#49874) 2026-11-06 01:31:59 -08:00
test_personal_key_team_model_access.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_proxy_routes.py refactor(proxy): expose public names for private proxy helpers (#45170) 2026-10-07 18:59:27 -07:00
test_rds_iam_token.py fix(proxy): preserve AWS session tokens for RDS IAM auth (#46559) 2026-10-15 22:51:39 +00:00
test_resolvers_exceptions.py fix(auth): return a generic 401 for an unknown key (#39787) 2026-10-15 01:05:25 -07:00
test_resolvers_grants.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_resolvers_models.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_resolvers_seam.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_resolvers_store.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_route_checks.py feat(proxy)!: let every key read its own spend logs and return 403 for filters outside the caller's scope (#52449) 2026-11-19 03:14:35 +00:00
test_router_override_fallback_auth.py refactor(proxy): expose public names for private proxy helpers (#45170) 2026-10-07 18:59:27 -07:00
test_scalar_budget_windows.py feat(db): rust repositories for user, end user and budget auth objects (#52170) 2026-11-18 22:32:05 +00:00
test_search_tool_deny_by_default.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_team_grants.py test(proxy): move auth, hooks, policy_engine and client tests into tests/unit/proxy (#43998) 2026-10-01 10:11:45 -07:00
test_team_member_budget.py feat(teams): show caller member spend and budget on Your Teams (#45674) 2026-10-24 17:09:55 -07:00
test_unmapped_model_budget_enforcement.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_user_api_key_auth.py fix(proxy): accept any case of the bearer scheme on realtime auth (#53259) 2026-11-21 16:32:32 -08:00
test_user_api_key_auth_deployment_profile.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_user_api_key_auth_request_flow.py fix(proxy): preserve OAuth query parameters on configured pass-through routes (#53379) 2026-11-21 16:28:31 -08:00
test_vector_store_access_groups.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00