会话管理
用户可能从多个设备或客户端登录,需要查看当前有哪些 Session、它们何时登录、最近何时活跃,以及何时过期。
AuthSession 记录:
sessionIduserIdclientTypeclientInstanceipAddressuserAgentloginAtlastSeenAtexpiresAtrevokedAtlogoutAtrevokeReason常用生命周期方法包括 revoked()、revoke(at, reason) 和 touch(at)。
iam.session.touch-interval 默认 10m,用于控制活跃时间更新频率。
查询当前 Session
Section titled “查询当前 Session”| 项目 | 内容 |
|---|---|
| Method | GET |
| Path | /iam/sessions |
| Auth | Bearer Token |
| 成功 | HTTP 200 |
响应结构:
{ "items": [ { "sessionId": "sess-reader", "userId": 101, "clientType": "WEB", "loginAt": "<timestamp>", "lastSeenAt": "<timestamp>", "expiresAt": "<timestamp>" } ]}- MySQL 保存持久 Session 状态;
- Redis 保存不透明 Token 到
TokenRecord的快速索引; - Session 是否撤销、Profile 等持久事实不能只依赖 Redis。