AuthN: Add auth proxy client (#61555)

* AuthN: set up boilerplate for proxy client

* AuthN: Implement Test for proxy client

* AuthN: parse accept list in constructor

* AuthN: add proxy client interface

* AuthN: handle error

* AuthN: Implement the proxy client interface for ldap

* AuthN: change reciever name

* AuthN: add grafana as a proxy client

* AuthN: for error returned

* AuthN: add tests for grafana proxy auth

* AuthN: swap order of grafan and ldap auth

* AuthN: Parse additional proxy headers in proxy client and pass down
This commit is contained in:
Karl Persson
2023-01-17 10:07:46 +01:00
committed by GitHub
parent c1d3b59643
commit b44b6fc5c6
11 changed files with 678 additions and 33 deletions
+19 -4
View File
@@ -64,12 +64,18 @@ func ProvideService(
s.clients[authn.ClientAnonymous] = clients.ProvideAnonymous(cfg, orgService)
}
var proxyClients []authn.ProxyClient
var passwordClients []authn.PasswordClient
if !s.cfg.DisableLogin {
passwordClients = append(passwordClients, clients.ProvideGrafana(userService))
}
if s.cfg.LDAPEnabled {
passwordClients = append(passwordClients, clients.ProvideLDAP(cfg))
ldap := clients.ProvideLDAP(cfg)
proxyClients = append(proxyClients, ldap)
passwordClients = append(passwordClients, ldap)
}
if !s.cfg.DisableLogin {
grafana := clients.ProvideGrafana(cfg, userService)
proxyClients = append(proxyClients, grafana)
passwordClients = append(passwordClients, grafana)
}
// if we have password clients configure check if basic auth or form auth is enabled
@@ -84,6 +90,15 @@ func ProvideService(
}
}
if s.cfg.AuthProxyEnabled && len(proxyClients) > 0 {
proxy, err := clients.ProvideProxy(cfg, proxyClients...)
if err != nil {
s.log.Error("failed to configure auth proxy", "err", err)
} else {
s.clients[authn.ClientProxy] = proxy
}
}
if s.cfg.JWTAuthEnabled {
s.clients[authn.ClientJWT] = clients.ProvideJWT(jwtService, cfg)
}