支持邮件客户端协议授权码持久加密存储与安全解密查看

This commit is contained in:
xuans committed 2026-09-12 14:01:38 +08:00
1 parent 9fb05c75f2
commit 8c94d07df5
10 files changed
+157 -7

No files matched your search

@@ -0,0 +1,19 @@
package migration
import (
"context"
"fmt"
)
func applyProtocolCredentialCiphertextSchema(ctx context.Context, exec executor, dialect Dialect) error {
definitions := map[Dialect]string{
DialectSQLite: "TEXT NULL",
DialectMySQL: "VARCHAR(512) NULL",
DialectPostgres: "VARCHAR(512) NULL",
}
definition, ok := definitions[dialect]
if !ok {
return fmt.Errorf("unsupported migration dialect %q", dialect)
}
return ensureColumn(ctx, exec, dialect, "protocol_credential", "code_ciphertext", definition)
}
+1
View File
@@ -29,6 +29,7 @@ func DefaultMigrations() []Migration {
DefineForDialects(17, "create_managed_logs", logStatements()),
DefineCustom(18, "expand_operation_log_actor_role", "expand_operation_log_actor_role_v1", applyOperationLogActorRoleSchema),
DefineForDialects(19, "create_user_contacts_and_trusted_senders", userContactStatements()),
DefineCustom(20, "expand_protocol_credential_ciphertext", "expand_protocol_credential_ciphertext_v1", applyProtocolCredentialCiphertextSchema),
}
}
+1
View File
@@ -284,6 +284,7 @@ func TestDefaultMigrationChecksumsAreImmutable(t *testing.T) {
17: "1dad66acb5e7fecf6c39f4a78526b994748d90045220f446a2e80c1b5fd881e7",
18: "17622df3406657f199d78a3a1aa1f3a8693baf85aa7707910cc6d6cb44c13ee4",
19: "f24b94ca9e4c25b7973f6c15fcaddccc7f02bcf7886c0a4995d2f7b79f4a3a16",
20: "e0bc01f4c2df742bc23c519c2a399cc1c3f341565dbed014509a8c63d68bf725",
}
migrations := DefaultMigrations()
if len(migrations) != len(expected) {