Repository navigation
Conversation
|
Ishaan Jaff seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR completes the v0 virtual-key auth for the Rust ai-gateway by wiring the Python control plane's budget reservation into the Rust session lifecycle, closing the gap where realtime sessions previously bypassed optimistic budget tracking.
Confidence Score: 5/5The auth and budget-reservation changes are safe to merge; the end-to-end flow from Python reservation creation through Rust session metadata to logging reconciliation is complete and well-tested. All three concerns raised in the previous review round are directly addressed: internal URLs are stripped from upstream errors, 5xx auth failures propagate rather than masquerade as 401, and the O(n) lock-hold is moved off the hot path. The budget-reservation plumbing is the only structural addition and each link in the chain — auth response, RequestMetadata, StandardLoggingMetadata, log replay, cost callback — is covered by a targeted unit test. The No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/rust_control_plane_endpoints/auth_endpoints.py | New internal auth endpoint for the Rust data plane; correctly re-raises 5xx errors, uses constant-time comparison, and explicitly includes budget_reservation (excluded=True in model) in the response. |
| litellm/proxy/auth/user_api_key_auth.py | Adds optional request parameter to _reserve_budget_after_common_checks and a skip_budget_reservation state-flag guard; only one production call site, already updated. |
| litellm/proxy/rust_control_plane_endpoints/logging_endpoints.py | Replays finished logging payloads through LiteLLM's callback fan-out; correctly maps user_api_key_budget_reservation from payload metadata to litellm_params.metadata where the cost callback reconciles it. |
| litellm-rust/crates/ai-gateway/src/auth/user_api_key.rs | Auth extractor; /v1/realtime always bypasses the cache, auth results with budget_reservation are never cached, and upstream errors are logged server-side with a generic message to clients. |
| litellm-rust/crates/ai-gateway/src/auth/cache.rs | Bounded TTL cache; disabled by default (TTL=0). O(n) retain moved from the hot get path to insert, addressing the prior review comment. |
| litellm-rust/crates/ai-gateway/src/auth/client/python.rs | HTTP client for delegating verification to the Python control plane; uses err.without_url() to redact internal URLs before storing in AuthError::Upstream. |
| litellm-rust/crates/ai-gateway/src/routes/realtime/mod.rs | Switches realtime handler from RequireMasterKey to UserApiKeyAuth; request_metadata_for_auth correctly propagates budget_reservation into RequestMetadata for the logging path. |
| litellm-rust/crates/ai-gateway/src/integrations/types.rs | Adds user_api_key_budget_reservation: Option<Value> to both RequestMetadata and StandardLoggingMetadata with skip_serializing_if to keep the JSON clean when absent. |
| litellm-rust/crates/ai-gateway/src/realtime/streaming.rs | Propagates user_api_key_budget_reservation from RequestMetadata into the StandardLoggingMetadata emitted at session end. |
| tests/test_litellm/proxy/rust_control_plane_endpoints/test_auth_endpoints.py | Comprehensive unit tests covering data-plane key guard (500/401 paths), budget_reservation passthrough, 5xx propagation, and Bearer prefix de-duplication. |
Reviews (5): Last reviewed commit: "fix(proxy): reconcile rust realtime budg..." | Re-trigger Greptile
…; require route; Bearer-prefix the key
…sh auth/client docs
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 7 · PR risk: 0/10 |
…forward model to verify
…el + key cache by (route,model,key)
…model access (veria High)
…staging' into codex/rust-auth-control-plane # Conflicts: # litellm-rust/Cargo.lock # litellm-rust/Cargo.toml # litellm-rust/crates/ai-gateway/Cargo.toml # litellm-rust/crates/ai-gateway/src/routes/realtime/mod.rs # litellm/proxy/proxy_server.py
|
@veria-ai please re-review. Latest head
Checks run: |
|
Addressed the remaining Veria security issue in b9c3c2b: realtime auth verification now skips only optimistic budget reservation while preserving normal admission checks, so repeated WebSocket opens cannot pin shared budget counters before actual spend. @veria-ai please run a fresh review. |
|
Pushed one more CI-only fix on top: Codecov now ignores litellm-rust/** because this PR's Rust gateway diff is validated by rustfmt/clippy/test but does not have a matching Codecov upload.\n\nVaria, please review the latest head commit as well. |
|
Fixed the SERVER_ROOT_PATH workflow failure. It was not a route assertion failure: Playwright's was failing during apt update because the GitHub runner had Microsoft apt sources returning 403 ( and ).\n\nAdded a workflow step to disable only apt source files containing before installing Chromium deps. Latest pushed commit: 5996946. |
|
Clean note on the SERVER_ROOT_PATH failure: it was not a route assertion failure. Playwright's browser dependency install failed during apt update because the GitHub runner had Microsoft apt sources returning 403:
The pushed fix disables only apt source files containing packages.microsoft.com before running Playwright's Chromium dependency install. Latest pushed commit: 5996946. |
|
@greptileai @veria-ai please re-review latest head This addresses the remaining realtime budget issue by carrying the Python budget reservation into Rust session metadata and reconciling it through
Local checks run:
|
Pull request was closed
Relevant issues
v0 of virtual-key auth on the Rust ai-gateway. Today the gateway only checks the master key; this adds per-key auth by delegating to the Python control plane's existing
user_api_key_auth(key lookup, expiry, budget, rate-limit, route checks) — Rust holds no secrets and never touches the DB. Same control-plane/data-plane pattern as the logging endpoint in #31134.Pre-Submission checklist
cargo test -p litellm-ai-gateway --features server→ 22 passed, 1 ignored; clippy-D warnings+ fmt cleanpytest tests/test_litellm/proxy/auth/test_internal_auth_endpoints.py→ 9 passedType
🆕 New Feature
Changes
Python control plane — one gated endpoint:
POST /internal/v1/auth/verifyruns the realuser_api_key_authand returns the resolvedUserAPIKeyAuthJSON (or 401).require_data_plane_key: constant-time check ofX-LiteLLM-Data-Plane-KeyagainstLITELLM_DATA_PLANE_KEY— a dedicated secret, not the master key (least privilege). 500 if unset (fail closed), 401 if missing/wrong.Rust data plane (
ai-gateway/src/auth/), designed to swap to native later without touching routes:client/mod.rs—KeyAuthenticatortrait (the swap seam). v0 =client/python.rs(PythonAuthClient, pooled rustls reqwest, bounded timeouts). Later = a native impl, drop-in.user_api_key.rs—UserApiKeyAuthstruct (mirrors Python) + the axumFromRequestPartsextractor = the route "decorator". Flow: Bearer → master key short-circuits to admin (constant-time, no Python call) → elsesha256(key)→ cache hit → miss verifies via the trait and caches.cache.rs—KeyCache: bounded ≤200 entries (FIFO evict) + TTL (60s,LITELLM_AUTH_CACHE_TTL_SECS), keyed bysha256so plaintext keys never sit in memory.AppState(authenticator: Arc<dyn KeyAuthenticator>,key_cache);main.rsbuilds it fromLITELLM_DATA_PLANE_KEY+LITELLM_AUTH_VERIFY_URL. The realtime WS route now usesauth: UserApiKeyAuth(auth runs on the upgrade, before the socket).Fail-closed throughout; raw keys never logged (only
sha256/alias). All auth lives inlitellm-ai-gateway(host) behind theserverfeature —litellm-corestays pure and the python-bridge cdylib is unaffected.