1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-13 20:21:22 +01:00

support X-Real-IP

This commit is contained in:
Kyle Spearrin 2019-04-26 11:02:38 -04:00
parent 43eeebdc21
commit a416f5a912

View File

@ -13,6 +13,7 @@ namespace Bit.Core
public class CurrentContext
{
private const string CloudFlareConnectingIp = "CF-Connecting-IP";
private const string RealIp = "X-Real-IP";
private bool _builtHttpContext;
private bool _builtClaimsPrincipal;
@ -182,6 +183,10 @@ namespace Bit.Core
{
return HttpContext.Request.Headers[CloudFlareConnectingIp].ToString();
}
if(globalSettings.SelfHosted && HttpContext.Request.Headers.ContainsKey(RealIp))
{
return HttpContext.Request.Headers[RealIp].ToString();
}
return HttpContext.Connection?.RemoteIpAddress?.ToString();
}