认证业务(Authentication Domain)
认证业务不是“验密码然后发 Token”,而是一整个凭证与会话生命周期域:注册/凭证绑定、Password/MFA、在线攻击防御、登录、Session/Refresh、设备与信任、重新认证、恢复、凭证变更、撤销、安全事件和风险决策共同决定账户当前是否可信。
[!info] related notes
- 实现模块: Authentication模块
- Web 总模型: Web 认证与浏览器安全边界
- Password: Password Policy, Password Storage & Verification
- MFA: 多因素认证(MFA), Password 与 MFA 的安全边界
- Session: Server-side Session 鉴权, Refresh Token
- Recovery: Password Reset & Account Recovery
- Device / Trust: Active Sessions & Device Management, Trusted Device & Remember MFA
- Assurance / Risk: Reauthentication Freshness, Risk-Based Authentication
- Events: Authentication Security Events & Login History
认证业务(Authentication Domain)
一句话定义
认证业务不是:
check password
→ issue JWT
而是:
从凭证创建开始,一直到登录、持续会话、风险变化、恢复和撤销为止,持续回答“当前这个请求是否仍能代表这个用户”。
业务生命周期
可以把整个域拆成:
Credential Enrollment
→ Authentication
→ Session / Grant
→ Ongoing Assurance
→ Recovery / Credential Change
→ Revocation
→ Security Events
每一阶段都有不同 authority。
1. Credential Enrollment
注册/绑定阶段要处理:
- account identifier;
- email verification;
- password policy;
- password verifier;
- MFA enrollment;
- WebAuthn / Passkey registration;
- recovery code generation。
这里建立的是:
identity ↔ authenticators
之间的绑定。
2. Password Credentials
Password 这一层至少拆成:
Password Policy
→ 用户允许选择什么
Password Storage
→ server 怎样保存 verifier
Online Throttling
→ attacker 在线能尝试多少次
不能把:
Argon2id
当成完整 Password Security。
3. Authentication Attempt
一次 Password 登录并不是单个 compare:
request
→ enumeration-safe account lookup
→ throttling / risk context
→ verify credential
→ MFA / step-up if required
→ create authenticated principal
同时要区分:
- brute force;
- password spraying;
- credential stuffing。
详见 在线密码攻击。
4. MFA
MFA 不是:
多输入一个 code
而是要求独立 factor。
认证域必须处理:
- enrollment;
- challenge;
- retry limit;
- factor replacement;
- recovery;
- remembered-device policy;
- assurance state。
强 MFA 也不能靠弱 recovery flow 绕过。
5. Session / Grant
认证成功后不会每个请求重新提交 Password。
系统创建:
Session / Grant
→ long-lived authentication lifecycle authority
并可能签发:
- opaque Session Token;
- short-lived Access Token;
- Refresh Token。
核心问题包括:
- expiration;
- idle timeout;
- rotation;
- revoke;
- logout all devices;
- stale Access Token window。
6. Ongoing Assurance
Session 存在不等于:
all sensitive actions forever allowed
还要维护:
- auth_time;
- authentication methods;
- MFA verified time;
- assurance;
- risk state;
- trusted-device state。
高风险操作通过:
required assurance
+ maximum auth age
→ step-up / reauthentication
完成。
7. Device / Trusted Client
“设备管理”通常是:
Session/Grant
+ device metadata
+ remembered trust credential
而不是浏览器 magically 获得稳定 hardware identity。
Fingerprint / IP / location:
→ risk signal
≠ authenticator
8. Recovery
Recovery 是另一条 Authentication Path。
包括:
- forgot password;
- MFA recovery;
- recovery codes;
- email recovery;
- support/admin recovery。
核心原则:
Recovery assurance 不能弱到可以轻松绕过正常认证。
恢复成功后还要考虑:
- Session revoke;
- Refresh family revoke;
- remembered device revoke;
- security notification;
- fresh login。
9. Credential Change
以下都属于 security-critical event:
- password change;
- password reset;
- email change;
- MFA factor add/remove;
- recovery-code regeneration;
- trusted-device enrollment;
- Passkey enrollment/removal。
通常需要:
- recent reauthentication;
- audit;
- notification;
- Session assurance update;
- 必要的 revoke。
10. Risk-Based Authentication
认证系统可以根据:
- device;
- IP/ASN;
- account velocity;
- source velocity;
- known leaked credentials;
- MFA failure;
- recovery sequence;
- behavior;
选择:
allow
step-up
delay
deny
recovery
alert
Risk signal 不替代 authentication factor。
11. Security Events
认证域需要独立事件词汇:
login success/failure
MFA challenge/result
recovery
credential change
session revoke
trusted-device change
risk step-up
这些事件同时服务:
- monitoring;
- detection;
- investigation;
- user Login History;
- security notifications。
但日志不能保存 raw secrets。
12. Authentication 与 Authorization
认证业务最终产生:
trusted principal / session context
但这只回答:
who / how strongly authenticated
不回答:
can user modify resource X?
资源级 Authorization 仍要单独检查:
- ownership;
- tenant;
- role;
- policy;
- business state。
一个稳定的业务边界
Account Domain
→ 用户资料 / identifier / lifecycle
Authentication Domain
→ authenticator + session + assurance + recovery
Authorization Domain
→ resource / action policy
Security Monitoring
→ event / risk / incident projection
实际实现可以在一个服务里,但概念职责应保持分离。
学习检查
- 为什么 Authentication Domain 不能等价成“Login API”?
- Password Policy、Password Storage、Throttling 各自解决什么问题?
- MFA enrollment / recovery 为什么都属于认证域?
- Session live 与 auth fresh 为什么是两个判断?
- Trusted Device 为什么不能只由 fingerprint 定义?
- Recovery 后为什么需要重新评估 Session/Refresh/remembered trust?
- Risk-Based Authentication 为什么不能替代真正 authenticator?
- Authentication 与 Authorization 的业务边界在哪里?