Profile 切换
同一用户可能需要在不同授权上下文之间切换,例如从 Reader 切换到 Editor。IAM 不会直接提升旧 Token,而是基于目标 Profile 创建一条新的 Session。
- 旧 Token / Session 保持原权限;
- 新 Profile 对应新的 Token / Session;
- 两条 Session 独立生命周期;
- 返回结果仍是
AuthenticationResult:accessToken、sessionId、expiresAt、principal。
| 项目 | 内容 |
|---|---|
| Method | POST |
| Path | /iam/authorization/profiles/{profileId}/switch |
| Auth | Bearer Token |
| 成功 | HTTP 200 |
| 目标不存在 | 404 |
QuickStart 中 Alice 的 Editor Profile ID 为 402。
切换成功后返回新的认证结果,例如:
{ "accessToken": "<new-editor-token>", "sessionId": "<new-editor-session>", "expiresAt": "<timestamp>", "principal": { "userId": 101, "activeProfileId": 402, "templateVersionId": 302 }}此时:
- 新 Editor Token 使用 Profile 402;
- 原 Reader Token 仍保持 Reader 权限;
- 不应该把这个行为描述成“修改旧 Session”。
AuthorizationProfileSwitchService:https://github.com/wbh123/iam/tree/main/muer-authentication/src/main/java/io/github/muer/authenticationAuthenticationResult:同上目录