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
fix(proxy_server.py): add 'admin' user to db (#6223)
Krish Dholakia199896f91289
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 6f5ecbc6545..163d2ff25d5 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -2935,21 +2935,21 @@ async def startup_event(): # noqa: PLR0915verbose_proxy_logger.info("Skipping writing master key hash to db")else:# add master key to db- asyncio.create_task(- generate_key_helper_fn(- request_type="user",- duration=None,- models=[],- aliases={},- config={},- spend=0,- token=master_key,- user_id=litellm_proxy_admin_name,- user_role=LitellmUserRoles.PROXY_ADMIN,- query_type="update_data",- update_key_values={"user_role": LitellmUserRoles.PROXY_ADMIN},- )+ # add 'admin' user to db. Fixes https://github.com/BerriAI/litellm/issues/6206+ task_1 = generate_key_helper_fn(+ request_type="user",+ duration=None,+ models=[],+ aliases={},+ config={},+ spend=0,+ token=master_key,+ user_id=litellm_proxy_admin_name,+ user_role=LitellmUserRoles.PROXY_ADMIN,+ query_type="update_data",+ update_key_values={"user_role": LitellmUserRoles.PROXY_ADMIN},)+ asyncio.create_task(task_1)if prisma_client is not None and litellm.max_budget > 0:if litellm.budget_duration is None:@@ -8107,16 +8107,16 @@ async def login(request: Request): # noqa: PLR0915):# Non SSO -> If user is using UI_USERNAME and UI_PASSWORD they are Proxy adminuser_role = LitellmUserRoles.PROXY_ADMIN- user_id = username+ user_id = litellm_proxy_admin_name# we want the key created to have PROXY_ADMIN_PERMISSIONSkey_user_id = litellm_proxy_admin_nameif (os.getenv("PROXY_ADMIN_ID", None) is not Noneand os.environ["PROXY_ADMIN_ID"] == user_id- ) or user_id == "admin":+ ) or user_id == litellm_proxy_admin_name:# checks if user is admin- key_user_id = os.getenv("PROXY_ADMIN_ID", "default_user_id")+ key_user_id = os.getenv("PROXY_ADMIN_ID", litellm_proxy_admin_name)# Admin is Authe'd in - generate key for the UI to access Proxy@@ -8161,7 +8161,7 @@ async def login(request: Request): # noqa: PLR0915{"user_id": user_id,"key": key,- "user_email": user_id,+ "user_email": None,"user_role": user_role, # this is the path without sso - we can assume only admins will use this"login_method": "username_password","premium_user": premium_user,diff --git a/ui/litellm-dashboard/src/components/navbar.tsx b/ui/litellm-dashboard/src/components/navbar.tsxindex beeb5fb70c8..9e6a9f0ebe6 100644--- a/ui/litellm-dashboard/src/components/navbar.tsx+++ b/ui/litellm-dashboard/src/components/navbar.tsx@@ -128,7 +128,7 @@ const Navbar: React.FC<NavbarProps> = ({}}><Dropdown menu={{ items }}>- <Space>{userEmail}</Space>+ <Space>{userEmail ? userEmail : userRole}</Space></Dropdown></div></div>