fix: harden cloud storage security
This commit is contained in:
30
install.sh
30
install.sh
@@ -2033,10 +2033,18 @@ configure_admin_account() {
|
||||
done
|
||||
|
||||
while true; do
|
||||
read -s -p "管理员密码(至少6位): " ADMIN_PASSWORD < /dev/tty
|
||||
read -s -p "管理员密码(至少8位,且至少包含字母/数字/特殊字符中的两类): " ADMIN_PASSWORD < /dev/tty
|
||||
echo ""
|
||||
if [[ ${#ADMIN_PASSWORD} -lt 6 ]]; then
|
||||
print_error "密码至少6个字符"
|
||||
if [[ ${#ADMIN_PASSWORD} -lt 8 ]]; then
|
||||
print_error "密码至少8个字符"
|
||||
continue
|
||||
fi
|
||||
local type_count=0
|
||||
[[ "$ADMIN_PASSWORD" =~ [A-Za-z] ]] && ((type_count++))
|
||||
[[ "$ADMIN_PASSWORD" =~ [0-9] ]] && ((type_count++))
|
||||
[[ "$ADMIN_PASSWORD" =~ [^A-Za-z0-9] ]] && ((type_count++))
|
||||
if [[ ${type_count} -lt 2 ]]; then
|
||||
print_error "密码必须包含字母、数字、特殊字符中的至少两种"
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -2111,9 +2119,6 @@ create_env_file() {
|
||||
# 生成随机JWT密钥
|
||||
JWT_SECRET=$(openssl rand -base64 32)
|
||||
|
||||
# 生成随机Session密钥
|
||||
SESSION_SECRET=$(openssl rand -hex 32)
|
||||
|
||||
# 生成随机加密密钥(用于加密OSS等敏感信息)
|
||||
ENCRYPTION_KEY=$(openssl rand -hex 32)
|
||||
|
||||
@@ -2162,9 +2167,6 @@ ADMIN_PASSWORD=${ADMIN_PASSWORD}
|
||||
# JWT密钥
|
||||
JWT_SECRET=${JWT_SECRET}
|
||||
|
||||
# Session密钥(用于会话管理)
|
||||
SESSION_SECRET=${SESSION_SECRET}
|
||||
|
||||
# 加密密钥(用于加密OSS Access Key Secret等敏感信息)
|
||||
# 重要:此密钥必须配置,否则服务无法启动
|
||||
ENCRYPTION_KEY=${ENCRYPTION_KEY}
|
||||
@@ -3730,16 +3732,6 @@ update_patch_env() {
|
||||
print_info ".env 已包含 TRUST_PROXY,保持不变"
|
||||
fi
|
||||
|
||||
# 检查 SESSION_SECRET(会话安全配置,生产环境必需)
|
||||
if ! grep -q "^SESSION_SECRET=" "${PROJECT_DIR}/backend/.env"; then
|
||||
# 自动生成随机 Session 密钥
|
||||
NEW_SESSION_SECRET=$(openssl rand -hex 32)
|
||||
echo "SESSION_SECRET=${NEW_SESSION_SECRET}" >> "${PROJECT_DIR}/backend/.env"
|
||||
print_warning "已为现有 .env 补充 SESSION_SECRET(已自动生成安全密钥)"
|
||||
else
|
||||
print_info ".env 已包含 SESSION_SECRET,保持不变"
|
||||
fi
|
||||
|
||||
# 检查 ENCRYPTION_KEY(加密密钥,用于加密OSS等敏感信息,必需)
|
||||
if ! grep -q "^ENCRYPTION_KEY=" "${PROJECT_DIR}/backend/.env"; then
|
||||
# 自动生成随机加密密钥
|
||||
|
||||
Reference in New Issue
Block a user