1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Copyright (c) 2026 Kirky.X. All rights reserved.
//! See LICENSE for full license text.
//! 账号安全引擎模块(吸收 keycloak 安全能力)。
//! 本模块吸收 Keycloak 安全能力,提升 Garrison 原生账号安全能力。
//! 与 `secure/` 模块(密码学原语)互补:`secure/` 提供 TOTP/签名/Basic/Digest
//! 等底层原语,`account/` 提供账号生命周期安全能力。
//!
//! # 子模块
//!
//! | 子模块 | Feature | 说明 |
//! |--------|---------|------|
//! | `credential` | `account-credential` | 统一凭证模型 SPI(Credential trait + PasswordCredential + TotpCredential) |
//! | `policy` | `account-policy` | 密码策略套件(12+ PasswordPolicyRule) |
//! | `lockout` | `account-lockout` | 用户级双态账号锁定(temporary + permanent) |
//! | `authflow` | `account-authflow` | AuthenticationFlow DSL(全认证流程编排) |
//!
//! # 与现有模块的关系
//!
//! - `secure/`:保留 totp/sign/httpbasic/httpdigest/confusable 子模块(密码学原语)
//! - `secure/password/`:v0.6.0 删除,迁移到 `account/credential/password.rs`
//! - `stp/`:不变,authflow DSL 在 SessionLogic/MfaLogic 之上编排
//! - `strategy/firewall/`:BruteForceStrategy 保留,UserLockoutStrategy 组合到 Firewall 执行链
/// 凭证模型 SPI 子模块(`account-credential` feature)。
///
/// 提供 `Credential` trait + `CredentialModel` + `CredentialRepository` 统一凭证抽象,
/// 含 `PasswordCredential`(吸收 secure/password/)和 `TotpCredential`(复用 secure/totp/)。
/// 密码策略套件子模块(`account-policy` feature)。
///
/// 提供 `PasswordPolicyRule` trait + `PasswordPolicyEngine` + 12+ 规则实现
/// (长度/复杂度/历史/黑名单/用户名相似/常见密码/过期/字典/重复字符/序列/邮箱/正则)。
/// 用户级双态账号锁定子模块(`account-lockout` feature)。
///
/// 提供 `UserLockoutStrategy` 实现 `GarrisonFirewallStrategy` trait,
/// 支持 temporary + permanent 双态锁定,与 `BruteForceStrategy`(IP 级)组合使用。
/// AuthenticationFlow DSL 子模块(`account-authflow` feature)。
///
/// 提供声明式认证流程编排:`AuthenticationFlow` + `AuthStep` + `AuthExecutor`,
/// 覆盖登录 + MFA + 社交登录 + SSO 全认证流程。
/// 账号安全能力 Prometheus 指标子模块(`metrics-prometheus` feature)。
///
/// 提供 `AccountMetrics`:4 个指标覆盖凭证验证 / 策略校验 / 锁定触发 / 认证流程执行。
/// 未启用 `metrics-prometheus` 时 `AccountMetrics` 为 `()` unit type 别名。
/// 封禁库子模块,提供账号封禁/解封/查询能力。
///
/// 提供 `DisableEntry` struct + `DisableRepository` trait(独立于 `GarrisonDao`,
/// 通过持有 `Arc<dyn GarrisonDao>` 委托实现)。非 feature-gated,依赖核心 `GarrisonDao` trait。