feat(ui_sso.py): Allows users to use test key pane, and have team budget limits be enforced for their use-case (#7666)

This commit is contained in:
Krish Dholakia 2025-01-09 22:12:45 -08:00 committed by GitHub
parent 6df8faf15f
commit 63926f484c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 2 deletions

View file

@ -204,6 +204,9 @@ from litellm.proxy.management_endpoints.team_callback_endpoints import (
)
from litellm.proxy.management_endpoints.team_endpoints import router as team_router
from litellm.proxy.management_endpoints.team_endpoints import update_team
from litellm.proxy.management_endpoints.ui_sso import (
get_disabled_non_admin_personal_key_creation,
)
from litellm.proxy.management_endpoints.ui_sso import router as ui_sso_router
from litellm.proxy.management_helpers.audit_logs import create_audit_log_for_update
from litellm.proxy.openai_files_endpoints.files_endpoints import (
@ -7295,6 +7298,9 @@ async def login(request: Request): # noqa: PLR0915
_user_row = await prisma_client.db.litellm_usertable.find_first(
where={"user_email": {"equals": username}}
)
disabled_non_admin_personal_key_creation = (
get_disabled_non_admin_personal_key_creation()
)
"""
To login to Admin UI, we support the following
- Login with UI_USERNAME and UI_PASSWORD
@ -7366,6 +7372,7 @@ async def login(request: Request): # noqa: PLR0915
"auth_header_name": general_settings.get(
"litellm_key_header_name", "Authorization"
),
"disabled_non_admin_personal_key_creation": disabled_non_admin_personal_key_creation,
},
master_key,
algorithm="HS256",
@ -7433,6 +7440,7 @@ async def login(request: Request): # noqa: PLR0915
"auth_header_name": general_settings.get(
"litellm_key_header_name", "Authorization"
),
"disabled_non_admin_personal_key_creation": disabled_non_admin_personal_key_creation,
},
master_key,
algorithm="HS256",
@ -7547,6 +7555,10 @@ async def onboarding(invite_link: str):
litellm_dashboard_ui += "/ui/onboarding"
import jwt
disabled_non_admin_personal_key_creation = (
get_disabled_non_admin_personal_key_creation()
)
jwt_token = jwt.encode( # type: ignore
{
"user_id": user_obj.user_id,
@ -7558,6 +7570,7 @@ async def onboarding(invite_link: str):
"auth_header_name": general_settings.get(
"litellm_key_header_name", "Authorization"
),
"disabled_non_admin_personal_key_creation": disabled_non_admin_personal_key_creation,
},
master_key,
algorithm="HS256",