From 0b17f3823ae78023f5f457931fc0b6cb7cbddf14 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 21 Feb 2018 21:43:02 -0500 Subject: [PATCH] Just use HttpContext RemoteIpAddress to get IP --- src/Core/CurrentContext.cs | 5 ----- src/Core/Utilities/ServiceCollectionExtensions.cs | 14 -------------- 2 files changed, 19 deletions(-) diff --git a/src/Core/CurrentContext.cs b/src/Core/CurrentContext.cs index 548d57ac1..6391b5cb6 100644 --- a/src/Core/CurrentContext.cs +++ b/src/Core/CurrentContext.cs @@ -47,11 +47,6 @@ namespace Bit.Core return null; } - if(HttpContext.Request?.Headers?.TryGetValue("X-Forwarded-For", out StringValues forwardHeader) ?? false) - { - _ip = forwardHeader.FirstOrDefault()?.Trim(); - } - if(string.IsNullOrWhiteSpace(_ip)) { _ip = HttpContext.Connection?.RemoteIpAddress?.ToString(); diff --git a/src/Core/Utilities/ServiceCollectionExtensions.cs b/src/Core/Utilities/ServiceCollectionExtensions.cs index 9a078982f..4e2776034 100644 --- a/src/Core/Utilities/ServiceCollectionExtensions.cs +++ b/src/Core/Utilities/ServiceCollectionExtensions.cs @@ -283,20 +283,6 @@ namespace Bit.Core.Utilities public static void UseDefaultMiddleware(this IApplicationBuilder app, IHostingEnvironment env) { - if(!env.IsDevelopment()) - { - // Adjust headers for proxy. - // ref: https://github.com/aspnet/Docs/issues/2384 - var forwardOptions = new ForwardedHeadersOptions - { - ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto, - RequireHeaderSymmetry = false - }; - forwardOptions.KnownNetworks.Clear(); - forwardOptions.KnownProxies.Clear(); - app.UseForwardedHeaders(forwardOptions); - } - // Add version information to response headers app.Use(async (httpContext, next) => {