feat(imLoginFailureLog): 用户登录密码错误次数锁定与解锁能力(管理端)

- 安全策略登录限频由 JSON 文本改为结构化表单(次数/锁定分钟/窗口分钟),编辑校验同步扩展
- 失败日志新增解锁入口:/imLoginFailureLog/unlock 经 internal 通道调用 im-server 释放锁定
- 失败日志模型补充 accountHash 字段,解锁按钮按 risk_action=account_locked 展示
- 租户业务库初始化模板补充 im_login_lockouts 等表;新增解锁按钮菜单权限 SQL
This commit is contained in:
Austin
2026-09-20 17:04:19 +08:00
parent fd4ff85191
commit 8675fe333d
13 changed files with 238 additions and 19 deletions
@@ -88,6 +88,7 @@ type ImLoginFailureLogModel struct {
UserId string `json:"userId" dc:"用户ID"`
AccountType string `json:"accountType" dc:"账号类型"`
AccountMask string `json:"accountMask" dc:"脱敏账号"`
AccountHash string `json:"accountHash" dc:"账号哈希"`
FailureType string `json:"failureType" dc:"失败类型"`
Reason string `json:"reason" dc:"原因码"`
Detail string `json:"detail" dc:"失败详情"`
@@ -130,6 +131,27 @@ func (in *ImLoginFailureAddBlacklistInp) Filter(ctx context.Context) error {
return nil
}
type ImLoginFailureUnlockInp struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
AccountHash string `json:"accountHash" dc:"账号哈希"`
}
func (in *ImLoginFailureUnlockInp) Filter(ctx context.Context) error {
in.AccountHash = strings.ToLower(strings.TrimSpace(in.AccountHash))
if in.AccountHash == "" {
return gerror.New("账号哈希不能为空")
}
if len(in.AccountHash) != 64 {
return gerror.New("账号哈希格式不正确")
}
for _, c := range in.AccountHash {
if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
return gerror.New("账号哈希格式不正确")
}
}
return nil
}
type ImLoginFailureBanUserInp struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
UserId int64 `json:"userId" dc:"用户ID"`