all: fix ratelimiter

This commit is contained in:
Stanislav Chzhen
2025-08-25 20:24:57 +03:00
parent 5f591bda61
commit 2fdb14b579
2 changed files with 13 additions and 9 deletions

View File

@@ -17,6 +17,13 @@ See also the [v0.107.66 GitHub milestone][ms-v0.107.66].
NOTE: Add new changes BELOW THIS COMMENT.
-->
### Fixed
- Authentication errors in the Web UI when AdGuard Home is behind a proxy that sets Basic Auth headers ([#7987]).
[#7987]: https://github.com/AdguardTeam/AdGuardHome/issues/7987
<!--
NOTE: Add new changes ABOVE THIS COMMENT.
-->

View File

@@ -506,24 +506,21 @@ func (mw *authMiddlewareDefault) userFromRequestBasicAuth(
return nil, fmt.Errorf("login attempt blocked for %s", left)
}
rateLimiter.inc(remoteIP)
defer func() {
if err != nil {
return
}
rateLimiter.remove(remoteIP)
}()
user, _ = mw.users.ByLogin(ctx, aghuser.Login(login))
if user == nil {
rateLimiter.inc(remoteIP)
return nil, errInvalidLogin
}
ok = user.Password.Authenticate(ctx, pass)
if !ok {
rateLimiter.inc(remoteIP)
return nil, errInvalidLogin
}
rateLimiter.remove(remoteIP)
return user, nil
}