From 6c4eb1db4dc7bba97d0e93f463a4c4434d31d134 Mon Sep 17 00:00:00 2001 From: Trojaner Date: Thu, 8 Oct 2020 16:45:17 +0300 Subject: [PATCH] Add forwarded headers options --- src/Startup.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Startup.cs b/src/Startup.cs index 0f8dfef..7a98d35 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using IdentityServer4.Services; +using Microsoft.AspNetCore.HttpOverrides; using SteamOpenIdConnectProvider.Database; using SteamOpenIdConnectProvider.Profile; @@ -97,6 +98,16 @@ namespace SteamOpenIdConnectProvider await next(); }); + var forwardOptions = new ForwardedHeadersOptions + { + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto, + RequireHeaderSymmetry = false + }; + + forwardOptions.KnownNetworks.Clear(); + forwardOptions.KnownProxies.Clear(); + + app.UseForwardedHeaders(forwardOptions); app.UseRouting(); app.UseIdentityServer(); app.UseEndpoints(endpoints =>