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:
parent
4d703541bd
commit
0b17f3823a
@ -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();
|
||||
|
@ -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) =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user