mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 18:47:23 +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);
|
||||
|
||||
logger.LogWarning("Failed authorization from {ip}", ip);
|
||||
|
||||
lock (failedAuthLock)
|
||||
{
|
||||
logger.LogWarning("Failed authorization from {ip}", ip);
|
||||
if (failedAuthorizations.TryGetValue(ip, out var auth))
|
||||
if (!_whitelistedIps.Any(w => ip.Contains(w)))
|
||||
{
|
||||
auth.IncreaseFailedAttempts();
|
||||
}
|
||||
else
|
||||
{
|
||||
failedAuthorizations[ip] = new FailedAuthorization();
|
||||
if (failedAuthorizations.TryGetValue(ip, out var auth))
|
||||
{
|
||||
auth.IncreaseFailedAttempts();
|
||||
}
|
||||
else
|
||||
{
|
||||
failedAuthorizations[ip] = new FailedAuthorization();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue