添加用户会话数限制功能,当超过最大会话数时自动移除最旧的会话 - 在config中添加UserSessionsKeyPrefix常量 - 在JwtAuth配置中新增MaxSessionsPerUser字段 - 在ServiceContext中实现EnforceUserSessionLimit方法 - 在所有登录逻辑中调用会话限制检查
This commit is contained in:
@@ -42,6 +42,9 @@ const SessionIdKey = "auth:session_id"
|
||||
// DeviceCacheKeyKey cache session key
|
||||
const DeviceCacheKeyKey = "auth:device_identifier"
|
||||
|
||||
// UserSessionsKeyPrefix per-user sessions zset key prefix
|
||||
const UserSessionsKeyPrefix = "auth:user_sessions:"
|
||||
|
||||
// GlobalConfigKey Global Config Key
|
||||
const GlobalConfigKey = "system:global_config"
|
||||
|
||||
|
||||
@@ -42,8 +42,9 @@ type RedisConfig struct {
|
||||
}
|
||||
|
||||
type JwtAuth struct {
|
||||
AccessSecret string `yaml:"AccessSecret"`
|
||||
AccessExpire int64 `yaml:"AccessExpire" default:"604800"`
|
||||
AccessSecret string `yaml:"AccessSecret"`
|
||||
AccessExpire int64 `yaml:"AccessExpire" default:"604800"`
|
||||
MaxSessionsPerUser int64 `yaml:"MaxSessionsPerUser" default:"3"`
|
||||
}
|
||||
|
||||
type Verify struct {
|
||||
|
||||
Reference in New Issue
Block a user