feat: handling for expired token
Returns a 401 with "Token expired" as the detail
This commit is contained in:
parent
34413b3fc5
commit
6871fcd75d
1 changed files with 5 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ import requests
|
|||
|
||||
from typing import Annotated, Any
|
||||
from joserfc import jwt
|
||||
from joserfc.errors import ExpiredTokenError
|
||||
from joserfc.jwk import KeySet
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
|
@ -46,7 +47,10 @@ async def get_current_user(oidc_auth_string: oidc_dependency) -> dict[str, Any]:
|
|||
|
||||
claims_requests = jwt.JWTClaimsRegistry(**claims_options)
|
||||
|
||||
claims_requests.validate(token.claims)
|
||||
try:
|
||||
claims_requests.validate(token.claims)
|
||||
except ExpiredTokenError as e:
|
||||
raise HTTPException(status_code=401, detail="Token expired")
|
||||
|
||||
db_id = await add_user_to_db(token.claims)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue