POST /mfa/totp/enable

为用户启用基于时间的一次性密码(TOTP)认证,生成密钥和二维码,返回备用恢复码。参考:RFC 6238 (TOTP)、OWASP ASVS V2.8.3。

多因素认证 `bearerAuth` application/json

请求体

Schema: service-mfa/internal/handler/dto.TOTPEnableRequest

字段类型必填示例约束描述
account string 否
device_name string 否

响应

状态描述Schema
200TOTP配置信息,包含密钥URL和二维码service-mfa/internal/handler/dto.TOTPEnableDetailResponse
400参数错误或TOTP已启用service-core/base/dto.SimpleResponse
401未认证service-core/base/dto.SimpleResponse
500服务器内部错误service-core/base/dto.SimpleResponse

引用的 Schema

service-core/base/dto.SimpleResponse

字段类型必填示例约束描述
code integer 否
message string 否
timestamp string 否

service-mfa/internal/handler/dto.TOTPEnableDetailResponse

字段类型必填示例约束描述
code integer 否
data service-mfa/internal/handler/dto.TOTPEnableResponse 否
message string 否
timestamp string 否

service-mfa/internal/handler/dto.TOTPEnableResponse

字段类型必填示例约束描述
backup_codes array of

string

否 ['["12345678"', '"23456789"]']
qr_code string 否 data:image/png;base64,iVBORw0KGgo...
qr_code_url string 否 otpauth://totp/Autional:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Autional
secret string 否 JBSWY3DPEHPK3PXP
setup_url string 否 https://auth.example.com/mfa/totp/setup