The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/pkg/login/ldap_login.go

35 lines
673 B

package login
import (
"github.com/grafana/grafana/pkg/models"
LDAP "github.com/grafana/grafana/pkg/services/ldap"
)
var newLDAP = LDAP.New
var readLDAPConfig = LDAP.ReadConfig
var isLDAPEnabled = LDAP.IsEnabled
var loginUsingLdap = func(query *models.LoginUserQuery) (bool, error) {
enabled := isLDAPEnabled()
if !enabled {
return false, nil
}
config := readLDAPConfig()
if len(config.Servers) == 0 {
return true, ErrNoLDAPServers
}
for _, server := range config.Servers {
auth := newLDAP(server)
err := auth.Login(query)
if err == nil || err != LDAP.ErrInvalidCredentials {
return true, err
}
}
return true, LDAP.ErrInvalidCredentials
}