litellm/tests/unit/rust_bridge/host
yujonglee 4aa00352bb
refactor(auth): decide route rules in Rust (#51531)
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.
2026-11-16 18:55:32 +09:00
..
routes feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
__init__.py refactor(rust_bridge): route Python state reads through host modules (#45689) 2026-10-11 14:10:16 -07:00
test_cache.py feat(messages): serve azure ai foundry messages on rust only (#51721) 2026-11-14 13:40:38 -08:00
test_callbacks_legacy_python.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_model_capabilities.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_model_cost.py fix(cost): keep a deployment's per-second video price over the catalog row's flat price (#51688) 2026-11-15 12:04:41 -08:00
test_preflight.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_redis_credentials.py feat(redis): extend the native Redis foundation for the store families (#50169) 2026-11-06 12:30:07 +09:00
test_redis_events.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_route_groups.py refactor(auth): decide route rules in Rust (#51531) 2026-11-16 18:55:32 +09:00
test_secret_manager.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_settings.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00