← [ BACK_TO_NOTES ]

Active Sessions & Device Management

Active Session 管理把每次长期登录建模为可枚举、可撤销的 Session/Grant,并可附带设备标签、最近活动、认证方式与风险元数据;Session 与物理设备不是一回事,设备管理 UI 本质上是对认证会话与设备信号的安全投影。

#synthesis #evergreen #auth

[!info] related notes

Active Sessions & Device Management

一句话关系

用户看到的“已登录设备”通常并不是一张纯设备表。

更准确的模型是:

User → Active Sessions / Grants → each session has device/context metadata

所以:

Session ≠ Physical Device

一个设备可以有多个 Session,一个 Session 也可能因浏览器重装、Profile 变化或 Token rotation 改变标识。

Session Record

一个长期 Session / Grant 常见字段:

  • session_id;
  • user_id;
  • created_at;
  • last_seen_at;
  • expires_at;
  • revoked_at;
  • authentication methods;
  • MFA / assurance state;
  • device label;
  • browser / OS summary;
  • IP / network context;
  • risk state;
  • refresh family/version。

这些字段服务于:

  • revoke;
  • user-facing session list;
  • suspicious activity detection;
  • audit;
  • step-up decisions。

“当前设备”通常其实是“当前 Session”

UI 写:

Current device

底层更准确的判定通常是:

current session_id == row.session_id

而不是:

fingerprint matches some physical machine

因为浏览器很难稳定、可靠、隐私友好地识别一台物理设备。

Device Label

用户可读标签例如:

Chrome on Windows iPhone App Desktop App

应该被理解为 display metadata。

它可以来自:

  • user agent;
  • platform info;
  • client-provided device name;
  • app installation metadata。

不要把 display label 当作认证凭证。

Last Seen

last_seen_at 是 operational metadata。

更新策略要权衡:

  • DB write amplification;
  • privacy;
  • accuracy;
  • usefulness。

常见做法不是每个请求都 UPDATE,而是:

  • time-bucket throttled update;
  • async event;
  • Redis hot state + periodic persistence。

IP / Location

Session history 可展示:

IP / rough location

用于帮助用户发现异常。

但必须明确:

  • IP 会变化;
  • NAT/VPN/CGNAT;
  • mobile network;
  • geolocation 不精确;
  • location 是 risk/display signal,不是 identity proof。

Revoke One Session

用户点击:

Sign out this device

更准确的服务端动作:

session_id → revoke Session / Grant → revoke Refresh family → invalidate remembered-device trust bound to that session/device when policy requires

短期 Access Token 是否即时失效取决于架构:

  • Session authority per-request check → 可立即;
  • pure stateless Access Token → 可能直到 exp。

Revoke All Other Sessions

常见高价值操作:

Keep current session → revoke all others

需要稳定的:

user_id → sessions secondary index

并明确 current session 的识别方式。

如果是 compromise response,通常更合理:

revoke all including current → require fresh authentication

Device Management 与 Account Recovery

Password reset / MFA reset / suspicious takeover 后:

device trust remembered MFA refresh family Session

都需要重新评估。

只撤销 Web Session,却保留 remembered-device bypass token,可能留下认证后门。

详见 Credential Change & Session Revocation。

Session 列表不是完整 Security History

Active Sessions 表示:

currently usable or recently live login state

Login History / Security Events 表示:

historical immutable-ish event trail

二者职责不同。

用户退出某 Session 后,它应从 Active Sessions 消失,但对应登录/撤销事件仍可留在 Security History。

详见 Authentication Security Events & Login History。

Privacy 边界

Device/session metadata 本身可能是个人数据:

  • IP;
  • location;
  • device identifier;
  • user agent;
  • login time。

所以要定义:

  • retention;
  • access control;
  • user visibility;
  • redaction;
  • deletion/anonymization。

不要为了“安全日志”无限保存所有精细设备数据。

学习检查

  1. 为什么 Active Session 不等于 Physical Device?
  2. “Current Device” UI 最可靠的底层标识通常是什么?
  3. last_seen_at 为什么不一定每请求持久化?
  4. IP/location 为什么适合做风险信号,却不适合做身份凭证?
  5. revoke one session 时为什么还要考虑 Refresh family / remembered trust?
  6. Active Sessions 与 Login History 有什么职责差异?
  7. 设计一个“退出其他所有设备”的 Session 状态转换。
创建于 2026/9/30 更新于 2026/9/30
Digital Biome
Access

键盘导航

j / k / ↑ / ↓
选择对象
Enter / o
打开选择
/ 或 Ctrl+K
全站搜索
i / f / 1–4
筛选当前列表
g → h / l / p / t / a
首页 / 笔记 / 项目 / 工具 / About
r → 1–9
打开所选对象的关联
u
返回上一页
Esc
关闭浮层 / 取消命令;输入框内清空文本