feat(auth): 新增手机号与 DCAuth 设备认证登录
- 登录链路改为用户名 + 密码 + 短信验证码 + DCAuth v2 设备签名 - 新增 login_sms_codes / user_devices / device_challenges 三张表,迁移 0063/0064 - 设备绑定只比对 deviceId + publicKey,每账号一个 active 设备,管理员可重置 - 保留未绑定手机号账号的密码登录兜底,绑定后强制安全登录 - 登录页与用户管理页支持验证码、DCAuth 轮询、手机号绑定与设备重置
This commit is contained in:
@@ -15,14 +15,17 @@ from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from utils import setup_logger
|
||||
|
||||
from .database import init_db
|
||||
from .errors import ApiError, api_error_handler
|
||||
from .routers import (
|
||||
account_check,
|
||||
accounts,
|
||||
admin_users,
|
||||
audit,
|
||||
auth,
|
||||
automation,
|
||||
cookies,
|
||||
dashboard,
|
||||
dcauth,
|
||||
douyu,
|
||||
douyu_collab,
|
||||
files,
|
||||
@@ -105,6 +108,9 @@ app = FastAPI(
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
# 业务异常统一带 errorCode,前端据此区分手机号未绑定 / 设备不一致等场景。
|
||||
app.add_exception_handler(ApiError, api_error_handler)
|
||||
|
||||
# CORS(支持通过环境变量配置,逗号分隔;默认开发环境)
|
||||
_cors_env = os.getenv("CORS_ORIGINS", "")
|
||||
if _cors_env:
|
||||
@@ -146,6 +152,8 @@ app.add_middleware(SecurityHeadersMiddleware)
|
||||
# 注册路由
|
||||
app.include_router(auth.router)
|
||||
app.include_router(users.router)
|
||||
app.include_router(admin_users.router)
|
||||
app.include_router(dcauth.router)
|
||||
app.include_router(accounts.router)
|
||||
app.include_router(account_check.router)
|
||||
app.include_router(dashboard.router)
|
||||
|
||||
Reference in New Issue
Block a user