chore: initial commit — leaudit-platform project skeleton
17-table PostgreSQL schema with full Chinese column comments, FastAPI project structure (admin/common/modules), DSL rule files, and schema migration scripts.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"""JWT 鉴权工具。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import jwt
|
||||
from fastapi import Request
|
||||
|
||||
from fastapi_admin.config import JWT_SECRET_KEY, JWT_ALGORITHM
|
||||
|
||||
|
||||
def verify_access_token(RequestObj: Request) -> dict[str, Any]:
|
||||
"""验证 JWT access token 并返回 payload。"""
|
||||
auth = RequestObj.headers.get("Authorization", "")
|
||||
if not auth.startswith("Bearer "):
|
||||
return {}
|
||||
token = auth.removeprefix("Bearer ").strip()
|
||||
try:
|
||||
payload = jwt.decode(token, JWT_SECRET_KEY, algorithms=[JWT_ALGORITHM])
|
||||
return payload
|
||||
except jwt.PyJWTError:
|
||||
return {}
|
||||
Reference in New Issue
Block a user