mirror of
https://github.com/bitwarden/server.git
synced 2025-04-17 19:18:16 -05:00
GetRequestInfo on ban
This commit is contained in:
parent
a1cb980bac
commit
cdddffc977
@ -60,7 +60,7 @@ namespace Bit.Core.Utilities
|
|||||||
if(blockedCount > 10)
|
if(blockedCount > 10)
|
||||||
{
|
{
|
||||||
_blockIpService.BlockIpAsync(identity.ClientIp, false);
|
_blockIpService.BlockIpAsync(identity.ClientIp, false);
|
||||||
_logger.LogInformation($"Blocked {identity.ClientIp} with token {GetToken(httpContext.Request)}");
|
_logger.LogInformation($"Blocked {identity.ClientIp}. Request Info: {GetRequestInfo(httpContext)}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -69,30 +69,25 @@ namespace Bit.Core.Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetToken(HttpRequest request)
|
private string GetRequestInfo(HttpContext httpContext)
|
||||||
{
|
{
|
||||||
if(request == null)
|
if(httpContext == null || httpContext.Request == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var authorization = request.Headers["Authorization"].FirstOrDefault();
|
var s = string.Empty;
|
||||||
if(string.IsNullOrWhiteSpace(authorization))
|
foreach(var header in httpContext.Request.Headers)
|
||||||
{
|
{
|
||||||
// Bearer token could exist in the 'Content-Language' header on clients that want to avoid pre-flights.
|
s += $"H_{header.Key}: {header.Value} | ";
|
||||||
var languageAuth = request.Headers["Content-Language"].FirstOrDefault();
|
|
||||||
if(string.IsNullOrWhiteSpace(languageAuth) ||
|
|
||||||
!languageAuth.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return request.Query["access_token"].FirstOrDefault();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
authorization = languageAuth.Split(',')[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return authorization;
|
foreach(var query in httpContext.Request.Query)
|
||||||
|
{
|
||||||
|
s += $"Q_{query.Key}: {query.Value} | ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user