chore(payment): mark legacy AES ciphertext fallback as deprecated
明文 JSON 已经是新写入的默认格式;保留 AES 密文读取仅为兼容迁移期间的旧 记录,一旦所有部署通过管理后台重存过一次即可删除。标记为 deprecated 并加 TODO,几个版本后统一清理掉:payment.Encrypt / payment.Decrypt、两处 decryptConfig 的 AES 分支、PaymentConfigService.encryptionKey 和 DefaultLoadBalancer.encryptionKey 字段。
This commit is contained in:
@@ -296,6 +296,10 @@ func (s *PaymentConfigService) mergeConfig(ctx context.Context, id int64, newCon
|
||||
// ("iv:authTag:ciphertext"). Values that cannot be parsed as either — including
|
||||
// legacy ciphertext with no/invalid TOTP_ENCRYPTION_KEY — are treated as empty,
|
||||
// letting the admin re-enter the config via the UI to complete the migration.
|
||||
//
|
||||
// TODO(deprecated-legacy-ciphertext): The AES fallback branch is a transitional
|
||||
// shim for pre-plaintext records. Remove it (and the encryptionKey field) after
|
||||
// a few releases once all live deployments have re-saved their provider configs.
|
||||
func (s *PaymentConfigService) decryptConfig(stored string) (map[string]string, error) {
|
||||
if stored == "" {
|
||||
return nil, nil
|
||||
@@ -304,7 +308,9 @@ func (s *PaymentConfigService) decryptConfig(stored string) (map[string]string,
|
||||
if err := json.Unmarshal([]byte(stored), &cfg); err == nil {
|
||||
return cfg, nil
|
||||
}
|
||||
// Deprecated: legacy AES-256-GCM ciphertext fallback — scheduled for removal.
|
||||
if len(s.encryptionKey) == payment.AES256KeySize {
|
||||
//nolint:staticcheck // SA1019: intentional legacy fallback, scheduled for removal
|
||||
if plaintext, err := payment.Decrypt(stored, s.encryptionKey); err == nil {
|
||||
if err := json.Unmarshal([]byte(plaintext), &cfg); err == nil {
|
||||
return cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user