v0.1.0: CRM/ERP 系统内测版本 - 安全加固完成

- Docker bridge 网络隔离(8000 端口封死)
- Gunicorn 4 Worker 多进程
- Alembic 数据库迁移基线
- 日志轮转 20m×3
- JWT 密钥 + DB 密码 + CORS 收紧
- 3-2-1 备份链路(NAS + R740-B 冷备)
- 连接池 pool_pre_ping + pool_recycle=3600
This commit is contained in:
hankin
2026-03-16 07:31:37 +00:00
commit 423baff73b
2578 changed files with 824643 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
"""
Auth 相关 Pydantic V2 Schema
"""
from __future__ import annotations
import uuid
from pydantic import BaseModel, Field
# ── 登录请求 ──────────────────────────────────────────────
class LoginRequest(BaseModel):
username: str = Field(..., min_length=1, max_length=50, examples=["admin"])
password: str = Field(..., min_length=1, max_length=128, examples=["123456"])
# ── Token 响应 ────────────────────────────────────────────
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"
# ── 当前用户信息(从 JWT 解析 + DB 查表组合而来)──────────
class CurrentUserPayload(BaseModel):
"""注入到 Dependency 中的用户权限上下文"""
user_id: uuid.UUID
username: str
real_name: str | None = None
dept_id: uuid.UUID | None = None
dept_name: str | None = None
role_id: uuid.UUID | None = None
role_name: str | None = None
data_scope: str = "self" # all / dept_and_sub / self
menu_keys: list[str] = Field(default_factory=list)
# ── 修改密码请求 ────────────────────────────────────
class UpdatePasswordRequest(BaseModel):
old_password: str = Field(..., min_length=1, max_length=128)
new_password: str = Field(..., min_length=6, max_length=128, description="新密码至少6位")