mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(auth): check a mapped JWT's end-user claim and keep the typed unknown-key error Two regressions from moving key and JWT auth into gateway-auth-core, both failing tests/integration/authorization on main. A JWT mapped to a virtual key carried its end-user claim beside the key, in MappedJwt, while the key path read the end user from KeyRecord.end_user_id. That field came from the stored key row, which never names an end user, so the key path validated, read and budget-checked the request body's end user, and an over-budget body user refused a request the claim should have decided. Credential::Resolved now carries the end user the JWT names, the key path reads it before the request's, and KeyRecord.end_user_id is gone. An unknown virtual key came back from the core as a plain ProxyException, so the failure spend row recorded error_class ProxyException and the auth failure log line lost "key=<hash>, not found in db". KeyDenial::NotFound now carries the hash the host looked up and renders as PublicDenial::KeyNotFound, which Python constructs as KeyNotFoundError. The team header integration test asserted Python's list repr in the 403 message. The core formats lists as JSON by design, so the test now reads the allowed team ids as JSON. * fix(auth): keep the JWT error classes failure rows record and test path handoffs at the entry point An unknown signing key and an ID-JAG sent as a bearer token were raised as NoMatchingJWTPublicKeyError and IdJagIsNotABearerTokenError before the core moved to Rust, and as a bare Exception after it, so the failure spend row's error_class lost the name. Each is its own PublicDenial variant again. test_denial.py now pins the exact class of every RustDenial variant and fails when a variant has none. lib.rs gains entry-point tests for a JWT that continues on the key path: a linked existing key reads the claim's end user, and a blocked mapped key is refused with that key. AGENTS.md records the three rules behind these fixes. * test(auth): pin auth outcomes for a production-shaped JWT deployment 86 requests run through user_api_key_auth against settings shaped like a production install: teams from a JWT roles claim, users created on first sight, team-based model access, a team route allowlist, pass-through endpoints registered with auth, a master key, virtual keys, and requests let through a database outage. A second JWT configuration maps a client claim to a virtual key and names the end user by a claim. Each case pins who the request is served as or how it is refused: the user, team and end user on the token, the status, type and opening of the error, the exception class the failure spend row records, and the users and team members auth wrote. Every expected value was observed on the commit before key and JWT auth moved to gateway-auth-core, where the same requests gave the same outcomes apart from message wording. Putting either of the two regressions back fails this file: the unknown-key case when the typed error is lost, and three mapped-JWT cases when the end-user claim does not reach the key path. * test(auth): build the profile test's empty tables in one expression * fix(auth): select a JWT team for pass-through subpaths and report a failed team read as an outage Two bugs that predate the Rust auth core and that the production-shaped profile test surfaced. A JWT caller whose team grants a pass-through endpoint registered with include_subpath was refused on every path under it, unless the user's own row listed exactly one team. Team selection asked whether team_allowed_routes lists the route, and a subpath is only listed inside the openai_routes group as "path/*", which a group entry never matches as a wildcard. Selection now asks whether the team may use the route, which is true for every auth pass-through route, and leaves the decision to the team's own grants, as the header, RBAC and database fallback sources already did. A database outage during a JWT team read was reported as 403 "No team has access to the requested model". get_team_object turns every failure into a 404 HTTPException, so the host answered Unreadable, and the core dropped any failure it did get. get_team_object now keeps the original error as the cause, the JWT host re-raises it when it is a database connection error, and team selection ends with that host failure. The request then gets the fallback identity under allow_requests_on_db_unavailable, or the 503. A team the host fails to read now ends the selection even when team_claim_fallback is on or a later team would qualify. * test(auth): cut auth tests that kill no mutant and simplify the claimed team read The deployment profile test goes from 87 cases to 12. Line coverage showed 36 cases ran no proxy line the rest of tests/unit/proxy/auth misses, and the others reached the same few host answers, so one case per answer stays. check_team now reads the team with ?, like every other team read in the file. The guard it replaces left a mutant no test could kill, since a host only fails a read as HostFailed. Core and host tests that repeated another test's assertion are removed, and two cases cover mutants that survived next to the changed key path code. * test(auth): cover the claimed team and entry point mutants left in the touched files A singular team claim is a team the header may name and wins over an alias claim, a delegated agent is scoped to the teams its token names, and the two public entry points that only delegate to the planner are now called from a test. cargo mutants over the 8 changed core files now reports 114 caught and none missed. * test(auth): drop the wall-clock expiry from the refused JWT class test Both refusals happen before the expiry is read, so the token needs no exp claim. * test(auth): mark the new entry point tests with rstest and name helpers over commenting them * refactor(auth): return a failed team read with its real error and read it in the JWT host get_team_object reports every database failure as a 404, so the JWT host had to recover an outage from the exception's cause. read_team now holds the read and returns a failed one as a value, get_team_object keeps its 404 on top of it for its other callers, and the host decides from the real error. * test(mcp): stub the team reader the JWT host now calls |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _guardrail_opt_out.py | ||
| _hidden_alias_budget.py | ||
| _responses_compact.py | ||
| test_access_group_budget.py | ||
| test_access_group_model_listing.py | ||
| test_access_group_rules.py | ||
| test_agent_access.py | ||
| test_agent_denial_logging.py | ||
| test_agent_least_privilege.py | ||
| test_alias_chain_budget_waiver.py | ||
| test_audio_model_access.py | ||
| test_audit_any_sweep_auth.py | ||
| test_auth_object_prefetch.py | ||
| test_bedrock_passthrough_model_access.py | ||
| test_claude_code_gateway_oauth.py | ||
| test_cli_sso_login_ui_disabled.py | ||
| test_customer_model_allowlist.py | ||
| test_customer_org_alias_first_request_burst.py | ||
| test_customer_org_alias_key_scope.py | ||
| test_deprecated_key_lookup_cache.py | ||
| test_end_user_block.py | ||
| test_guardrail_submissions.py | ||
| test_hidden_alias_budget_bypass.py | ||
| test_hidden_alias_budget_bypass_chaos.py | ||
| test_jwt_auto_register_map_existing_key.py | ||
| test_jwt_default_team_provisioning.py | ||
| test_jwt_key_mapping_lifecycle.py | ||
| test_jwt_mapped_key_email_backfill.py | ||
| test_key_alias_model_access.py | ||
| test_key_bound_to_unknown_user.py | ||
| test_key_budget_owner_updates.py | ||
| test_key_guardrail_opt_out.py | ||
| test_key_guardrail_opt_out_chaos.py | ||
| test_key_guardrail_opt_out_runtime.py | ||
| test_lakera_v2_on_flagged.py | ||
| test_legacy_empty_models_boot_warning.py | ||
| test_litellm_http_client_sso_real_io.py | ||
| test_master_key_boot_check_real_io.py | ||
| test_memory_ownership.py | ||
| test_model_access_allow_lists.py | ||
| test_object_permission_lookup.py | ||
| test_passthrough_route_denylist.py | ||
| test_rag_query_vector_store_allowlist.py | ||
| test_rag_team_provider_credentials.py | ||
| test_realtime_client_secret_access.py | ||
| test_reject_before_body.py | ||
| test_responses_compact_id_ownership.py | ||
| test_responses_compact_id_ownership_chaos.py | ||
| test_responses_id_ownership.py | ||
| test_responses_lifecycle_during_call_guardrail.py | ||
| test_search_tool_allowlist.py | ||
| test_search_tool_deny_by_default.py | ||
| test_sso_blank_identity.py | ||
| test_team_admin_gate.py | ||
| test_team_member_permissions.py | ||
| test_team_scoped_models.py | ||
| test_tool_search_replay_allowlist.py | ||
| test_tool_search_replay_guardrails.py | ||
| test_unknown_key_generic_401.py | ||
| test_user_api_key_auth_request_flow_real_io.py | ||
| test_user_self_update_guard.py | ||
| test_warmed_policy.py | ||
| test_websocket_rejection_logging.py | ||
| test_wildcard_model_access.py | ||
| test_workflow_ownership.py | ||