fix(seed): LDAP 管理密码不再硬编码,改为从 LDAP_ADMIN_PASSWORD 环境变量读取
This commit is contained in:
1 parent
95066083bd
commit
b4521d13a1
1 file changed
+8
-1
@@ -1,6 +1,7 @@
|
||||
package seed
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"ezops/model"
|
||||
@@ -36,9 +37,14 @@ func SeedData(db *gorm.DB) {
|
||||
}
|
||||
|
||||
// 2. 创建默认 LDAP 配置
|
||||
// LDAP 管理密码只从环境变量 LDAP_ADMIN_PASSWORD 读取,不写入代码库
|
||||
var ldapCount int64
|
||||
db.Model(&model.LDAPConfig{}).Count(&ldapCount)
|
||||
if ldapCount == 0 {
|
||||
ldapPassword := os.Getenv("LDAP_ADMIN_PASSWORD")
|
||||
if ldapPassword == "" {
|
||||
zap.L().Info("LDAP_ADMIN_PASSWORD 未设置,跳过 LDAP 默认配置初始化(请在页面手动配置)")
|
||||
} else {
|
||||
port := 389
|
||||
useLDAPS := false
|
||||
searchFilter := "(objectClass=inetOrgPerson)"
|
||||
@@ -48,7 +54,7 @@ func SeedData(db *gorm.DB) {
|
||||
LDAPPort: &port,
|
||||
UseLDAPS: &useLDAPS,
|
||||
AdminDN: "cn=admin,dc=opsx,dc=vip",
|
||||
AdminPassword: "LQl2GX7EEg2N",
|
||||
AdminPassword: ldapPassword,
|
||||
BaseDN: "dc=opsx,dc=vip",
|
||||
SearchFilter: &searchFilter,
|
||||
UserMapping: &userMapping,
|
||||
@@ -59,6 +65,7 @@ func SeedData(db *gorm.DB) {
|
||||
zap.L().Info("seeded default LDAP config (8.217.205.92:389)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 创建默认审批模板(资源申请)
|
||||
var tplCount int64
|
||||
|
||||
Reference in new issue
Block a user