Skip to content

Commit

Permalink
Add data protection when necessary for multiple nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffputz committed Jul 8, 2024
1 parent 08dec8a commit 85a2366
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PopForums.Web/PopForums.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.3.4" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/PopForums.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.ResponseCompression;
using System.IO.Compression;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;

// the following block is for use when you have multiple nodes running
// (think Azure App Services) so they can all decode the auth cookie
var configuration = builder.Configuration;
if (configuration["DataProtectBlobConnectionString"] != null)
{
services.AddDataProtection()
.SetApplicationName("popforumsdev")
.PersistKeysToAzureBlobStorage(configuration["DataProtectBlobConnectionString"], "keys", "antiforge");
}

services.AddControllersWithViews();
services.AddRazorPages();

Expand Down

0 comments on commit 85a2366

Please sign in to comment.