Skip to content

Commit

Permalink
Litellm dev 01 08 2025 p1 (#7640)
Browse files Browse the repository at this point in the history
* feat(ui_sso.py): support reading team ids from sso token

* feat(ui_sso.py): working upsert sso user teams membership in litellm - if team exists

Adds user to relevant teams, if user is part of teams and team exists on litellm

* fix(ui_sso.py): safely handle add team member task

* build(ui/): support setting team id when creating team on UI

* build(ui/): teams.tsx

allow setting team id on ui

* build(circle_ci/requirements.txt): add fastapi-sso to ci/cd testing

* fix: fix linting errors
  • Loading branch information
krrishdholakia authored Jan 9, 2025
1 parent 1e3370f commit 907bcd3
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 120 deletions.
1 change: 1 addition & 0 deletions .circleci/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ anthropic
orjson==3.9.15
pydantic==2.7.1
google-cloud-aiplatform==1.43.0
fastapi-sso==0.10.0
2 changes: 1 addition & 1 deletion litellm/proxy/_new_secret_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ model_list:
custom_tokenizer:
identifier: deepseek-ai/DeepSeek-V3-Base
revision: main
auth_token: os.environ/HUGGINGFACE_API_KEY
auth_token: os.environ/HUGGINGFACE_API_KEY
2 changes: 2 additions & 0 deletions litellm/proxy/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ class LiteLLM_JWTAuth(LiteLLMPydanticObjectBase):
"info_routes",
]
team_id_jwt_field: Optional[str] = None
team_ids_jwt_field: Optional[str] = None
upsert_sso_user_to_team: bool = False
team_allowed_routes: List[
Literal["openai_routes", "info_routes", "management_routes"]
] = ["openai_routes", "info_routes"]
Expand Down
7 changes: 6 additions & 1 deletion litellm/proxy/auth/handle_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import json
import os
from typing import Optional, cast
from typing import List, Optional, cast

from cryptography import x509
from cryptography.hazmat.backends import default_backend
Expand Down Expand Up @@ -59,6 +59,11 @@ def is_admin(self, scopes: list) -> bool:
return True
return False

def get_team_ids_from_jwt(self, token: dict) -> List[str]:
if self.litellm_jwtauth.team_ids_jwt_field is not None:
return token[self.litellm_jwtauth.team_ids_jwt_field]
return []

def get_end_user_id(
self, token: dict, default_value: Optional[str]
) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion litellm/proxy/management_endpoints/team_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ async def update_team(

if existing_team_row is None:
raise HTTPException(
status_code=404,
status_code=400,
detail={"error": f"Team not found, passed team_id={data.team_id}"},
)

Expand Down
13 changes: 13 additions & 0 deletions litellm/proxy/management_endpoints/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Types for the management endpoints
Might include fastapi/proxy requirements.txt related imports
"""

from typing import List

from fastapi_sso.sso.base import OpenID


class CustomOpenID(OpenID):
team_ids: List[str]
Loading

0 comments on commit 907bcd3

Please sign in to comment.