shanshanzhong 1d5d361ae8
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m32s
feat(auth): 实现用户会话数限制功能
添加用户会话数限制功能,当超过最大会话数时自动移除最旧的会话
- 在config中添加UserSessionsKeyPrefix常量
- 在JwtAuth配置中新增MaxSessionsPerUser字段
- 在ServiceContext中实现EnforceUserSessionLimit方法
- 在所有登录逻辑中调用会话限制检查
2025-11-26 17:52:12 -08:00

68 lines
2.0 KiB
Go

package config
// CurrencyConfigKey Currency Config Key
const CurrencyConfigKey = "system:currency_config"
// SmsConfigKey Mobile Config Key
const SmsConfigKey = "system:sms_config"
// SiteConfigKey Site Config Key
const SiteConfigKey = "system:site_config"
// SubscribeConfigKey Subscribe Config Key
const SubscribeConfigKey = "system:subscribe_config"
// RegisterConfigKey Register Config Key
const RegisterConfigKey = "system:register_config"
// VerifyConfigKey Verify Config Key
const VerifyConfigKey = "system:verify_config"
// EmailSmtpConfigKey Email Smtp Config Key
const EmailSmtpConfigKey = "system:email_smtp_config"
// NodeConfigKey Node Config Key
const NodeConfigKey = "system:node_config"
// InviteConfigKey Invite Config Key
const InviteConfigKey = "system:invite_config"
// TelegramConfigKey Telegram Config Key
const TelegramConfigKey = "system:telegram_config"
// TosConfigKey Tos配置
const TosConfigKey = "system:tos_config"
// VerifyCodeConfigKey Verify Code Config Key
const VerifyCodeConfigKey = "system:verify_code_config"
// SessionIdKey cache session key
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"
// AuthCodeCacheKey Register Code Cache Key
const AuthCodeCacheKey = "auth:verify:email"
// AuthCodeTelephoneCacheKey Register Code Cache Key
const AuthCodeTelephoneCacheKey = "auth:verify:telephone"
// CommonStatCacheKey CommonStat Cache Key
const CommonStatCacheKey = "common:stat"
// ServerCountCacheKey Server Count Cache Key
const ServerCountCacheKey = "server:count"
// SendIntervalKeyPrefix Auth Code Send Interval Key Prefix
const SendIntervalKeyPrefix = "send:interval:"
// SendCountLimitKeyPrefix Send Count Limit Key Prefix eg. send:limit:register:email:xxx@ppanel.dev
const SendCountLimitKeyPrefix = "send:limit:"