This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
namespace LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Postgres;
|
||||
|
||||
namespace LiteCharms.Features.Extensions;
|
||||
|
||||
public static class Postgres
|
||||
{
|
||||
public const string SchedulerDbConfigName = "PostgresScheduler";
|
||||
public const string SchedulerDbConfigName = "PostgresScheduler";
|
||||
public const string DataProtectionDbConfigName = "PostgresDataProtection";
|
||||
|
||||
public static IServiceCollection AddDataProtectionDatabase(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var connectionString = configuration.GetConnectionString(DataProtectionDbConfigName);
|
||||
|
||||
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connectionString);
|
||||
|
||||
dataSourceBuilder.ConfigureTypeLoading(options => { options.EnableTypeLoading(false); });
|
||||
|
||||
var dataSource = dataSourceBuilder.Build();
|
||||
|
||||
services.AddSingleton(dataSource);
|
||||
|
||||
services.AddPooledDbContextFactory<DataProtectionDbContext>(options =>
|
||||
options.UseNpgsql(dataSource));
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user