Compare commits
6
Commits
1.124.0
...
92c60e6616
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92c60e6616 | ||
|
|
9099610185 | ||
|
|
21788c66a3 | ||
|
|
dfaa62ea75 | ||
|
|
54ef7a6e5f | ||
|
|
0ec7ef4861 |
@@ -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();
|
||||
@@ -77,6 +92,8 @@ public static class Api
|
||||
options.SaveTokens = true;
|
||||
options.GetClaimsFromUserInfoEndpoint = true;
|
||||
|
||||
options.ForwardSignOut = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||
|
||||
options.Scope.Clear();
|
||||
options.Scope.Add("openid");
|
||||
options.Scope.Add("profile");
|
||||
@@ -159,7 +176,6 @@ public static class Api
|
||||
authProperties.Parameters.Add("id_token_hint", idToken);
|
||||
|
||||
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, authProperties);
|
||||
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
});
|
||||
|
||||
return app;
|
||||
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user