AuthN: Refactor basic auth client to support multiple password auth (#61153)

* AuthN: add interface for password clients

* AuthN: Extract grafana password client

* AuthN: Rewrite basic client tests

* AuthN: Add Ldap client and rename method of PasswordClient

* AuthN: Configure multiple password clients

* AuthN: create ldap service and add tests
This commit is contained in:
Karl Persson
2023-01-09 16:40:29 +01:00
committed by GitHub
parent c3378aff8b
commit a49892c9ac
10 changed files with 413 additions and 76 deletions

View File

@@ -53,9 +53,19 @@ func ProvideService(
s.clients[authn.ClientAnonymous] = clients.ProvideAnonymous(cfg, orgService)
}
// FIXME (kalleep): handle cfg.DisableLogin as well?
if s.cfg.BasicAuthEnabled && !s.cfg.DisableLogin {
s.clients[authn.ClientBasic] = clients.ProvideBasic(userService, loginAttempts)
var passwordClients []authn.PasswordClient
if !s.cfg.DisableLogin {
passwordClients = append(passwordClients, clients.ProvideGrafana(userService))
}
if s.cfg.LDAPEnabled {
passwordClients = append(passwordClients, clients.ProvideLDAP(cfg))
}
// only configure basic auth client if it is enabled, and we have at least one password client enabled
if s.cfg.BasicAuthEnabled && len(passwordClients) > 0 {
s.clients[authn.ClientBasic] = clients.ProvideBasic(loginAttempts, passwordClients...)
}
// FIXME (jguer): move to User package