From ccbc7cfb9f36a2e4911355cb070242709d87b09b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 16 Jul 2024 21:16:34 -0700 Subject: [PATCH] fix(team_endpoints.py): check if key belongs to team before returning /team/info --- litellm/proxy/_experimental/out/404.html | 1 - litellm/proxy/_experimental/out/model_hub.html | 1 - litellm/proxy/_experimental/out/onboarding.html | 1 - litellm/proxy/auth/handle_jwt.py | 14 ++++++++------ .../proxy/management_endpoints/team_endpoints.py | 7 +++++++ 5 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 litellm/proxy/_experimental/out/404.html delete mode 100644 litellm/proxy/_experimental/out/model_hub.html delete mode 100644 litellm/proxy/_experimental/out/onboarding.html diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html deleted file mode 100644 index 0d07f61c56..0000000000 --- a/litellm/proxy/_experimental/out/404.html +++ /dev/null @@ -1 +0,0 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/model_hub.html b/litellm/proxy/_experimental/out/model_hub.html deleted file mode 100644 index 49ce1f2cff..0000000000 --- a/litellm/proxy/_experimental/out/model_hub.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html deleted file mode 100644 index bec1f6b605..0000000000 --- a/litellm/proxy/_experimental/out/onboarding.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/auth/handle_jwt.py b/litellm/proxy/auth/handle_jwt.py index e02bb1e8aa..200df7317f 100644 --- a/litellm/proxy/auth/handle_jwt.py +++ b/litellm/proxy/auth/handle_jwt.py @@ -6,19 +6,21 @@ Currently only supports admin. JWT token must have 'litellm_proxy_admin' in scope. """ -import jwt import json import os -from litellm.caching import DualCache -from litellm._logging import verbose_proxy_logger -from litellm.proxy._types import LiteLLM_JWTAuth, LiteLLM_UserTable -from litellm.proxy.utils import PrismaClient -from litellm.llms.custom_httpx.httpx_handler import HTTPHandler from typing import Optional + +import jwt from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization +from litellm._logging import verbose_proxy_logger +from litellm.caching import DualCache +from litellm.llms.custom_httpx.httpx_handler import HTTPHandler +from litellm.proxy._types import LiteLLM_JWTAuth, LiteLLM_UserTable +from litellm.proxy.utils import PrismaClient + class JWTHandler: """ diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index 6be8310e8f..b85ddb6ca0 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -713,6 +713,7 @@ async def team_info( team_id: str = fastapi.Query( default=None, description="Team ID in the request parameters" ), + user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth), ): """ get info on team + related keys @@ -747,6 +748,12 @@ async def team_info( detail={"message": "Malformed request. No team id passed in."}, ) + if user_api_key_dict.team_id or (team_id != user_api_key_dict.team_id): + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="key not allowed to access this team's info", + ) + team_info = await prisma_client.get_data( team_id=team_id, table_name="team", query_type="find_unique" )