mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-14 03:14:16 +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,9 +102,12 @@ 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))
|
if (failedAuthorizations.TryGetValue(ip, out var auth))
|
||||||
{
|
{
|
||||||
auth.IncreaseFailedAttempts();
|
auth.IncreaseFailedAttempts();
|
||||||
|
|
@ -114,6 +117,7 @@ internal class SecretKeyAuthenticationHandler
|
||||||
failedAuthorizations[ip] = new FailedAuthorization();
|
failedAuthorizations[ip] = new FailedAuthorization();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
|
return new AuthReply() { Success = false, Uid = new UidMessage() { Uid = string.Empty } };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue