Compare commits

...

4 Commits

2 changed files with 17 additions and 1 deletions
+16 -1
View File
@@ -2,6 +2,8 @@
using LiteCharms.Features.Api;
using LiteCharms.Features.Api.Configuration;
using LiteCharms.Features.Api.Sdk;
using Microsoft.AspNetCore.Hosting;
using System.Runtime.InteropServices;
namespace LiteCharms.Features.Extensions;
@@ -51,8 +53,21 @@ public static class Api
return services;
}
public static IServiceCollection AddLiteCharmsWebSecurity(this IServiceCollection services, IConfiguration configuration)
public static IServiceCollection AddLiteCharmsWebSecurity(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment environment)
{
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");
var configSection = configuration.GetSection(nameof(LiteCharmsSettings));
var authOptions = new LiteCharmsSettings();
@@ -194,6 +194,7 @@
<!-- Shared Usings -->
<ItemGroup>
<Using Include="Microsoft.AspNetCore.DataProtection" />
<Using Include="Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage" />
<Using Include="System.Text.Json.Serialization" />
<Using Include="System.Reflection" />