From 7d244ca7102125390eeffe92c59c0615490c1312 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Wed, 31 Jan 2024 18:13:00 -0800 Subject: [PATCH] (feat) proxy use jwts for UI --- litellm/proxy/proxy_server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 2ddab15a850..76ce89d101d 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -3143,7 +3143,7 @@ async def auth_callback(request: Request): user_id = getattr(result, "first_name", "") + getattr(result, "last_name", "") response = await generate_key_helper_fn( - **{"duration": "24hr", "models": [], "aliases": {}, "config": {}, "spend": 0, "user_id": user_id, "team_id": "litellm-dashboard"} # type: ignore + **{"duration": "1hr", "models": [], "aliases": {}, "config": {}, "spend": 0, "user_id": user_id, "team_id": "litellm-dashboard"} # type: ignore ) key = response["token"] # type: ignore @@ -3163,11 +3163,16 @@ async def auth_callback(request: Request): else: proxy_base_url += "/ui" litellm_dashboard_ui = proxy_base_url + import jwt + + jwt_token = jwt.encode( + {"user_id": user_id, "key": key}, "secret", algorithm="HS256" + ) litellm_dashboard_ui += ( "?userID=" + user_id - + "&accessToken=" - + key + + "&token=" + + jwt_token + "&proxyBaseUrl=" + os.getenv("PROXY_BASE_URL") )