feat: optimize token verification

This commit is contained in:
martsforever
2025-11-24 16:58:55 +08:00
parent 0c6ca599e3
commit 25d9dce5f1
+7
View File
@@ -1,6 +1,7 @@
import time
import traceback
import jwt
from fastapi import FastAPI, HTTPException
from passlib.exc import InvalidTokenError
from starlette import status
@@ -65,6 +66,12 @@ def add_app_middlewares(app: FastAPI):
raise unauthorized_exception
except InvalidTokenError:
raise unauthorized_exception
except jwt.exceptions.InvalidSignatureError:
raise unauthorized_exception
except jwt.exceptions.ExpiredSignatureError:
raise unauthorized_exception
except jwt.exceptions.DecodeError:
raise unauthorized_exception
async def get_default_cache_value():
async with async_session() as session: