Files
vue-driven-cloud-storage/backend/.env.example
喻勇祥 a953bda39a 安全: 修复JWT密钥使用默认值的安全隐患
问题描述:
- JWT_SECRET使用硬编码默认值,存在严重安全风险
- 生产环境token可被轻易伪造

修复内容:
1. 在auth.js中添加JWT密钥安全检查
   - 检测默认密钥并发出警告
   - 生产环境强制要求设置JWT_SECRET
2. 更新.env.example添加JWT_SECRET配置说明
   - 提供密钥生成方法
   - 添加其他安全配置项
3. 优化deploy.sh部署脚本
   - 自动生成随机JWT密钥
   - 检测并替换默认密钥

影响范围: 安全认证模块

测试建议:
- 启动服务验证JWT_SECRET警告正常显示
- 使用deploy.sh部署验证自动生成密钥

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 13:17:57 +08:00

29 lines
823 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 服务器配置
PORT=40001
NODE_ENV=production
# JWT安全密钥 (必须设置!使用随机字符串)
# 生成方法: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
JWT_SECRET=your-secret-key-change-in-production-PLEASE-CHANGE-THIS
# 管理员账号配置
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123
# 存储根目录(本地存储模式)
STORAGE_ROOT=/app/storage
# CORS允许的来源多个用逗号分隔* 表示允许所有)
# 生产环境建议设置为具体域名,例如: https://yourdomain.com,https://www.yourdomain.com
ALLOWED_ORIGINS=*
# Cookie安全配置
# 如果使用HTTPS设置为true
COOKIE_SECURE=false
# FTP服务器配置可选用户可在界面配置
FTP_HOST=your-ftp-host.com
FTP_PORT=21
FTP_USER=your-username
FTP_PASSWORD=your-password