From a81757d94d554ba62dc2477bd13348cf2cab0c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20G=C3=B6pel?= Date: Sun, 26 Jul 2026 22:26:58 +0800 Subject: [PATCH] feat: adopt protected-secret support from marten-configuration --- Directory.Packages.props | 2 +- .../packages.lock.json | 8 ++++---- .../MartenEmailSettingsStore.cs | 15 +++++---------- .../packages.lock.json | 6 +++--- src/AndreGoepel.AppFoundation/packages.lock.json | 8 ++++---- .../packages.lock.json | 8 ++++---- .../packages.lock.json | 10 +++++----- 7 files changed, 26 insertions(+), 31 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 7fd1f8d..922cf50 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -36,7 +36,7 @@ - + diff --git a/src/AndreGoepel.AppFoundation.Hosting/packages.lock.json b/src/AndreGoepel.AppFoundation.Hosting/packages.lock.json index 9bc08d6..f128bb5 100644 --- a/src/AndreGoepel.AppFoundation.Hosting/packages.lock.json +++ b/src/AndreGoepel.AppFoundation.Hosting/packages.lock.json @@ -4,9 +4,9 @@ "net10.0": { "AndreGoepel.Marten.Configuration": { "type": "Direct", - "requested": "[1.0.1, )", - "resolved": "1.0.1", - "contentHash": "K/lZ0YfJ6+9u851HX1o89Y8TPNVwBd8SSqzh9KIWLgYf3/j6w2yL7RTBtAKlPUtTyTTIf2Vuh+Jsz1hREEEyOw==", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "oz/8HU0TJ5efluVfz5d17BESg03G46DqYhuM0GXTuSNgeqxr/k7OYvJZl2pbw4IT8ffuDLj7Mwgo8xjiWJdyZA==", "dependencies": { "Marten": "9.19.0" } @@ -604,7 +604,7 @@ "type": "Project", "dependencies": { "AndreGoepel.Core": "[1.0.0, )", - "AndreGoepel.Marten.Configuration": "[1.0.1, )", + "AndreGoepel.Marten.Configuration": "[1.1.0, )", "MailKit": "[4.17.0, )", "Marten": "[9.19.0, )", "WolverineFx.Marten": "[6.22.0, )" diff --git a/src/AndreGoepel.AppFoundation.MailService/MartenEmailSettingsStore.cs b/src/AndreGoepel.AppFoundation.MailService/MartenEmailSettingsStore.cs index 65ede88..b971b25 100644 --- a/src/AndreGoepel.AppFoundation.MailService/MartenEmailSettingsStore.cs +++ b/src/AndreGoepel.AppFoundation.MailService/MartenEmailSettingsStore.cs @@ -38,16 +38,11 @@ public async Task SaveAsync( var existing = await store.LoadAsync(cancellationToken); var protector = dataProtectionProvider.CreateProtector(ProtectorPurpose); - string protectedPassword; - if (!string.IsNullOrEmpty(newPassword)) - { - protectedPassword = protector.Protect(newPassword); - } - else if (existing is not null) - { - protectedPassword = existing.ProtectedPassword; - } - else + var protectedPassword = protector.ProtectOrKeepExisting( + newPassword, + existing?.ProtectedPassword + ); + if (protectedPassword is null) { return Result.Fail("An SMTP password is required for the first save."); } diff --git a/src/AndreGoepel.AppFoundation.MailService/packages.lock.json b/src/AndreGoepel.AppFoundation.MailService/packages.lock.json index bb347e7..9beae74 100644 --- a/src/AndreGoepel.AppFoundation.MailService/packages.lock.json +++ b/src/AndreGoepel.AppFoundation.MailService/packages.lock.json @@ -10,9 +10,9 @@ }, "AndreGoepel.Marten.Configuration": { "type": "Direct", - "requested": "[1.0.1, )", - "resolved": "1.0.1", - "contentHash": "K/lZ0YfJ6+9u851HX1o89Y8TPNVwBd8SSqzh9KIWLgYf3/j6w2yL7RTBtAKlPUtTyTTIf2Vuh+Jsz1hREEEyOw==", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "oz/8HU0TJ5efluVfz5d17BESg03G46DqYhuM0GXTuSNgeqxr/k7OYvJZl2pbw4IT8ffuDLj7Mwgo8xjiWJdyZA==", "dependencies": { "Marten": "9.19.0" } diff --git a/src/AndreGoepel.AppFoundation/packages.lock.json b/src/AndreGoepel.AppFoundation/packages.lock.json index 1fd7aa5..1ed9741 100644 --- a/src/AndreGoepel.AppFoundation/packages.lock.json +++ b/src/AndreGoepel.AppFoundation/packages.lock.json @@ -274,7 +274,7 @@ "type": "Project", "dependencies": { "AndreGoepel.Core": "[1.0.0, )", - "AndreGoepel.Marten.Configuration": "[1.0.1, )", + "AndreGoepel.Marten.Configuration": "[1.1.0, )", "MailKit": "[4.17.0, )", "Marten": "[9.19.0, )", "WolverineFx.Marten": "[6.22.0, )" @@ -288,9 +288,9 @@ }, "AndreGoepel.Marten.Configuration": { "type": "CentralTransitive", - "requested": "[1.0.1, )", - "resolved": "1.0.1", - "contentHash": "K/lZ0YfJ6+9u851HX1o89Y8TPNVwBd8SSqzh9KIWLgYf3/j6w2yL7RTBtAKlPUtTyTTIf2Vuh+Jsz1hREEEyOw==", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "oz/8HU0TJ5efluVfz5d17BESg03G46DqYhuM0GXTuSNgeqxr/k7OYvJZl2pbw4IT8ffuDLj7Mwgo8xjiWJdyZA==", "dependencies": { "Marten": "9.19.0" } diff --git a/tests/AndreGoepel.AppFoundation.MailService.Tests/packages.lock.json b/tests/AndreGoepel.AppFoundation.MailService.Tests/packages.lock.json index 5ae82ec..abe6f55 100644 --- a/tests/AndreGoepel.AppFoundation.MailService.Tests/packages.lock.json +++ b/tests/AndreGoepel.AppFoundation.MailService.Tests/packages.lock.json @@ -363,7 +363,7 @@ "type": "Project", "dependencies": { "AndreGoepel.Core": "[1.0.0, )", - "AndreGoepel.Marten.Configuration": "[1.0.1, )", + "AndreGoepel.Marten.Configuration": "[1.1.0, )", "MailKit": "[4.17.0, )", "Marten": "[9.19.0, )", "WolverineFx.Marten": "[6.22.0, )" @@ -377,9 +377,9 @@ }, "AndreGoepel.Marten.Configuration": { "type": "CentralTransitive", - "requested": "[1.0.1, )", - "resolved": "1.0.1", - "contentHash": "K/lZ0YfJ6+9u851HX1o89Y8TPNVwBd8SSqzh9KIWLgYf3/j6w2yL7RTBtAKlPUtTyTTIf2Vuh+Jsz1hREEEyOw==", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "oz/8HU0TJ5efluVfz5d17BESg03G46DqYhuM0GXTuSNgeqxr/k7OYvJZl2pbw4IT8ffuDLj7Mwgo8xjiWJdyZA==", "dependencies": { "Marten": "9.19.0" } diff --git a/tests/AndreGoepel.AppFoundation.Tests/packages.lock.json b/tests/AndreGoepel.AppFoundation.Tests/packages.lock.json index 6505485..6ea81c9 100644 --- a/tests/AndreGoepel.AppFoundation.Tests/packages.lock.json +++ b/tests/AndreGoepel.AppFoundation.Tests/packages.lock.json @@ -747,7 +747,7 @@ "AndreGoepel.AppFoundation.Core": "[1.8.0, )", "AndreGoepel.AppFoundation.MailService": "[1.9.0, )", "AndreGoepel.AppFoundation.ServiceDefaults": "[1.8.0, )", - "AndreGoepel.Marten.Configuration": "[1.0.1, )", + "AndreGoepel.Marten.Configuration": "[1.1.0, )", "AndreGoepel.Marten.Identity.Blazor": "[1.8.0, )", "Marten": "[9.19.0, )", "Microsoft.AspNetCore.HeaderPropagation": "[10.0.10, )", @@ -763,7 +763,7 @@ "type": "Project", "dependencies": { "AndreGoepel.Core": "[1.0.0, )", - "AndreGoepel.Marten.Configuration": "[1.0.1, )", + "AndreGoepel.Marten.Configuration": "[1.1.0, )", "MailKit": "[4.17.0, )", "Marten": "[9.19.0, )", "WolverineFx.Marten": "[6.22.0, )" @@ -798,9 +798,9 @@ }, "AndreGoepel.Marten.Configuration": { "type": "CentralTransitive", - "requested": "[1.0.1, )", - "resolved": "1.0.1", - "contentHash": "K/lZ0YfJ6+9u851HX1o89Y8TPNVwBd8SSqzh9KIWLgYf3/j6w2yL7RTBtAKlPUtTyTTIf2Vuh+Jsz1hREEEyOw==", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "oz/8HU0TJ5efluVfz5d17BESg03G46DqYhuM0GXTuSNgeqxr/k7OYvJZl2pbw4IT8ffuDLj7Mwgo8xjiWJdyZA==", "dependencies": { "Marten": "9.19.0" }