feat: 移除配置文件中的管理员用户名和密码,增强安全性
This commit is contained in:
1 parent
9c1093ec29
commit
f0dee4a778
7 files changed
+11
-32
No files matched your search
@@ -23,9 +23,6 @@ auth:
|
||||
secret: "license-manager-dev-secret-key-32-bytes"
|
||||
expire_hours: 1
|
||||
refresh_threshold_minutes: 30
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "admin@123"
|
||||
security:
|
||||
max_login_attempts: 5
|
||||
lockout_duration_minutes: 15
|
||||
|
||||
@@ -24,9 +24,6 @@ auth:
|
||||
secret: "license-manager-dev-secret-key-32-bytes" # 32字节的随机字符串
|
||||
expire_hours: 1 # 1小时后过期
|
||||
refresh_threshold_minutes: 30 # 30分钟后可刷新token
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "admin@123"
|
||||
security:
|
||||
max_login_attempts: 5 # 5次失败后锁定15分钟
|
||||
lockout_duration_minutes: 15 # 15分钟后解锁
|
||||
|
||||
@@ -23,9 +23,6 @@ auth:
|
||||
secret: "please-change-in-prod"
|
||||
expire_hours: 1
|
||||
refresh_threshold_minutes: 30
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "changeMe!"
|
||||
security:
|
||||
max_login_attempts: 5
|
||||
lockout_duration_minutes: 15
|
||||
|
||||
@@ -23,9 +23,6 @@ auth:
|
||||
secret: "license-manager-dev-secret-key-32-bytes" # 32字节的随机字符串
|
||||
expire_hours: 1 # 1小时后过期
|
||||
refresh_threshold_minutes: 30 # 30分钟后可刷新token
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "admin@123"
|
||||
security:
|
||||
max_login_attempts: 5 # 5次失败后锁定15分钟
|
||||
lockout_duration_minutes: 15 # 15分钟后解锁
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
## 社区版登录设计
|
||||
|
||||
用户名和密码配置在配置文件中,默认用户名和密码为 `admin` / `admin@123`
|
||||
用户名和密码硬编码在系统中,默认用户名和密码为 `admin` / `admin@123`
|
||||
|
||||
## 功能模块
|
||||
|
||||
|
||||
@@ -40,24 +40,18 @@ type DatabaseConfig struct {
|
||||
|
||||
type AuthConfig struct {
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
Admin AdminConfig `mapstructure:"admin"`
|
||||
Security SecurityConfig `mapstructure:"security"`
|
||||
}
|
||||
|
||||
type JWTConfig struct {
|
||||
Secret string `mapstructure:"secret"`
|
||||
ExpireHours int `mapstructure:"expire_hours"`
|
||||
RefreshThresholdMinutes int `mapstructure:"refresh_threshold_minutes"`
|
||||
}
|
||||
|
||||
type AdminConfig struct {
|
||||
Username string `mapstructure:"username"`
|
||||
Password string `mapstructure:"password"`
|
||||
Secret string `mapstructure:"secret"`
|
||||
ExpireHours int `mapstructure:"expire_hours"`
|
||||
RefreshThresholdMinutes int `mapstructure:"refresh_threshold_minutes"`
|
||||
}
|
||||
|
||||
type SecurityConfig struct {
|
||||
MaxLoginAttempts int `mapstructure:"max_login_attempts"`
|
||||
LockoutDurationMinutes int `mapstructure:"lockout_duration_minutes"`
|
||||
MaxLoginAttempts int `mapstructure:"max_login_attempts"`
|
||||
LockoutDurationMinutes int `mapstructure:"lockout_duration_minutes"`
|
||||
}
|
||||
|
||||
type LogConfig struct {
|
||||
@@ -84,7 +78,7 @@ var AppConfig *Config
|
||||
func Load(configPath string) error {
|
||||
viper.SetConfigName("config")
|
||||
viper.SetConfigType("yaml")
|
||||
|
||||
|
||||
if configPath != "" {
|
||||
viper.SetConfigFile(configPath)
|
||||
} else {
|
||||
@@ -136,10 +130,7 @@ func setDefaults() {
|
||||
viper.SetDefault("auth.jwt.secret", "license-manager-default-secret-key")
|
||||
viper.SetDefault("auth.jwt.expire_hours", 1)
|
||||
viper.SetDefault("auth.jwt.refresh_threshold_minutes", 30)
|
||||
|
||||
viper.SetDefault("auth.admin.username", "admin")
|
||||
viper.SetDefault("auth.admin.password", "admin@123")
|
||||
|
||||
|
||||
viper.SetDefault("auth.security.max_login_attempts", 5)
|
||||
viper.SetDefault("auth.security.lockout_duration_minutes", 15)
|
||||
|
||||
@@ -162,4 +153,4 @@ func setDefaults() {
|
||||
|
||||
func GetConfig() *Config {
|
||||
return AppConfig
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -25,7 +25,7 @@ docker run --rm -v $(pwd):/tmp/extract ghcr.io/cedar-v/license-manager-frontend:
|
||||
### 2. 启动服务
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.github.image.yml up -d
|
||||
docker-compose -f docker-compose.github.image.yml up
|
||||
```
|
||||
|
||||
### 3. 检查服务状态
|
||||
@@ -43,7 +43,7 @@ docker-compose -f docker-compose.github.image.yml ps
|
||||
## 默认账号
|
||||
|
||||
- **用户名**: admin
|
||||
- **密码**: changeMe!
|
||||
- **密码**: admin@123
|
||||
|
||||
## 停止服务
|
||||
|
||||
|
||||
Reference in new issue
Block a user