mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
(fix) proxy check expires time
This commit is contained in:
parent
92093dd45a
commit
87ff4ca55c
2 changed files with 12 additions and 1 deletions
|
@ -355,8 +355,17 @@ async def user_api_key_auth(
|
||||||
|
|
||||||
# Check 3. If token is expired
|
# Check 3. If token is expired
|
||||||
if valid_token.expires is not None:
|
if valid_token.expires is not None:
|
||||||
|
current_time = datetime.now(timezone.utc)
|
||||||
expiry_time = datetime.fromisoformat(valid_token.expires)
|
expiry_time = datetime.fromisoformat(valid_token.expires)
|
||||||
if expiry_time < datetime.utcnow():
|
if (
|
||||||
|
expiry_time.tzinfo is None
|
||||||
|
or expiry_time.tzinfo.utcoffset(expiry_time) is None
|
||||||
|
):
|
||||||
|
expiry_time = expiry_time.replace(tzinfo=timezone.utc)
|
||||||
|
verbose_proxy_logger.debug(
|
||||||
|
f"Checking if token expired, expiry time {expiry_time} and current time {current_time}"
|
||||||
|
)
|
||||||
|
if expiry_time < current_time:
|
||||||
# Token exists but is expired.
|
# Token exists but is expired.
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
|
|
@ -374,6 +374,8 @@ class PrismaClient:
|
||||||
)
|
)
|
||||||
print_verbose(f"PrismaClient: response={response}")
|
print_verbose(f"PrismaClient: response={response}")
|
||||||
if response is not None:
|
if response is not None:
|
||||||
|
# for prisma we need to cast the expires time to str
|
||||||
|
response.expires = response.expires.isoformat()
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
# Token does not exist.
|
# Token does not exist.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue