check whitelisted ip when retrieving unauthorized from cache

This commit is contained in:
Stanley Dimant
2022-10-15 01:01:04 +02:00
parent c98e2b2dd6
commit 75a18fb0b8

View File

@@ -102,9 +102,12 @@ internal class SecretKeyAuthenticationHandler
{
metrics.IncCounter(MetricsAPI.CounterAuthenticationFailures);
logger.LogWarning("Failed authorization from {ip}", ip);
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();
@@ -114,6 +117,7 @@ internal class SecretKeyAuthenticationHandler
failedAuthorizations[ip] = new FailedAuthorization();
}
}
}
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
}