Added data protection database based support
continuous-integration/drone/pr Build is passing

This commit is contained in:
Khwezi Mngoma
2026-06-14 09:57:24 +02:00
parent 9099610185
commit 4e9e428ab5
8 changed files with 196 additions and 15 deletions
+4 -13
View File
@@ -2,6 +2,7 @@
using LiteCharms.Features.Api;
using LiteCharms.Features.Api.Configuration;
using LiteCharms.Features.Api.Sdk;
using LiteCharms.Features.Postgres;
using Microsoft.AspNetCore.Hosting;
using System.Runtime.InteropServices;
@@ -53,20 +54,10 @@ public static class Api
return services;
}
public static IServiceCollection AddLiteCharmsWebSecurity(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment environment)
public static IServiceCollection AddLiteCharmsWebSecurity(this IServiceCollection services, IConfiguration configuration)
{
string keysFolderPath;
if (OperatingSystem.IsLinux())
keysFolderPath = "/app/shared-keys";
else
keysFolderPath = Path.Combine(environment.ContentRootPath, "obj", "DeveloperDataProtectionKeys");
if (!Directory.Exists(keysFolderPath)) Directory.CreateDirectory(keysFolderPath);
services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(keysFolderPath))
.SetApplicationName("MidrandBookshop");
services.AddDataProtection().PersistKeysToDbContext<DataProtectionDbContext>()
.SetApplicationName("LiteCharmsApp");
var configSection = configuration.GetSection(nameof(LiteCharmsSettings));