fix: 按评审报告止血支付漏洞并加固授权链路

废除浏览器回跳自助结算,通用 webhook 强制密钥鉴权,Waffo 支持验签与未知事件忽略;重构订单状态机/激活占座/SQLite WAL,并补备份、readyz、限流与前端导出/登录页安全修复。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Logan.LiandCursor committed 2026-08-12 21:26:58 +08:00
1 parent 8cc2c83f9d
commit bac72e6945
24 files changed
+682 -391

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ type Customer struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"size:100;not null"`
Company string `json:"company" gorm:"size:200"`
Email string `json:"email" gorm:"size:100;index"`
Email string `json:"email" gorm:"size:100;uniqueIndex"`
Phone string `json:"phone" gorm:"size:20"`
Address string `json:"address" gorm:"size:500"`
Notes string `json:"notes" gorm:"type:text"`
+4 -4
View File
@@ -5,16 +5,16 @@ import "time"
// CustomerEntitlement 客户权益记录(防重复购买的核心表) // Logan.Li
type CustomerEntitlement struct {
ID uint `json:"id" gorm:"primaryKey"`
CustomerID uint `json:"customer_id"`
CustomerID uint `json:"customer_id" gorm:"uniqueIndex:idx_ent_cust_prod,priority:1"`
Customer Customer `json:"customer,omitempty" gorm:"foreignKey:CustomerID"`
ProductID uint `json:"product_id"`
ProductID uint `json:"product_id" gorm:"uniqueIndex:idx_ent_cust_prod,priority:2"`
Product Product `json:"product,omitempty" gorm:"foreignKey:ProductID"`
PlanID uint `json:"plan_id"`
Plan Plan `json:"plan,omitempty" gorm:"foreignKey:PlanID"`
LicenseID uint `json:"license_id"`
LicenseKey string `json:"license_key" gorm:"size:100"`
PlanType string `json:"plan_type" gorm:"size:50"` // perpetual / monthly / yearly / lifetime
Status string `json:"status" gorm:"size:20;default:'active'"` // active / expired / revoked
PlanType string `json:"plan_type" gorm:"size:50"` // perpetual / monthly / yearly / lifetime
Status string `json:"status" gorm:"size:20;default:'active'"` // active / expired / revoked
ValidFrom time.Time `json:"valid_from"`
ValidUntil *time.Time `json:"valid_until,omitempty"` // 买断/永久为 null
Renewable bool `json:"renewable" gorm:"default:true"` // 订阅到期后是否可续费
+2 -2
View File
@@ -62,9 +62,9 @@ func (License) TableName() string {
// Activation 激活记录模型(机器绑定) // Logan.Li
type Activation struct {
ID uint `json:"id" gorm:"primaryKey"`
LicenseID uint `json:"license_id"`
LicenseID uint `json:"license_id" gorm:"uniqueIndex:idx_lic_device,priority:1"`
License License `json:"license,omitempty" gorm:"foreignKey:LicenseID"`
DeviceID string `json:"device_id" gorm:"size:100"`
DeviceID string `json:"device_id" gorm:"size:100;uniqueIndex:idx_lic_device,priority:2"`
DeviceName string `json:"device_name" gorm:"size:200"`
DeviceInfo string `json:"device_info" gorm:"type:text"` // JSON 格式存储设备信息
IP string `json:"ip" gorm:"size:50"`
+1 -1
View File
@@ -18,7 +18,7 @@ type Order struct {
Status string `json:"status" gorm:"size:20;default:'pending'"` // pending / paid / failed / refunded / cancelled
PaymentMethod string `json:"payment_method" gorm:"size:50"` // paddle / stripe / creem / waffo / alipay / wechat
PaymentGateway string `json:"payment_gateway" gorm:"size:50"`
GatewayOrderNo string `json:"gateway_order_no" gorm:"size:200"`
GatewayOrderNo string `json:"gateway_order_no" gorm:"size:200;index"`
PaidAt *time.Time `json:"paid_at,omitempty"`
RefundAt *time.Time `json:"refund_at,omitempty"`
ClientIP string `json:"client_ip" gorm:"size:50"`