mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
Whether a route may be called was decided by Python helpers spread over RouteChecks and the managed agent module: wildcard, prefix and deny matching, pass-through grants, and the managed agent route table. The Rust auth core needs the same rules, and a second copy would drift. The rules move into a new gateway-auth-core crate under routes/, and Python calls them through _native. RouteChecks and managed_authorization keep their function names and now delegate, so every existing caller is unchanged. The LiteLLMRoutes groups stay Python's and reach Rust through litellm/rust_bridge/host/route_groups.py. Route templates parse in a new litellm-starlette crate, which follows starlette's compile_path and never fails. A pass-through path with an int, float or uuid parameter used to panic the route group load and now matches one segment, as the Python matcher did. Both matchers share one walk over the template that keeps the set of offsets reached so far, so a template with many path parameters answers in polynomial time where trying every split, as Python's re does, never finishes. Route lists from key and team metadata, and JWT team_allowed_routes, read as litellm-config's RouteList, so a value that is not a list of strings answers with a 403 instead of failing the request: a malformed allow list grants nothing and a malformed deny list denies every pass-through route. The Rust route groups are rebuilt whenever LiteLLMRoutes changes, since an auth-enforced pass-through endpoint adds its path to openai_routes while the proxy runs. Reading config files and their include moves out of litellm-config into a new litellm-config-load crate, which leaves litellm-config the typed data model. How Python reads a config value it never validates now lives in one place, python-compat's lenient module: `value is True`, `bool(value)`, and a value of the expected shape or Malformed. Config types use them as serde_with adapters, so the gateway's YAML load and python-bridge's from_py read a value the same way. general_settings.pass_through_endpoints is typed with them, its path as a starlette RouteTemplate. The config types derive Debug, and veil's Redact where a field can carry a credential, in place of their hand-written impls. No change to which well-formed routes are allowed or denied is intended. |
||
|---|---|---|
| .. | ||
| routes | ||
| __init__.py | ||
| test_cache.py | ||
| test_callbacks_legacy_python.py | ||
| test_model_capabilities.py | ||
| test_model_cost.py | ||
| test_preflight.py | ||
| test_redis_credentials.py | ||
| test_redis_events.py | ||
| test_route_groups.py | ||
| test_secret_manager.py | ||
| test_settings.py | ||