mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
only show ip-related headers
This commit is contained in:
@ -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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user