refactor: consolidate route auth for UI and API tokens#25473
refactor: consolidate route auth for UI and API tokens#25473yuneng-berri merged 2 commits intomainfrom
Conversation
Unify UI and API token authorization through the shared RBAC path and backfill missing routes in role-based route lists.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| "ui" if token_team is not None and token_team == "litellm-dashboard" else "api" | ||
| ) | ||
| _is_route_allowed = _is_allowed_route( | ||
| _is_route_allowed = _is_api_route_allowed( |
Greptile SummaryThis PR eliminates an RBAC bypass in the proxy's route authorization layer: previously, any token with Confidence Score: 5/5Safe to merge — fixes a real RBAC bypass with no regressions introduced; backward-compat concern from prior review is addressed. All changed files have passing unit tests. Previous P1 concern (deletion of No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_checks.py | Removes _is_allowed_route/_is_ui_route UI bypass; all tokens now go through _is_api_route_allowed RBAC. Minor: _is_route_allowed result is assigned but never checked (pre-existing pattern). |
| litellm/proxy/_types.py | Route lists updated: new routes backfilled to info_routes, spend_tracking_routes, global_spend_tracking_routes, internal_user_routes, admin_viewer_routes. ui_routes retained with backward-compat comment. Black reformatting of multi-line defaults. |
| tests/proxy_unit_tests/test_user_api_key_auth.py | New test_ui_token_route_access parametrize adds explicit coverage for the security fix; test_is_allowed_route updated to match renamed function. Coverage improved, not weakened. |
| tests/proxy_unit_tests/test_jwt.py | test_allowed_routes_admin still parametrizes with ["ui_routes"], validating that the retained enum member continues to work in JWT admin_allowed_routes configs. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph BEFORE["BEFORE this PR"]
A[Request with dashboard token] --> B{Route in ui_routes?}
B -->|Yes - prefix match| C[Allow regardless of role]
B -->|No| D[RBAC check]
end
subgraph AFTER["AFTER this PR"]
E[All tokens] --> F[_is_api_route_allowed]
F --> G{Proxy admin?}
G -->|Yes| H[Allow all routes]
G -->|No| I[non_proxy_admin_allowed_routes_check]
I --> J{Role}
J -->|INTERNAL_USER| K[internal_user_routes]
J -->|INTERNAL_USER_VIEW_ONLY| L[internal_user_view_only_routes]
J -->|PROXY_ADMIN_VIEW_ONLY| M[admin_viewer_routes]
K --> N[Allow or 403]
L --> N
M --> N
end
style C fill:#f66,color:#fff
style H fill:#6b6,color:#fff
style N fill:#6b6,color:#fff
Reviews (2): Last reviewed commit: "retain ui_routes enum alias for JWT conf..." | Re-trigger Greptile
Summary
Test plan
test_user_api_key_auth.py,test_jwt.py)