feat: add auth module with login and access control

This commit is contained in:
2026-05-07 14:34:42 +08:00
parent 2d56bc2889
commit b8ba0ea6a0
15 changed files with 501 additions and 34 deletions

View File

@@ -0,0 +1,24 @@
from __future__ import annotations
from pydantic import BaseModel, EmailStr, Field
class LoginRequest(BaseModel):
username: str = Field(min_length=1, max_length=255)
password: str = Field(min_length=1, max_length=128)
class AuthUserRead(BaseModel):
username: str
name: str
role: str
roleCodes: list[str] = Field(default_factory=list)
email: EmailStr | str
avatar: str
isAdmin: bool = False
class LoginResponse(BaseModel):
ok: bool = True
detail: str = "登录成功。"
user: AuthUserRead