feat(settings): 运行配置中心——.env 业务参数统一到后台页面维护
CI / backend (push) Canceled after 0s

- 新增 app_configs 表与 appconfig 注册表:读取优先级 页面 → .env → 默认,删除即回退
- 页面可配 7 项:支付回调基址、成功回跳、Webhook 密钥(加密入库)、未验签放行开关、CORS、可信代理、GeoIP 路径
- 引导密钥(JWT_SECRET / OPSLIC_MASTER_KEY / OFFLINE_LICENSE_SEED)与部署参数只读展示掩码+指纹,永不入库
- 校验:URL 格式、密钥长度≥16、CIDR、release 下禁止开启未验签回调;变更写审计日志
- 消费点改造:支付回调地址、Waffo 回跳、webhook 验签、可信代理、CORS、GeoIP 统一走配置中心
- 前端新增「审计与设置 → 运行配置」页(分组表格 + 来源标记 + 编辑弹窗 + 恢复默认)
- .env.example 补注释:哪些必须留在 .env、哪些已收敛到页面
This commit is contained in:
Logan.Li committed 2026-11-01 06:17:58 +08:00
1 parent b0b611eee2
commit 83a3630404
17 files changed
+1204 -33

No files matched your search

+17 -16
View File
@@ -8,6 +8,7 @@ import (
"strings"
"backend/internal/model"
"backend/internal/service/appconfig"
"gorm.io/gorm"
)
@@ -42,21 +43,21 @@ type WaffoProductMapping struct {
// WaffoPublicMeta 存入 payment_gateway_configs.public_key 的 JSON(无私钥) // Logan.Li
type WaffoPublicMeta struct {
MerchantID string `json:"merchant_id"`
StoreID string `json:"store_id"`
StoreSlug string `json:"store_slug"`
ProductID string `json:"product_id"`
ProductIDYearly string `json:"product_id_yearly"`
ProductIDPerpetual string `json:"product_id_perpetual"`
ProductIDs map[string]string `json:"product_ids,omitempty"` // 可扩展映射,兼容旧字段 // Logan.Li
ProductMappings []WaffoProductMapping `json:"product_mappings,omitempty"` // 前端表格(含 label) // Logan.Li
EnvProfiles map[string]WaffoEnvProfile `json:"env_profiles,omitempty"` // test/live 隔离映射 // Logan.Li
SuccessURL string `json:"success_url"`
Currency string `json:"currency"`
CurrencyYearly string `json:"currency_yearly"`
CurrencyPerpetual string `json:"currency_perpetual"`
Environment string `json:"environment"`
CheckoutURL string `json:"checkout_url"`
MerchantID string `json:"merchant_id"`
StoreID string `json:"store_id"`
StoreSlug string `json:"store_slug"`
ProductID string `json:"product_id"`
ProductIDYearly string `json:"product_id_yearly"`
ProductIDPerpetual string `json:"product_id_perpetual"`
ProductIDs map[string]string `json:"product_ids,omitempty"` // 可扩展映射,兼容旧字段 // Logan.Li
ProductMappings []WaffoProductMapping `json:"product_mappings,omitempty"` // 前端表格(含 label) // Logan.Li
EnvProfiles map[string]WaffoEnvProfile `json:"env_profiles,omitempty"` // test/live 隔离映射 // Logan.Li
SuccessURL string `json:"success_url"`
Currency string `json:"currency"`
CurrencyYearly string `json:"currency_yearly"`
CurrencyPerpetual string `json:"currency_perpetual"`
Environment string `json:"environment"`
CheckoutURL string `json:"checkout_url"`
}
// DefaultWebhookURL 对外 Webhook 地址(只读提示) // Logan.Li
@@ -85,7 +86,7 @@ func loadWaffoFromEnv() WaffoConfig {
if env == "" {
env = "test"
}
success := strings.TrimSpace(os.Getenv("SUCCESS_URL"))
success := strings.TrimSpace(appconfig.String("SUCCESS_URL"))
if success == "" {
success = DefaultSuccessURL
}