Skip to content

Commit

Permalink
more forwarded headers config
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgriff committed Jan 17, 2025
1 parent ff7638f commit ea117ec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions GenderPayGap.WebUI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using GenderPayGap.WebUI.Search;
using GenderPayGap.WebUI.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
Expand Down Expand Up @@ -130,6 +131,13 @@ private static void ConfigureServices(IServiceCollection services)
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
options.JsonSerializerOptions.PropertyNamingPolicy = null;
});

// Configure forwarded headers - this is so that the anti-forgery middleware (see below) is allowed to set a "Secure only" cookie
services.Configure<ForwardedHeadersOptions>(
options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});

// Add anti-forgery token by default to forms making sure the Secure flag is always set
services.AddAntiforgery(
Expand Down

0 comments on commit ea117ec

Please sign in to comment.