feat: 小程序演示版改造 + 服务端安全加固
- 许愿树移除付费许愿/商品选择/微信支付调用,全部走免费许愿 - 许愿发布前接入微信 msgSecCheck v2 内容安全检测(access_token 内存缓存) - 许愿字数限制改为按字符计算(中文按 1 字计) - 占卜页改名「民俗趣算」并弱化「算命」措辞,占卜/每日运势页加文化声明 - 生产环境 JWT_SECRET 缺失或为默认值/不足 32 位时拒绝启动 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
12fa2b0d19
commit
51d1a1999f
@@ -18,6 +18,14 @@ import (
|
||||
func Bootstrap() *config.Config {
|
||||
_ = godotenv.Load(".env.local", "../.env.local", ".env")
|
||||
cfg := config.Load()
|
||||
|
||||
// 生产环境安全底线:JWT 密钥必须是强随机值
|
||||
if cfg.Server.Env == "production" {
|
||||
if cfg.JWT.Secret == "" || cfg.JWT.Secret == "your-secret-key" || len(cfg.JWT.Secret) < 32 {
|
||||
log.Fatal("JWT_SECRET 未配置或过短:生产环境必须设置至少 32 位的强随机密钥")
|
||||
}
|
||||
}
|
||||
|
||||
if err := config.InitDB(cfg); err != nil {
|
||||
log.Fatalf("Failed to initialize database: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user