1. 为imSensitiveWord、imUserPolicyGroup、imSecurityPolicy页面添加租户ID校验,避免表格挂载时因租户默认值未就绪发起无效请求 2. 更新imLoginFailureLog、imUserLoginHistory的搜索占位符与账号列宽 3. 修正后端登录审计相关结构体的字段注释描述
184 lines
6.7 KiB
Go
184 lines
6.7 KiB
Go
package sysin
|
|
|
|
import (
|
|
"context"
|
|
"hotgo/internal/model/input/form"
|
|
"strings"
|
|
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
type ImUserLoginHistoryListInp struct {
|
|
form.PageReq
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" dc:"用户ID"`
|
|
Account string `json:"account" dc:"账号"`
|
|
LoginType string `json:"loginType" dc:"登录方式"`
|
|
EventType string `json:"eventType" dc:"事件类型"`
|
|
Platform string `json:"platform" dc:"客户端平台"`
|
|
Ip string `json:"ip" dc:"IP地址"`
|
|
LoginAt []*gtime.Time `json:"loginAt" dc:"登录时间"`
|
|
}
|
|
|
|
func (in *ImUserLoginHistoryListInp) Filter(ctx context.Context) error {
|
|
in.Account = strings.TrimSpace(in.Account)
|
|
in.Ip = strings.TrimSpace(in.Ip)
|
|
return filterImAuditPage(&in.PageReq)
|
|
}
|
|
|
|
type ImUserLoginHistoryModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
UserId string `json:"userId" dc:"用户ID"`
|
|
Username string `json:"username" dc:"用户名"`
|
|
AccountType string `json:"accountType" dc:"账号类型"`
|
|
AccountMask string `json:"accountMask" dc:"账号"`
|
|
LoginType string `json:"loginType" dc:"登录方式"`
|
|
EventType string `json:"eventType" dc:"事件类型"`
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
DeviceId string `json:"deviceId" dc:"设备ID"`
|
|
Platform string `json:"platform" dc:"客户端平台"`
|
|
AppVersion string `json:"appVersion" dc:"客户端版本"`
|
|
Ip string `json:"ip" dc:"IP地址"`
|
|
Region string `json:"region" dc:"地区"`
|
|
UserAgent string `json:"userAgent" dc:"客户端标识"`
|
|
RiskLevel string `json:"riskLevel" dc:"风险等级"`
|
|
RequestId string `json:"requestId" dc:"请求ID"`
|
|
LoginAt *gtime.Time `json:"loginAt" dc:"登录时间"`
|
|
LogoutAt *gtime.Time `json:"logoutAt" dc:"登出时间"`
|
|
Metadata string `json:"metadata" dc:"元数据"`
|
|
}
|
|
|
|
type ImLoginFailureLogListInp struct {
|
|
form.PageReq
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" dc:"用户ID"`
|
|
Account string `json:"account" dc:"账号"`
|
|
FailureType string `json:"failureType" dc:"失败类型"`
|
|
Platform string `json:"platform" dc:"客户端平台"`
|
|
Ip string `json:"ip" dc:"IP地址"`
|
|
AttemptAt []*gtime.Time `json:"attemptAt" dc:"尝试时间"`
|
|
}
|
|
|
|
func (in *ImLoginFailureLogListInp) Filter(ctx context.Context) error {
|
|
in.Account = strings.TrimSpace(in.Account)
|
|
in.Ip = strings.TrimSpace(in.Ip)
|
|
return filterImAuditPage(&in.PageReq)
|
|
}
|
|
|
|
func filterImAuditPage(page *form.PageReq) error {
|
|
if page.Page <= 0 {
|
|
page.Page = 1
|
|
}
|
|
if page.PerPage <= 0 {
|
|
page.PerPage = 20
|
|
}
|
|
if page.PerPage > 200 {
|
|
return gerror.New("每页数量不能超过200")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImLoginFailureLogModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
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:"失败详情"`
|
|
Ip string `json:"ip" dc:"IP地址"`
|
|
Region string `json:"region" dc:"地区"`
|
|
DeviceId string `json:"deviceId" dc:"设备ID"`
|
|
Platform string `json:"platform" dc:"客户端平台"`
|
|
AppVersion string `json:"appVersion" dc:"客户端版本"`
|
|
UserAgent string `json:"userAgent" dc:"客户端标识"`
|
|
RiskLevel string `json:"riskLevel" dc:"风险等级"`
|
|
RiskAction string `json:"riskAction" dc:"风控动作"`
|
|
RequestId string `json:"requestId" dc:"请求ID"`
|
|
AttemptAt *gtime.Time `json:"attemptAt" dc:"尝试时间"`
|
|
Metadata string `json:"metadata" dc:"元数据"`
|
|
}
|
|
|
|
type ImLoginFailureViewInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Id int64 `json:"id" dc:"日志ID"`
|
|
}
|
|
|
|
func (in *ImLoginFailureViewInp) Filter(ctx context.Context) error {
|
|
if in.Id <= 0 {
|
|
return gerror.New("日志ID不能为空")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImLoginFailureAddBlacklistInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Ip string `json:"ip" dc:"IP地址"`
|
|
Remark string `json:"remark" dc:"备注"`
|
|
}
|
|
|
|
func (in *ImLoginFailureAddBlacklistInp) Filter(ctx context.Context) error {
|
|
in.Ip = strings.TrimSpace(in.Ip)
|
|
if in.Ip == "" {
|
|
return gerror.New("IP地址不能为空")
|
|
}
|
|
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"`
|
|
Reason string `json:"reason" dc:"封禁原因"`
|
|
}
|
|
|
|
func (in *ImLoginFailureBanUserInp) Filter(ctx context.Context) error {
|
|
in.Reason = strings.TrimSpace(in.Reason)
|
|
if in.UserId <= 0 {
|
|
return gerror.New("用户ID不能为空")
|
|
}
|
|
if in.Reason == "" {
|
|
return gerror.New("封禁原因不能为空")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImLoginAuditExportModel struct {
|
|
Id int64 `json:"id" dc:"ID"`
|
|
UserId string `json:"userId" dc:"用户ID"`
|
|
AccountMask string `json:"accountMask" dc:"账号"`
|
|
EventType string `json:"eventType" dc:"事件/失败类型"`
|
|
Platform string `json:"platform" dc:"客户端平台"`
|
|
Ip string `json:"ip" dc:"IP地址"`
|
|
Region string `json:"region" dc:"地区"`
|
|
RiskLevel string `json:"riskLevel" dc:"风险等级"`
|
|
Reason string `json:"reason" dc:"原因"`
|
|
OccurredAt *gtime.Time `json:"occurredAt" dc:"发生时间"`
|
|
}
|