fix: 按评审报告止血支付漏洞并加固授权链路
废除浏览器回跳自助结算,通用 webhook 强制密钥鉴权,Waffo 支持验签与未知事件忽略;重构订单状态机/激活占座/SQLite WAL,并补备份、readyz、限流与前端导出/登录页安全修复。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8cc2c83f9d
commit
bac72e6945
24 files changed
+682
-391
No files matched your search
@@ -2,12 +2,10 @@ package utils
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -38,20 +36,15 @@ type OfflineKeyPair struct {
|
||||
Public ed25519.PublicKey
|
||||
}
|
||||
|
||||
// DeriveOfflineKeyPair 从 32 字节 seed(hex)派生 Ed25519 密钥对 // Logan.Li
|
||||
// DeriveOfflineKeyPair 从 32 字节 seed(必须 64 位 hex)派生 Ed25519 密钥对 // Logan.Li
|
||||
func DeriveOfflineKeyPair(seedHex string) (*OfflineKeyPair, error) {
|
||||
seedHex = strings.TrimSpace(seedHex)
|
||||
if seedHex == "" {
|
||||
return nil, errors.New("离线签发 seed 为空")
|
||||
}
|
||||
raw, err := hex.DecodeString(seedHex)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("离线签发 seed 不是合法 hex: %w", err)
|
||||
}
|
||||
if len(raw) != ed25519.SeedSize {
|
||||
// 允许任意长度输入,统一 hash 成 32 字节 // Logan.Li
|
||||
sum := sha256.Sum256(raw)
|
||||
raw = sum[:]
|
||||
if err != nil || len(raw) != ed25519.SeedSize {
|
||||
return nil, errors.New("OFFLINE_LICENSE_SEED 必须是 64 位 hex(32 字节),请用 openssl rand -hex 32 生成")
|
||||
}
|
||||
priv := ed25519.NewKeyFromSeed(raw)
|
||||
pub := priv.Public().(ed25519.PublicKey)
|
||||
|
||||
Reference in new issue
Block a user