The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Allow routes for admin viewer
Jugal Bhatt89a115003333
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex cf8b3d147f0..de282553950 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -527,9 +527,20 @@ class LiteLLMRoutes(enum.Enum):"/organization/member_update",]+ # Routes accessible by Admin Viewer (read-only admin access)+ admin_viewer_routes = [+ "/user/list",+ "/user/available_users",+ "/user/available_roles",+ "/user/daily/activity",+ "/team/daily/activity",+ "/tag/daily/activity",+ "/tag/list",+ ] + info_routes+# All routes accesible by an Org Adminorg_admin_allowed_routes = (- org_admin_only_routes + management_routes + self_managed_routes+ org_admin_only_routes + management_routes + self_managed_routes + admin_viewer_routes)diff --git a/litellm/proxy/auth/route_checks.py b/litellm/proxy/auth/route_checks.pyindex f6b088d15a6..22e6bbffb38 100644--- a/litellm/proxy/auth/route_checks.py+++ b/litellm/proxy/auth/route_checks.py@@ -159,11 +159,12 @@ class RouteChecks:status_code=status.HTTP_403_FORBIDDEN,detail=f"user not allowed to access this OpenAI routes, role= {_user_role}",)++ # Check if this is a write operation on management routesif RouteChecks.check_route_access(route=route, allowed_routes=LiteLLMRoutes.management_routes.value):-- # the Admin Viewer is only allowed to call /user/update for their own user_id and can only update+ # For management routes, only allow read operations or specific allowed updatesif route == "/user/update":# Check the Request params are valid for PROXY_ADMIN_VIEW_ONLYif request_data is not None and isinstance(request_data, dict):@@ -174,17 +175,25 @@ class RouteChecks:status_code=status.HTTP_403_FORBIDDEN,detail=f"user not allowed to access this route, role= {_user_role}. Trying to access: {route} and updating invalid param: {param}. only user_email and password can be updated",)- else:+ elif route in ["/user/new", "/user/delete", "/team/new", "/team/update", "/team/delete", "/model/new", "/model/update", "/model/delete"]:+ # Block write operations for PROXY_ADMIN_VIEW_ONLYraise HTTPException(status_code=status.HTTP_403_FORBIDDEN,detail=f"user not allowed to access this route, role= {_user_role}. Trying to access: {route}",)+ # Allow read operations on management routes (like /user/info, /team/info, /model/info)+ pass+ elif RouteChecks.check_route_access(+ route=route, allowed_routes=LiteLLMRoutes.admin_viewer_routes.value+ ):+ # Allow access to admin viewer routes (read-only admin endpoints)+ passelse:+ # For other routes, block accessraise HTTPException(status_code=status.HTTP_403_FORBIDDEN,detail=f"user not allowed to access this route, role= {_user_role}. Trying to access: {route}",)-elif (_user_role == LitellmUserRoles.INTERNAL_USER.valueand RouteChecks.check_route_access(