POST /auth/me/switch-tenant

验证用户在新租户下的成员资格,检查跨租户切换策略,验证通过后签发新JWT令牌(含新租户的角色和权限)。参考:NIST SP 800-53 AC-2、OWASP ASVS V1.2。

身份认证 `bearerAuth` application/json

请求体

Schema: service-identity/internal/handler/dto.SwitchTenantRequest

字段类型必填示例约束描述
tenant_id string 是

响应

状态描述Schema
200租户切换成功,返回新JWT令牌service-identity/internal/handler/dto.SwitchTenantResponseWrapper
400请求参数无效service-core/base/dto.SimpleResponse
401未认证或令牌无效service-core/base/dto.SimpleResponse
403无目标租户成员资格或跨租户切换被禁用service-core/base/dto.SimpleResponse
500服务器内部错误service-core/base/dto.SimpleResponse

引用的 Schema

service-core/base/dto.SimpleResponse

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

service-identity/internal/handler/dto.SwitchTenantResponse

字段类型必填示例约束描述
access_token string 否
expires_in integer 否
refresh_token string 否
token_type string 否
user service-identity/internal/handler/dto.UserInfo 否

service-identity/internal/handler/dto.SwitchTenantResponseWrapper

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

service-identity/internal/handler/dto.UserInfo

用户基本信息

字段类型必填示例约束描述
created_at string 否 2026-01-15T10:30:00Z Account creation time
email string 否 john@example.com Email
id string 否 usr_abc123 User ID
last_login_at string 否 2026-07-20T08:00:00Z Last login time
metadata object 否 AUTH-44:metadata 仅 /auth/me 回传(portal 偏好等);其余构造点省略。
mfa_enabled boolean 否 True AUTH-44:指针 + omitempty —— 仅权威构造点(/auth/me)填充;其余构造点省略该键, 避免登录响应等处误报 mfa_enabled=false(零值不等于"未启用")。
must_change_password boolean 否 False Password must be changed
password_expires_in integer 否 30 Days until password expires
password_warning string 否 expiring Password warning: expiring/expired_grace/expired
phone string 否 13800138000 Phone
status string 否 active Status
username string 否 john.doe Username