44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
"""auth_oauth 请求/响应模型。
|
||||
|
|
|
|||
|
|
框架契约:所有插件须有 models/pydantic.py(gen_models 的产物位置)——
|
|||
|
|
网关契约校验按 plugins.<type>.models.pydantic → src.plugins.... → workers....
|
|||
|
|
顺序探测,缺失时会以 src.plugins. 前缀二次执行插件包(父包导入链),
|
|||
|
|
插件内自定义 SQLModel 表会在全局元数据中重复定义导致启动失败。
|
|||
|
|
本插件模型由手写(等价 gen_models 产物),端点函数以类型注解直接绑定。
|
|||
|
|
登录响应 LoginPostResponse 直接从 chongming_auth 导入(共享契约)。
|
|||
|
|
"""
|
|||
|
|
from pydantic import BaseModel, Field
|
|||
|
|
|
|||
|
|
|
|||
|
|
class GithubAuthorizeGetResponse(BaseModel):
|
|||
|
|
"""授权跳转 URL 响应"""
|
|||
|
|
result: str = Field(..., description="success/fail")
|
|||
|
|
authorize_url: str = Field(default="", description="GitHub 授权跳转 URL")
|
|||
|
|
state: str = Field(default="", description="防 CSRF state(一次性,300s)")
|
|||
|
|
expires_in: int = Field(default=300, description="state 有效期(秒)")
|
|||
|
|
|
|||
|
|
|
|||
|
|
class GithubCallbackPostRequest(BaseModel):
|
|||
|
|
"""GitHub 回调请求"""
|
|||
|
|
code: str = Field(..., description="GitHub 回跳授权码")
|
|||
|
|
state: str = Field(..., description="authorize 返回的 state")
|
|||
|
|
|
|||
|
|
|
|||
|
|
class PhoneSendCodePostRequest(BaseModel):
|
|||
|
|
"""发送验证码请求"""
|
|||
|
|
phone: str = Field(..., description="手机号")
|
|||
|
|
|
|||
|
|
|
|||
|
|
class PhoneSendCodePostResponse(BaseModel):
|
|||
|
|
"""发送验证码响应"""
|
|||
|
|
result: str = Field(..., description="success/fail")
|
|||
|
|
message: str = Field(..., description="结果消息")
|
|||
|
|
expires_in: int = Field(default=300, description="验证码有效期(秒)")
|
|||
|
|
dev_code: str | None = Field(default=None, description="验证码(仅演示模式返回)")
|
|||
|
|
|
|||
|
|
|
|||
|
|
class PhoneLoginPostRequest(BaseModel):
|
|||
|
|
"""验证码登录请求"""
|
|||
|
|
phone: str = Field(..., description="手机号")
|
|||
|
|
code: str = Field(..., description="短信验证码")
|