mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-24 00:28:32 +00:00
[Fix] Restrict /global/spend/* routes to admin roles
The routes in `global_spend_tracking_routes` (e.g. /global/spend/report, /global/spend/teams, /global/spend/keys) return spend aggregated across every team, customer, and api_key in the proxy. They were included in `internal_user_routes` and `internal_user_view_only_routes`, so non-admin roles could read proxy-wide spend. Drop them from both non-admin route lists. PROXY_ADMIN and PROXY_ADMIN_VIEW_ONLY access is preserved through their existing branches in route_checks.py, and the `get_spend_routes` permission opt-in continues to grant access for keys that need it. Updates two pre-existing test parametrizations whose expected results flip from True to False, and adds parametrized coverage over every route in `global_spend_tracking_routes` for: PROXY_ADMIN_VIEW_ONLY allowed, INTERNAL_USER blocked, INTERNAL_USER_VIEW_ONLY blocked, INTERNAL_USER + get_spend_routes permission allowed.
This commit is contained in:
@@ -459,7 +459,8 @@ async def test_org_admin_create_user_team_wrong_org_permissions(prisma_client):
|
||||
("/key/generate", LitellmUserRoles.PROXY_ADMIN, True),
|
||||
("/key/regenerate", LitellmUserRoles.PROXY_ADMIN, True),
|
||||
# # Internal User checks - allowed routes
|
||||
("/global/spend/logs", LitellmUserRoles.INTERNAL_USER, True),
|
||||
# /global/spend/logs returns proxy-wide spend; non-admin roles must be blocked
|
||||
("/global/spend/logs", LitellmUserRoles.INTERNAL_USER, False),
|
||||
("/key/delete", LitellmUserRoles.INTERNAL_USER, True),
|
||||
("/key/generate", LitellmUserRoles.INTERNAL_USER, True),
|
||||
("/key/82akk800000000jjsk/regenerate", LitellmUserRoles.INTERNAL_USER, True),
|
||||
|
||||
Reference in New Issue
Block a user