Skip to content

Commit

Permalink
fix: forgery warnng (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybeeelsdon authored Dec 3, 2024
1 parent afc02a9 commit bf21975
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/DARE-API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using NETCore.MailKit.Extensions;
using NETCore.MailKit.Infrastructure.Internal;
using BL.Models;
using Microsoft.AspNetCore.DataProtection;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -49,6 +50,9 @@
{
Log.Warning("{Function} Disabling Anti Forgery token. Only do if testing", "Main");
builder.Services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo("/root/.aspnet/DataProtection-Keys"))
.DisableAutomaticKeyGeneration();
}
//Add Services
AddServices(builder);
Expand Down
6 changes: 5 additions & 1 deletion src/DARE-FrontEnd/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Newtonsoft.Json;
using DARE_FrontEnd.Models;
using DARE_FrontEnd.Services;
using Microsoft.AspNetCore.DataProtection;

var builder = WebApplication.CreateBuilder(args);
IdentityModelEventSource.ShowPII = true;
Expand Down Expand Up @@ -67,7 +68,10 @@
{
Log.Warning("{Function} Disabling Anti Forgery token. Only do if testing", "Main");
builder.Services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
}
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo("/root/.aspnet/DataProtection-Keys"))
.DisableAutomaticKeyGeneration();
}

//add services here
builder.Services.AddScoped<CustomCookieEvent>();
Expand Down
4 changes: 4 additions & 0 deletions src/Data-Egress-API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using NETCore.MailKit.Extensions;
using NETCore.MailKit.Infrastructure.Internal;
using BL.Models;
using Microsoft.AspNetCore.DataProtection;

var builder = WebApplication.CreateBuilder(args);
ConfigurationManager configuration = builder.Configuration;
Expand All @@ -30,6 +31,9 @@
{
Log.Warning("{Function} Disabling Anti Forgery token. Only do if testing", "Main");
builder.Services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo("/root/.aspnet/DataProtection-Keys"))
.DisableAutomaticKeyGeneration();
}
// Add services to the container.

Expand Down
4 changes: 4 additions & 0 deletions src/Data-Egress-UI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using BL.Models;
using Microsoft.AspNetCore.DataProtection;

var builder = WebApplication.CreateBuilder(args);
ConfigurationManager configuration = builder.Configuration;
Expand All @@ -27,6 +28,9 @@
{
Log.Warning("{Function} Disabling Anti Forgery token. Only do if testing", "Main");
builder.Services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo("/root/.aspnet/DataProtection-Keys"))
.DisableAutomaticKeyGeneration();
}
IdentityModelEventSource.ShowPII = true;

Expand Down
4 changes: 4 additions & 0 deletions src/TRE-API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using TRE_API.Models;
using TREAPI.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -40,6 +41,9 @@
{
Log.Warning("{Function} Disabling Anti Forgery token. Only do if testing", "Main");
builder.Services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo("/root/.aspnet/DataProtection-Keys"))
.DisableAutomaticKeyGeneration();
}

// Add services to the container.
Expand Down
4 changes: 4 additions & 0 deletions src/TRE-UI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Microsoft.AspNetCore.CookiePolicy;
using Microsoft.AspNetCore.DataProtection;

var builder = WebApplication.CreateBuilder(args);
ConfigurationManager configuration = builder.Configuration;
Expand All @@ -27,6 +28,9 @@
{
Log.Warning("{Function} Disabling Anti Forgery token. Only do if testing", "Main");
builder.Services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo("/root/.aspnet/DataProtection-Keys"))
.DisableAutomaticKeyGeneration();
}
//builder.Host.UseSerilog();
IdentityModelEventSource.ShowPII = true;
Expand Down

0 comments on commit bf21975

Please sign in to comment.