Merge pull request 'Added certificate protected data protection keys' (#124) from dataprotection into master

Reviewed-on: #124
This commit was merged in pull request #124.
This commit is contained in:
2026-06-14 11:27:32 +02:00
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -5,6 +5,7 @@ using LiteCharms.Features.Api.Sdk;
using LiteCharms.Features.Postgres;
using Microsoft.AspNetCore.Hosting;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
namespace LiteCharms.Features.Extensions;
@@ -56,7 +57,10 @@ public static class Api
public static IServiceCollection AddLiteCharmsWebSecurity(this IServiceCollection services, IConfiguration configuration)
{
var certificate = X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(configuration["DataProtection:Certificate"]!), configuration["DataProtection:Password"]);
services.AddDataProtection().PersistKeysToDbContext<DataProtectionDbContext>()
.ProtectKeysWithCertificate(certificate)
.SetApplicationName("LiteCharmsApp");
var configSection = configuration.GetSection(nameof(LiteCharmsSettings));
+1 -1
View File
@@ -9,7 +9,7 @@ public static class Postgres
public static IServiceCollection AddDataProtectionDatabase(this IServiceCollection services, IConfiguration configuration)
{
var connectionString = configuration.GetConnectionString(DataProtectionDbConfigName);
var connectionString = configuration.GetConnectionString(DataProtectionDbConfigName);
services.AddPooledDbContextFactory<DataProtectionDbContext>(options =>
options.UseNpgsql(connectionString));