From b93a355b051f3f721db23e8ff59908366fa933d3 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 1 Feb 2024 13:37:14 -0800 Subject: [PATCH] (fix) user_custom_auth --- litellm/proxy/proxy_server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index df4dec756..e10a2f3d3 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -252,12 +252,13 @@ async def user_api_key_auth( ) -> UserAPIKeyAuth: global master_key, prisma_client, llm_model_list, user_custom_auth, custom_db_client try: - if isinstance(api_key, str): - api_key = _get_bearer_token(api_key=api_key) - ### USER-DEFINED AUTH FUNCTION ### + ### USER-DEFINED AUTH FUNCTION -> This should always be run first if a user has defined it ### if user_custom_auth is not None: response = await user_custom_auth(request=request, api_key=api_key) return UserAPIKeyAuth.model_validate(response) + + if isinstance(api_key, str): + api_key = _get_bearer_token(api_key=api_key) ### LITELLM-DEFINED AUTH FUNCTION ### if master_key is None: if isinstance(api_key, str):