Skip to content

Commit 6896882

Browse files
API: set data protection storage location
1 parent 5157a89 commit 6896882

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/Certify.Server/Certify.Server.Core/Certify.Server.Core/Startup.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Text;
22
using Certify.Management;
3+
using Certify.Models;
4+
using Microsoft.AspNetCore.DataProtection;
35
using Microsoft.AspNetCore.ResponseCompression;
46
using Microsoft.AspNetCore.SignalR;
57
using Microsoft.OpenApi.Models;
@@ -24,10 +26,15 @@ public void ConfigureServices(IServiceCollection services)
2426
.AddSignalR()
2527
.AddMessagePackProtocol();
2628

27-
services.AddDataProtection(a =>
28-
{
29-
a.ApplicationDiscriminator = "certify";
30-
});
29+
var appDataPath = EnvironmentUtil.CreateAppDataPath("keys");
30+
31+
services
32+
.AddDataProtection(a =>
33+
{
34+
a.ApplicationDiscriminator = "certify";
35+
})
36+
.PersistKeysToFileSystem(new DirectoryInfo(appDataPath));
37+
3138
services.AddResponseCompression(opts =>
3239
{
3340
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "application/octet-stream", "application/json" });

src/Certify.Server/Certify.Server.HubService/Certify.Server.HubService.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
<ItemGroup>
2929
<ProjectReference Include="..\..\Certify.Aspire\Certify.Aspire.ServiceDefaults\Certify.Aspire.ServiceDefaults.csproj" />
30+
<ProjectReference Include="..\..\Certify.Shared\Certify.Shared.Core.csproj" />
3031
<ProjectReference Include="..\Certify.Server.Core\Certify.Server.Core\Certify.Server.Core.csproj">
3132
<PrivateAssets>all</PrivateAssets>
3233
</ProjectReference>

src/Certify.Server/Certify.Server.HubService/Program.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using Certify.Client;
22
using Certify.Management;
3+
using Certify.Models;
34
using Certify.Server.Hub.Api.Middleware;
45
using Certify.Server.Hub.Api.Services;
56
using Certify.Server.Hub.Api.SignalR;
67
using Certify.Server.Hub.Api.SignalR.ManagementHub;
78
using Certify.Server.HubService.Services;
9+
using Microsoft.AspNetCore.DataProtection;
810
using Microsoft.AspNetCore.Mvc.ApplicationParts;
911
using Microsoft.AspNetCore.SignalR;
1012
using Microsoft.AspNetCore.StaticFiles;
@@ -37,6 +39,15 @@
3739
a.ApplicationDiscriminator = "certify";
3840
});
3941

42+
var appDataPath = EnvironmentUtil.CreateAppDataPath("keys");
43+
44+
builder.Services
45+
.AddDataProtection(a =>
46+
{
47+
a.ApplicationDiscriminator = "certify";
48+
})
49+
.PersistKeysToFileSystem(new DirectoryInfo(appDataPath));
50+
4051
builder.Services.AddResponseCompression();
4152

4253
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi

0 commit comments

Comments
 (0)