mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix _return_user_api_key_auth_obj (#7591)
This commit is contained in:
parent
61d67cfa43
commit
0b5c1392f7
2 changed files with 17 additions and 12 deletions
|
@ -732,7 +732,7 @@ async def user_api_key_auth( # noqa: PLR0915
|
|||
)
|
||||
|
||||
if is_master_key_valid:
|
||||
_user_api_key_obj = _return_user_api_key_auth_obj(
|
||||
_user_api_key_obj = await _return_user_api_key_auth_obj(
|
||||
user_obj=None,
|
||||
user_role=LitellmUserRoles.PROXY_ADMIN,
|
||||
api_key=master_key,
|
||||
|
@ -1177,7 +1177,7 @@ async def user_api_key_auth( # noqa: PLR0915
|
|||
# No token was found when looking up in the DB
|
||||
raise Exception("Invalid proxy server token passed")
|
||||
if valid_token_dict is not None:
|
||||
return _return_user_api_key_auth_obj(
|
||||
return await _return_user_api_key_auth_obj(
|
||||
user_obj=user_obj,
|
||||
api_key=api_key,
|
||||
parent_otel_span=parent_otel_span,
|
||||
|
@ -1240,7 +1240,7 @@ async def user_api_key_auth( # noqa: PLR0915
|
|||
)
|
||||
|
||||
|
||||
def _return_user_api_key_auth_obj(
|
||||
async def _return_user_api_key_auth_obj(
|
||||
user_obj: Optional[LiteLLM_UserTable],
|
||||
api_key: str,
|
||||
parent_otel_span: Optional[Span],
|
||||
|
@ -1250,14 +1250,18 @@ def _return_user_api_key_auth_obj(
|
|||
user_role: Optional[LitellmUserRoles] = None,
|
||||
) -> UserAPIKeyAuth:
|
||||
end_time = datetime.now()
|
||||
user_api_key_service_logger_obj.service_success_hook(
|
||||
service=ServiceTypes.AUTH,
|
||||
call_type=route,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
duration=end_time.timestamp() - start_time.timestamp(),
|
||||
parent_otel_span=parent_otel_span,
|
||||
|
||||
asyncio.create_task(
|
||||
user_api_key_service_logger_obj.async_service_success_hook(
|
||||
service=ServiceTypes.AUTH,
|
||||
call_type=route,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
duration=end_time.timestamp() - start_time.timestamp(),
|
||||
parent_otel_span=parent_otel_span,
|
||||
)
|
||||
)
|
||||
|
||||
retrieved_user_role = (
|
||||
user_role or _get_user_role(user_obj=user_obj) or LitellmUserRoles.INTERNAL_USER
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue