Skip to content

Commit

Permalink
API: set data protection storage location
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Mar 6, 2025
1 parent 5157a89 commit 6896882
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Text;
using Certify.Management;
using Certify.Models;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Models;
Expand All @@ -24,10 +26,15 @@ public void ConfigureServices(IServiceCollection services)
.AddSignalR()
.AddMessagePackProtocol();

services.AddDataProtection(a =>
{
a.ApplicationDiscriminator = "certify";
});
var appDataPath = EnvironmentUtil.CreateAppDataPath("keys");

services
.AddDataProtection(a =>
{
a.ApplicationDiscriminator = "certify";
})
.PersistKeysToFileSystem(new DirectoryInfo(appDataPath));

services.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "application/octet-stream", "application/json" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<ItemGroup>
<ProjectReference Include="..\..\Certify.Aspire\Certify.Aspire.ServiceDefaults\Certify.Aspire.ServiceDefaults.csproj" />
<ProjectReference Include="..\..\Certify.Shared\Certify.Shared.Core.csproj" />
<ProjectReference Include="..\Certify.Server.Core\Certify.Server.Core\Certify.Server.Core.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
Expand Down
11 changes: 11 additions & 0 deletions src/Certify.Server/Certify.Server.HubService/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Certify.Client;
using Certify.Management;
using Certify.Models;
using Certify.Server.Hub.Api.Middleware;
using Certify.Server.Hub.Api.Services;
using Certify.Server.Hub.Api.SignalR;
using Certify.Server.Hub.Api.SignalR.ManagementHub;
using Certify.Server.HubService.Services;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.StaticFiles;
Expand Down Expand Up @@ -37,6 +39,15 @@
a.ApplicationDiscriminator = "certify";
});

var appDataPath = EnvironmentUtil.CreateAppDataPath("keys");

builder.Services
.AddDataProtection(a =>
{
a.ApplicationDiscriminator = "certify";
})
.PersistKeysToFileSystem(new DirectoryInfo(appDataPath));

builder.Services.AddResponseCompression();

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

0 comments on commit 6896882

Please sign in to comment.