mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 23:44:15 +01:00
check whitelisted ip when retrieving unauthorized from cache
This commit is contained in:
parent
c98e2b2dd6
commit
75a18fb0b8
1 changed files with 11 additions and 7 deletions
|
|
@ -102,16 +102,20 @@ internal class SecretKeyAuthenticationHandler
|
||||||
{
|
{
|
||||||
metrics.IncCounter(MetricsAPI.CounterAuthenticationFailures);
|
metrics.IncCounter(MetricsAPI.CounterAuthenticationFailures);
|
||||||
|
|
||||||
|
logger.LogWarning("Failed authorization from {ip}", ip);
|
||||||
|
|
||||||
lock (failedAuthLock)
|
lock (failedAuthLock)
|
||||||
{
|
{
|
||||||
logger.LogWarning("Failed authorization from {ip}", ip);
|
if (!_whitelistedIps.Any(w => ip.Contains(w)))
|
||||||
if (failedAuthorizations.TryGetValue(ip, out var auth))
|
|
||||||
{
|
{
|
||||||
auth.IncreaseFailedAttempts();
|
if (failedAuthorizations.TryGetValue(ip, out var auth))
|
||||||
}
|
{
|
||||||
else
|
auth.IncreaseFailedAttempts();
|
||||||
{
|
}
|
||||||
failedAuthorizations[ip] = new FailedAuthorization();
|
else
|
||||||
|
{
|
||||||
|
failedAuthorizations[ip] = new FailedAuthorization();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue