fix(handle_jwt.py): enable user to set jwt admin scope string in config

This commit is contained in:
Krrish Dholakia 2024-03-25 11:34:49 -07:00
parent d2d6f6d0aa
commit d3e7376e10
2 changed files with 11 additions and 7 deletions

View file

@ -67,17 +67,21 @@ class JWTHandler:
self.http_handler = HTTPHandler()
def update_environment(
self, prisma_client: Optional[PrismaClient], user_api_key_cache: DualCache
self,
prisma_client: Optional[PrismaClient],
user_api_key_cache: DualCache,
litellm_proxy_roles: LiteLLMProxyRoles,
) -> None:
self.prisma_client = prisma_client
self.user_api_key_cache = user_api_key_cache
self.litellm_proxy_roles = litellm_proxy_roles
def is_jwt(self, token: str):
parts = token.split(".")
return len(parts) == 3
def is_admin(self, scopes: list) -> bool:
if LiteLLMProxyRoles.PROXY_ADMIN.value in scopes:
if self.litellm_proxy_roles.PROXY_ADMIN in scopes:
return True
return False