From f0dee4a77810f111a1789aa933e2fbb0b0138893 Mon Sep 17 00:00:00 2001 From: wood911010 Date: Sun, 12 Oct 2025 12:07:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E5=92=8C=E5=AF=86=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/configs/config.dev.yaml | 3 --- backend/configs/config.example.yaml | 3 --- backend/configs/config.prod.yaml | 3 --- backend/configs/config.yaml | 3 --- backend/docs/modules_design/login&auth.md | 2 +- backend/internal/config/config.go | 25 ++++++++--------------- docs/github镜像部署.md | 4 ++-- 7 files changed, 11 insertions(+), 32 deletions(-) diff --git a/backend/configs/config.dev.yaml b/backend/configs/config.dev.yaml index 2cf7c46..d0727f0 100644 --- a/backend/configs/config.dev.yaml +++ b/backend/configs/config.dev.yaml @@ -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 diff --git a/backend/configs/config.example.yaml b/backend/configs/config.example.yaml index 6a4e34b..2ea7416 100644 --- a/backend/configs/config.example.yaml +++ b/backend/configs/config.example.yaml @@ -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分钟后解锁 diff --git a/backend/configs/config.prod.yaml b/backend/configs/config.prod.yaml index adad505..8cd3ff0 100644 --- a/backend/configs/config.prod.yaml +++ b/backend/configs/config.prod.yaml @@ -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 diff --git a/backend/configs/config.yaml b/backend/configs/config.yaml index bcee8bb..5c25f0a 100644 --- a/backend/configs/config.yaml +++ b/backend/configs/config.yaml @@ -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分钟后解锁 diff --git a/backend/docs/modules_design/login&auth.md b/backend/docs/modules_design/login&auth.md index 3829a59..bb1c201 100644 --- a/backend/docs/modules_design/login&auth.md +++ b/backend/docs/modules_design/login&auth.md @@ -13,7 +13,7 @@ ## 社区版登录设计 -用户名和密码配置在配置文件中,默认用户名和密码为 `admin` / `admin@123` +用户名和密码硬编码在系统中,默认用户名和密码为 `admin` / `admin@123` ## 功能模块 diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index e8cd597..8070d2f 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -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 -} \ No newline at end of file +} diff --git a/docs/github镜像部署.md b/docs/github镜像部署.md index 210f698..21c84b6 100644 --- a/docs/github镜像部署.md +++ b/docs/github镜像部署.md @@ -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 ## 停止服务