Merge pull request #4479 from BerriAI/litellm_fix_admin_ui_login_issue

[Fix] Admin UI - fix error users we're seeing when logging in (use correct  user_id  when creating key for admin ui)
This commit is contained in:
Ishaan Jaff 2024-06-29 20:00:45 -07:00 committed by GitHub
commit 4910029eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7511,7 +7511,9 @@ async def login(request: Request):
# Non SSO -> If user is using UI_USERNAME and UI_PASSWORD they are Proxy admin # Non SSO -> If user is using UI_USERNAME and UI_PASSWORD they are Proxy admin
user_role = LitellmUserRoles.PROXY_ADMIN user_role = LitellmUserRoles.PROXY_ADMIN
user_id = username user_id = username
key_user_id = user_id
# we want the key created to have PROXY_ADMIN_PERMISSIONS
key_user_id = litellm_proxy_admin_name
if ( if (
os.getenv("PROXY_ADMIN_ID", None) is not None os.getenv("PROXY_ADMIN_ID", None) is not None
and os.environ["PROXY_ADMIN_ID"] == user_id and os.environ["PROXY_ADMIN_ID"] == user_id
@ -7531,7 +7533,17 @@ async def login(request: Request):
if os.getenv("DATABASE_URL") is not None: if os.getenv("DATABASE_URL") is not None:
response = await generate_key_helper_fn( response = await generate_key_helper_fn(
request_type="key", request_type="key",
**{"user_role": LitellmUserRoles.PROXY_ADMIN, "duration": "2hr", "key_max_budget": 5, "models": [], "aliases": {}, "config": {}, "spend": 0, "user_id": key_user_id, "team_id": "litellm-dashboard"}, # type: ignore **{
"user_role": LitellmUserRoles.PROXY_ADMIN,
"duration": "2hr",
"key_max_budget": 5,
"models": [],
"aliases": {},
"config": {},
"spend": 0,
"user_id": key_user_id,
"team_id": "litellm-dashboard",
}, # type: ignore
) )
else: else:
raise ProxyException( raise ProxyException(