feat: optimize token verification
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import jwt
|
||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from passlib.exc import InvalidTokenError
|
from passlib.exc import InvalidTokenError
|
||||||
from starlette import status
|
from starlette import status
|
||||||
@@ -65,6 +66,12 @@ def add_app_middlewares(app: FastAPI):
|
|||||||
raise unauthorized_exception
|
raise unauthorized_exception
|
||||||
except InvalidTokenError:
|
except InvalidTokenError:
|
||||||
raise unauthorized_exception
|
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 def get_default_cache_value():
|
||||||
async with async_session() as session:
|
async with async_session() as session:
|
||||||
|
|||||||
Reference in New Issue
Block a user