mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LDAP: consistently name the LDAP entities (#17203)
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/ldap"
|
||||
)
|
||||
|
||||
func (server *HTTPServer) ReloadLdapCfg() Response {
|
||||
func (server *HTTPServer) ReloadLDAPCfg() Response {
|
||||
if !ldap.IsEnabled() {
|
||||
return Error(400, "LDAP is not enabled", nil)
|
||||
}
|
||||
@@ -13,5 +13,5 @@ func (server *HTTPServer) ReloadLdapCfg() Response {
|
||||
if err != nil {
|
||||
return Error(500, "Failed to reload ldap config.", err)
|
||||
}
|
||||
return Success("Ldap config reloaded")
|
||||
return Success("LDAP config reloaded")
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
adminRoute.Post("/provisioning/dashboards/reload", Wrap(hs.AdminProvisioningReloadDasboards))
|
||||
adminRoute.Post("/provisioning/datasources/reload", Wrap(hs.AdminProvisioningReloadDatasources))
|
||||
adminRoute.Post("/provisioning/notifications/reload", Wrap(hs.AdminProvisioningReloadNotifications))
|
||||
adminRoute.Post("/ldap/reload", Wrap(hs.ReloadLdapCfg))
|
||||
adminRoute.Post("/ldap/reload", Wrap(hs.ReloadLDAPCfg))
|
||||
}, reqGrafanaAdmin)
|
||||
|
||||
// rendering
|
||||
|
||||
@@ -176,7 +176,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interf
|
||||
"appSubUrl": setting.AppSubUrl,
|
||||
"allowOrgCreate": (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin,
|
||||
"authProxyEnabled": setting.AuthProxyEnabled,
|
||||
"ldapEnabled": setting.LdapEnabled,
|
||||
"ldapEnabled": setting.LDAPEnabled,
|
||||
"alertingEnabled": setting.AlertingEnabled,
|
||||
"alertingErrorOrTimeout": setting.AlertingErrorOrTimeout,
|
||||
"alertingNoDataOrNullValues": setting.AlertingNoDataOrNullValues,
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func SendResetPasswordEmail(c *m.ReqContext, form dtos.SendResetPasswordEmailForm) Response {
|
||||
if setting.LdapEnabled || setting.AuthProxyEnabled {
|
||||
if setting.LDAPEnabled || setting.AuthProxyEnabled {
|
||||
return Error(401, "Not allowed to reset password when LDAP or Auth Proxy is enabled", nil)
|
||||
}
|
||||
if setting.DisableLoginForm {
|
||||
|
||||
@@ -21,7 +21,7 @@ func GetTeamMembers(c *m.ReqContext) Response {
|
||||
member.AvatarUrl = dtos.GetGravatarUrl(member.Email)
|
||||
member.Labels = []string{}
|
||||
|
||||
if setting.IsEnterprise && setting.LdapEnabled && member.External {
|
||||
if setting.IsEnterprise && setting.LDAPEnabled && member.External {
|
||||
member.Labels = append(member.Labels, "LDAP")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *m.ReqContext) {
|
||||
}
|
||||
|
||||
func ChangeUserPassword(c *m.ReqContext, cmd m.ChangeUserPasswordCommand) Response {
|
||||
if setting.LdapEnabled || setting.AuthProxyEnabled {
|
||||
if setting.LDAPEnabled || setting.AuthProxyEnabled {
|
||||
return Error(400, "Not allowed to change password when LDAP or Auth Proxy is enabled", nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
|
||||
authTypes := map[string]bool{}
|
||||
authTypes["anonymous"] = setting.AnonymousEnabled
|
||||
authTypes["basic_auth"] = setting.BasicAuthEnabled
|
||||
authTypes["ldap"] = setting.LdapEnabled
|
||||
authTypes["ldap"] = setting.LDAPEnabled
|
||||
authTypes["auth_proxy"] = setting.AuthProxyEnabled
|
||||
|
||||
for provider, enabled := range oauthProviders {
|
||||
|
||||
@@ -182,7 +182,7 @@ func TestMetrics(t *testing.T) {
|
||||
setting.BuildVersion = "5.0.0"
|
||||
setting.AnonymousEnabled = true
|
||||
setting.BasicAuthEnabled = true
|
||||
setting.LdapEnabled = true
|
||||
setting.LDAPEnabled = true
|
||||
setting.AuthProxyEnabled = true
|
||||
setting.Packaging = "deb"
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func AuthenticateUser(query *models.LoginUserQuery) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ldapEnabled, ldapErr := loginUsingLdap(query)
|
||||
ldapEnabled, ldapErr := loginUsingLDAP(query)
|
||||
if ldapEnabled {
|
||||
if ldapErr == nil || ldapErr != ldap.ErrInvalidCredentials {
|
||||
return ldapErr
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When a user authenticates without setting a password", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(nil, sc)
|
||||
mockLoginUsingLdap(false, nil, sc)
|
||||
mockLoginUsingLDAP(false, nil, sc)
|
||||
|
||||
loginQuery := models.LoginUserQuery{
|
||||
Username: "user",
|
||||
@@ -33,7 +33,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When a user authenticates having too many login attempts", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(ErrTooManyLoginAttempts, sc)
|
||||
mockLoginUsingGrafanaDB(nil, sc)
|
||||
mockLoginUsingLdap(true, nil, sc)
|
||||
mockLoginUsingLDAP(true, nil, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -50,7 +50,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When grafana user authenticate with valid credentials", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(nil, sc)
|
||||
mockLoginUsingLdap(true, ErrInvalidCredentials, sc)
|
||||
mockLoginUsingLDAP(true, ErrInvalidCredentials, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -68,7 +68,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
customErr := errors.New("custom")
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(customErr, sc)
|
||||
mockLoginUsingLdap(true, ErrInvalidCredentials, sc)
|
||||
mockLoginUsingLDAP(true, ErrInvalidCredentials, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -85,7 +85,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When a non-existing grafana user authenticate and ldap disabled", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(models.ErrUserNotFound, sc)
|
||||
mockLoginUsingLdap(false, nil, sc)
|
||||
mockLoginUsingLDAP(false, nil, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -102,7 +102,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When a non-existing grafana user authenticate and invalid ldap credentials", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(models.ErrUserNotFound, sc)
|
||||
mockLoginUsingLdap(true, ldap.ErrInvalidCredentials, sc)
|
||||
mockLoginUsingLDAP(true, ldap.ErrInvalidCredentials, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -119,7 +119,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When a non-existing grafana user authenticate and valid ldap credentials", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(models.ErrUserNotFound, sc)
|
||||
mockLoginUsingLdap(true, nil, sc)
|
||||
mockLoginUsingLDAP(true, nil, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -137,7 +137,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
customErr := errors.New("custom")
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(models.ErrUserNotFound, sc)
|
||||
mockLoginUsingLdap(true, customErr, sc)
|
||||
mockLoginUsingLDAP(true, customErr, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -154,7 +154,7 @@ func TestAuthenticateUser(t *testing.T) {
|
||||
authScenario("When grafana user authenticate with invalid credentials and invalid ldap credentials", func(sc *authScenarioContext) {
|
||||
mockLoginAttemptValidation(nil, sc)
|
||||
mockLoginUsingGrafanaDB(ErrInvalidCredentials, sc)
|
||||
mockLoginUsingLdap(true, ldap.ErrInvalidCredentials, sc)
|
||||
mockLoginUsingLDAP(true, ldap.ErrInvalidCredentials, sc)
|
||||
mockSaveInvalidLoginAttempt(sc)
|
||||
|
||||
err := AuthenticateUser(sc.loginUserQuery)
|
||||
@@ -187,8 +187,8 @@ func mockLoginUsingGrafanaDB(err error, sc *authScenarioContext) {
|
||||
}
|
||||
}
|
||||
|
||||
func mockLoginUsingLdap(enabled bool, err error, sc *authScenarioContext) {
|
||||
loginUsingLdap = func(query *models.LoginUserQuery) (bool, error) {
|
||||
func mockLoginUsingLDAP(enabled bool, err error, sc *authScenarioContext) {
|
||||
loginUsingLDAP = func(query *models.LoginUserQuery) (bool, error) {
|
||||
sc.ldapLoginWasCalled = true
|
||||
return enabled, err
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func mockSaveInvalidLoginAttempt(sc *authScenarioContext) {
|
||||
func authScenario(desc string, fn authScenarioFunc) {
|
||||
Convey(desc, func() {
|
||||
origLoginUsingGrafanaDB := loginUsingGrafanaDB
|
||||
origLoginUsingLdap := loginUsingLdap
|
||||
origLoginUsingLDAP := loginUsingLDAP
|
||||
origValidateLoginAttempts := validateLoginAttempts
|
||||
origSaveInvalidLoginAttempt := saveInvalidLoginAttempt
|
||||
|
||||
@@ -224,7 +224,7 @@ func authScenario(desc string, fn authScenarioFunc) {
|
||||
|
||||
defer func() {
|
||||
loginUsingGrafanaDB = origLoginUsingGrafanaDB
|
||||
loginUsingLdap = origLoginUsingLdap
|
||||
loginUsingLDAP = origLoginUsingLDAP
|
||||
validateLoginAttempts = origValidateLoginAttempts
|
||||
saveInvalidLoginAttempt = origSaveInvalidLoginAttempt
|
||||
}()
|
||||
|
||||
@@ -17,9 +17,9 @@ var isLDAPEnabled = multildap.IsEnabled
|
||||
// newLDAP creates multiple LDAP instance
|
||||
var newLDAP = multildap.New
|
||||
|
||||
// loginUsingLdap logs in user using LDAP. It returns whether LDAP is enabled and optional error and query arg will be
|
||||
// loginUsingLDAP logs in user using LDAP. It returns whether LDAP is enabled and optional error and query arg will be
|
||||
// populated with the logged in user if successful.
|
||||
var loginUsingLdap = func(query *models.LoginUserQuery) (bool, error) {
|
||||
var loginUsingLDAP = func(query *models.LoginUserQuery) (bool, error) {
|
||||
enabled := isLDAPEnabled()
|
||||
|
||||
if !enabled {
|
||||
@@ -38,7 +38,7 @@ var loginUsingLdap = func(query *models.LoginUserQuery) (bool, error) {
|
||||
|
||||
login, err := user.Upsert(&user.UpsertArgs{
|
||||
ExternalUser: externalUser,
|
||||
SignupAllowed: setting.LdapAllowSignup,
|
||||
SignupAllowed: setting.LDAPAllowSignup,
|
||||
})
|
||||
if err != nil {
|
||||
return true, err
|
||||
|
||||
@@ -14,10 +14,10 @@ import (
|
||||
|
||||
var errTest = errors.New("Test error")
|
||||
|
||||
func TestLdapLogin(t *testing.T) {
|
||||
func TestLDAPLogin(t *testing.T) {
|
||||
Convey("Login using ldap", t, func() {
|
||||
Convey("Given ldap enabled and no server configured", func() {
|
||||
setting.LdapEnabled = true
|
||||
setting.LDAPEnabled = true
|
||||
|
||||
LDAPLoginScenario("When login", func(sc *LDAPLoginScenarioContext) {
|
||||
sc.withLoginResult(false)
|
||||
@@ -29,7 +29,7 @@ func TestLdapLogin(t *testing.T) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
enabled, err := loginUsingLdap(sc.loginUserQuery)
|
||||
enabled, err := loginUsingLDAP(sc.loginUserQuery)
|
||||
|
||||
Convey("it should return true", func() {
|
||||
So(enabled, ShouldBeTrue)
|
||||
@@ -46,11 +46,11 @@ func TestLdapLogin(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Given ldap disabled", func() {
|
||||
setting.LdapEnabled = false
|
||||
setting.LDAPEnabled = false
|
||||
|
||||
LDAPLoginScenario("When login", func(sc *LDAPLoginScenarioContext) {
|
||||
sc.withLoginResult(false)
|
||||
enabled, err := loginUsingLdap(&models.LoginUserQuery{
|
||||
enabled, err := loginUsingLDAP(&models.LoginUserQuery{
|
||||
Username: "user",
|
||||
Password: "pwd",
|
||||
})
|
||||
|
||||
@@ -40,7 +40,7 @@ type AuthProxy struct {
|
||||
header string
|
||||
|
||||
enabled bool
|
||||
LdapAllowSignup bool
|
||||
LDAPAllowSignup bool
|
||||
AuthProxyAutoSignUp bool
|
||||
whitelistIP string
|
||||
headerType string
|
||||
@@ -88,8 +88,8 @@ func New(options *Options) *AuthProxy {
|
||||
headerType: setting.AuthProxyHeaderProperty,
|
||||
headers: setting.AuthProxyHeaders,
|
||||
whitelistIP: setting.AuthProxyWhitelist,
|
||||
cacheTTL: setting.AuthProxyLdapSyncTtl,
|
||||
LdapAllowSignup: setting.LdapAllowSignup,
|
||||
cacheTTL: setting.AuthProxyLDAPSyncTtl,
|
||||
LDAPAllowSignup: setting.LDAPAllowSignup,
|
||||
AuthProxyAutoSignUp: setting.AuthProxyAutoSignUp,
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (auth *AuthProxy) LoginViaLDAP() (int64, *Error) {
|
||||
// Have to sync grafana and LDAP user during log in
|
||||
user, err := user.Upsert(&user.UpsertArgs{
|
||||
ReqContext: auth.ctx,
|
||||
SignupAllowed: auth.LdapAllowSignup,
|
||||
SignupAllowed: auth.LDAPAllowSignup,
|
||||
ExternalUser: extUser,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -300,7 +300,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
setting.AuthProxyEnabled = true
|
||||
setting.AuthProxyWhitelist = ""
|
||||
setting.AuthProxyAutoSignUp = true
|
||||
setting.LdapEnabled = true
|
||||
setting.LDAPEnabled = true
|
||||
setting.AuthProxyHeaderName = "X-WEBAUTH-USER"
|
||||
setting.AuthProxyHeaderProperty = "username"
|
||||
name := "markelog"
|
||||
@@ -326,7 +326,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
})
|
||||
|
||||
middlewareScenario(t, "should create an user from a header", func(sc *scenarioContext) {
|
||||
setting.LdapEnabled = false
|
||||
setting.LDAPEnabled = false
|
||||
setting.AuthProxyAutoSignUp = true
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetSignedInUserQuery) error {
|
||||
@@ -354,7 +354,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
})
|
||||
|
||||
middlewareScenario(t, "should get an existing user from header", func(sc *scenarioContext) {
|
||||
setting.LdapEnabled = false
|
||||
setting.LDAPEnabled = false
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetSignedInUserQuery) error {
|
||||
query.Result = &m.SignedInUser{OrgId: 2, UserId: 12}
|
||||
@@ -379,7 +379,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
|
||||
middlewareScenario(t, "should allow the request from whitelist IP", func(sc *scenarioContext) {
|
||||
setting.AuthProxyWhitelist = "192.168.1.0/24, 2001::0/120"
|
||||
setting.LdapEnabled = false
|
||||
setting.LDAPEnabled = false
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetSignedInUserQuery) error {
|
||||
query.Result = &m.SignedInUser{OrgId: 4, UserId: 33}
|
||||
@@ -405,7 +405,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
|
||||
middlewareScenario(t, "should not allow the request from whitelist IP", func(sc *scenarioContext) {
|
||||
setting.AuthProxyWhitelist = "8.8.8.8"
|
||||
setting.LdapEnabled = false
|
||||
setting.LDAPEnabled = false
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetSignedInUserQuery) error {
|
||||
query.Result = &m.SignedInUser{OrgId: 4, UserId: 33}
|
||||
|
||||
@@ -454,9 +454,9 @@ func (server *Server) requestMemberOf(searchResult *ldap.SearchResult) ([]string
|
||||
for _, groupSearchBase := range server.config.GroupSearchBaseDNs {
|
||||
var filterReplace string
|
||||
if server.config.GroupSearchFilterUserAttribute == "" {
|
||||
filterReplace = getLdapAttr(server.config.Attr.Username, searchResult)
|
||||
filterReplace = getLDAPAttr(server.config.Attr.Username, searchResult)
|
||||
} else {
|
||||
filterReplace = getLdapAttr(server.config.GroupSearchFilterUserAttribute, searchResult)
|
||||
filterReplace = getLDAPAttr(server.config.GroupSearchFilterUserAttribute, searchResult)
|
||||
}
|
||||
|
||||
filter := strings.Replace(
|
||||
@@ -489,7 +489,7 @@ func (server *Server) requestMemberOf(searchResult *ldap.SearchResult) ([]string
|
||||
|
||||
if len(groupSearchResult.Entries) > 0 {
|
||||
for i := range groupSearchResult.Entries {
|
||||
memberOf = append(memberOf, getLdapAttrN(groupIDAttribute, groupSearchResult, i))
|
||||
memberOf = append(memberOf, getLDAPAttrN(groupIDAttribute, groupSearchResult, i))
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -512,27 +512,27 @@ func (server *Server) serializeUsers(
|
||||
}
|
||||
|
||||
userInfo := &UserInfo{
|
||||
DN: getLdapAttrN(
|
||||
DN: getLDAPAttrN(
|
||||
"dn",
|
||||
users,
|
||||
index,
|
||||
),
|
||||
LastName: getLdapAttrN(
|
||||
LastName: getLDAPAttrN(
|
||||
server.config.Attr.Surname,
|
||||
users,
|
||||
index,
|
||||
),
|
||||
FirstName: getLdapAttrN(
|
||||
FirstName: getLDAPAttrN(
|
||||
server.config.Attr.Name,
|
||||
users,
|
||||
index,
|
||||
),
|
||||
Username: getLdapAttrN(
|
||||
Username: getLDAPAttrN(
|
||||
server.config.Attr.Username,
|
||||
users,
|
||||
index,
|
||||
),
|
||||
Email: getLdapAttrN(
|
||||
Email: getLDAPAttrN(
|
||||
server.config.Attr.Email,
|
||||
users,
|
||||
index,
|
||||
@@ -554,7 +554,7 @@ func (server *Server) getMemberOf(search *ldap.SearchResult) (
|
||||
[]string, error,
|
||||
) {
|
||||
if server.config.GroupSearchFilter == "" {
|
||||
memberOf := getLdapAttrArray(server.config.Attr.MemberOf, search)
|
||||
memberOf := getLDAPAttrArray(server.config.Attr.MemberOf, search)
|
||||
|
||||
return memberOf, nil
|
||||
}
|
||||
@@ -576,11 +576,11 @@ func appendIfNotEmpty(slice []string, values ...string) []string {
|
||||
return slice
|
||||
}
|
||||
|
||||
func getLdapAttr(name string, result *ldap.SearchResult) string {
|
||||
return getLdapAttrN(name, result, 0)
|
||||
func getLDAPAttr(name string, result *ldap.SearchResult) string {
|
||||
return getLDAPAttrN(name, result, 0)
|
||||
}
|
||||
|
||||
func getLdapAttrN(name string, result *ldap.SearchResult, n int) string {
|
||||
func getLDAPAttrN(name string, result *ldap.SearchResult, n int) string {
|
||||
if strings.ToLower(name) == "dn" {
|
||||
return result.Entries[n].DN
|
||||
}
|
||||
@@ -594,11 +594,11 @@ func getLdapAttrN(name string, result *ldap.SearchResult, n int) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func getLdapAttrArray(name string, result *ldap.SearchResult) []string {
|
||||
return getLdapAttrArrayN(name, result, 0)
|
||||
func getLDAPAttrArray(name string, result *ldap.SearchResult) []string {
|
||||
return getLDAPAttrArrayN(name, result, 0)
|
||||
}
|
||||
|
||||
func getLdapAttrArrayN(name string, result *ldap.SearchResult, n int) []string {
|
||||
func getLDAPAttrArrayN(name string, result *ldap.SearchResult, n int) []string {
|
||||
for _, attr := range result.Entries[n].Attributes {
|
||||
if attr.Name == name {
|
||||
return attr.Values
|
||||
|
||||
@@ -65,7 +65,7 @@ var loadingMutex = &sync.Mutex{}
|
||||
|
||||
// IsEnabled checks if ldap is enabled
|
||||
func IsEnabled() bool {
|
||||
return setting.LdapEnabled
|
||||
return setting.LDAPEnabled
|
||||
}
|
||||
|
||||
// ReloadConfig reads the config from the disc and caches it.
|
||||
@@ -78,7 +78,7 @@ func ReloadConfig() error {
|
||||
defer loadingMutex.Unlock()
|
||||
|
||||
var err error
|
||||
config, err = readConfig(setting.LdapConfigFile)
|
||||
config, err = readConfig(setting.LDAPConfigFile)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func GetConfig() (*Config, error) {
|
||||
defer loadingMutex.Unlock()
|
||||
|
||||
var err error
|
||||
config, err = readConfig(setting.LdapConfigFile)
|
||||
config, err = readConfig(setting.LDAPConfigFile)
|
||||
|
||||
return config, err
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func GetConfig() (*Config, error) {
|
||||
func readConfig(configFile string) (*Config, error) {
|
||||
result := &Config{}
|
||||
|
||||
logger.Info("Ldap enabled, reading config file", "file", configFile)
|
||||
logger.Info("LDAP enabled, reading config file", "file", configFile)
|
||||
|
||||
_, err := toml.DecodeFile(configFile, result)
|
||||
if err != nil {
|
||||
|
||||
@@ -138,7 +138,7 @@ var (
|
||||
AuthProxyHeaderName string
|
||||
AuthProxyHeaderProperty string
|
||||
AuthProxyAutoSignUp bool
|
||||
AuthProxyLdapSyncTtl int
|
||||
AuthProxyLDAPSyncTtl int
|
||||
AuthProxyWhitelist string
|
||||
AuthProxyHeaders map[string]string
|
||||
|
||||
@@ -165,11 +165,11 @@ var (
|
||||
GoogleTagManagerId string
|
||||
|
||||
// LDAP
|
||||
LdapEnabled bool
|
||||
LdapConfigFile string
|
||||
LdapSyncCron string
|
||||
LdapAllowSignup bool
|
||||
LdapActiveSyncEnabled bool
|
||||
LDAPEnabled bool
|
||||
LDAPConfigFile string
|
||||
LDAPSyncCron string
|
||||
LDAPAllowSignup bool
|
||||
LDAPActiveSyncEnabled bool
|
||||
|
||||
// QUOTA
|
||||
Quota QuotaSettings
|
||||
@@ -815,7 +815,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
return err
|
||||
}
|
||||
AuthProxyAutoSignUp = authProxy.Key("auto_sign_up").MustBool(true)
|
||||
AuthProxyLdapSyncTtl = authProxy.Key("ldap_sync_ttl").MustInt()
|
||||
AuthProxyLDAPSyncTtl = authProxy.Key("ldap_sync_ttl").MustInt()
|
||||
AuthProxyWhitelist, err = valueAsString(authProxy, "whitelist", "")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -978,11 +978,11 @@ type RemoteCacheOptions struct {
|
||||
|
||||
func (cfg *Cfg) readLDAPConfig() {
|
||||
ldapSec := cfg.Raw.Section("auth.ldap")
|
||||
LdapConfigFile = ldapSec.Key("config_file").String()
|
||||
LdapSyncCron = ldapSec.Key("sync_cron").String()
|
||||
LdapEnabled = ldapSec.Key("enabled").MustBool(false)
|
||||
LdapActiveSyncEnabled = ldapSec.Key("active_sync_enabled").MustBool(false)
|
||||
LdapAllowSignup = ldapSec.Key("allow_sign_up").MustBool(true)
|
||||
LDAPConfigFile = ldapSec.Key("config_file").String()
|
||||
LDAPSyncCron = ldapSec.Key("sync_cron").String()
|
||||
LDAPEnabled = ldapSec.Key("enabled").MustBool(false)
|
||||
LDAPActiveSyncEnabled = ldapSec.Key("active_sync_enabled").MustBool(false)
|
||||
LDAPAllowSignup = ldapSec.Key("allow_sign_up").MustBool(true)
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readSessionConfig() {
|
||||
|
||||
Reference in New Issue
Block a user