1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00

Just use HttpContext RemoteIpAddress to get IP

This commit is contained in:
Kyle Spearrin 2018-02-21 21:43:02 -05:00
parent 4d703541bd
commit 0b17f3823a
2 changed files with 0 additions and 19 deletions

View File

@ -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();

View File

@ -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) =>
{