Initial FastAPI admin auth scaffold

This commit is contained in:
2026-06-05 17:10:30 +08:00
commit 5635da9ea5
65 changed files with 1407 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
from app.constants.result_code import ResultCode
from app.exception.err_exception import ErrException
from app.lib.jwt.factory import JwtFactory
from app.lib.jwt.jwt import Jwt
from app.lib.jwt.token import JwtToken
class BaseTokenService:
def __init__(self, jwt_factory: JwtFactory) -> None:
self.jwt_factory = jwt_factory
def get_jwt(self, scene: str = "admin") -> Jwt:
return self.jwt_factory.get(scene)
async def check_jwt(self, jwt: Jwt, token: JwtToken) -> None:
if await jwt.has_blacklist(token):
raise ErrException("token已过期", ResultCode.JWT_EXPIRED)