完成部分API路由以及文档

This commit is contained in:
2025-06-18 02:14:37 +08:00
parent 127fb6972f
commit eb3d2843eb
22 changed files with 2867 additions and 2 deletions

30
middleware/auth.py Normal file
View File

@@ -0,0 +1,30 @@
from typing import Annotated, Literal
from fastapi import Depends
from pkg.JWT import jwt
async def AuthRequired(
token: Annotated[str, Depends(jwt.oauth2_scheme)]
) -> Literal[True]:
'''
AuthRequired 需要登录
'''
return True
async def SignRequired(
token: Annotated[str, Depends(jwt.oauth2_scheme)]
) -> Literal[True]:
'''
SignAuthRequired 需要登录并验证请求签名
'''
return True
async def AdminRequired(
token: Annotated[str, Depends(jwt.oauth2_scheme)]
) -> Literal[True]:
'''
验证是否为管理员。
使用方法:
>>> APIRouter(dependencies=[Depends(is_admin)])
'''
...