mirror of
https://github.com/bitwarden/server.git
synced 2025-02-24 03:11:22 +01:00
only show ip-related headers
This commit is contained in:
parent
6341937c7c
commit
4a0071f721
@ -6,6 +6,8 @@ using Bit.Core.Utilities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Bit.Core;
|
||||
using Stripe;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Api.Controllers
|
||||
{
|
||||
@ -38,10 +40,14 @@ namespace Bit.Api.Controllers
|
||||
[HttpGet("~/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
|
||||
{
|
||||
Ip = HttpContext.Connection?.RemoteIpAddress?.ToString(),
|
||||
Headers = HttpContext.Request?.Headers,
|
||||
Headers = headers,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user