mirror of
https://github.com/bitwarden/server.git
synced 2024-11-29 13:25: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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HttpContext.Request?.Headers?.TryGetValue("X-Forwarded-For", out StringValues forwardHeader) ?? false)
|
|
||||||
{
|
|
||||||
_ip = forwardHeader.FirstOrDefault()?.Trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(_ip))
|
if(string.IsNullOrWhiteSpace(_ip))
|
||||||
{
|
{
|
||||||
_ip = HttpContext.Connection?.RemoteIpAddress?.ToString();
|
_ip = HttpContext.Connection?.RemoteIpAddress?.ToString();
|
||||||
|
@ -283,20 +283,6 @@ namespace Bit.Core.Utilities
|
|||||||
|
|
||||||
public static void UseDefaultMiddleware(this IApplicationBuilder app, IHostingEnvironment env)
|
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
|
// Add version information to response headers
|
||||||
app.Use(async (httpContext, next) =>
|
app.Use(async (httpContext, next) =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user