AuthN: Login (#61225)

* AuthN: Add function to login auth request
This commit is contained in:
Karl Persson
2023-01-10 14:55:27 +01:00
committed by GitHub
parent ef9a71f483
commit 2de72c1c39
5 changed files with 132 additions and 11 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/grafana/grafana/pkg/services/loginattempt"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util/errutil"
"github.com/grafana/grafana/pkg/web"
)
var (
@@ -54,7 +55,7 @@ func (c *Basic) Authenticate(ctx context.Context, r *authn.Request) (*authn.Iden
}
if errors.Is(err, errInvalidPassword) {
// only add login attempt if identity was found but the provided password was invalid
_ = c.loginAttempts.Add(ctx, username, r.HTTPRequest.RemoteAddr)
_ = c.loginAttempts.Add(ctx, username, web.RemoteAddr(r.HTTPRequest))
}
return nil, errBasicAuthCredentials.Errorf("failed to authenticate identity: %w", err)
}