1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

only show ip-related headers

This commit is contained in:
Kyle Spearrin
2020-03-07 21:41:53 -05:00
parent 6341937c7c
commit 4a0071f721

View File

@ -6,6 +6,8 @@ using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Bit.Core; using Bit.Core;
using Stripe; using Stripe;
using System.Linq;
using System.Collections.Generic;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -38,10 +40,14 @@ namespace Bit.Api.Controllers
[HttpGet("~/ip")] [HttpGet("~/ip")]
public JsonResult Ip() public JsonResult Ip()
{ {
var headerSet = new HashSet<string> { "x-forwarded-for", "cf-connecting-ip", "client-ip" };
var headers = HttpContext.Request?.Headers
.Where(h => headerSet.Contains(h.Key.ToLower()))
.ToDictionary(h => h.Key);
return new JsonResult(new return new JsonResult(new
{ {
Ip = HttpContext.Connection?.RemoteIpAddress?.ToString(), Ip = HttpContext.Connection?.RemoteIpAddress?.ToString(),
Headers = HttpContext.Request?.Headers, Headers = headers,
}); });
} }