diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/config.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/utils/config.go b/utils/config.go index 93c8ffc7c..d8f52ce49 100644 --- a/utils/config.go +++ b/utils/config.go @@ -13,6 +13,7 @@ import ( l4g "github.com/alecthomas/log4go" + "github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/model" ) @@ -167,6 +168,11 @@ func LoadConfig(fileName string) { map[string]interface{}{"Filename": fileName, "Error": err.Message})) } + if err := ValidateLdapFilter(&config); err != nil { + panic(T("utils.config.load_config.validating.panic", + map[string]interface{}{"Filename": fileName, "Error": err.Message})) + } + configureLog(&config.LogSettings) TestConnection(&config) @@ -243,3 +249,13 @@ func getClientConfig(c *model.Config) map[string]string { return props } + +func ValidateLdapFilter(cfg *model.Config) *model.AppError { + ldapInterface := einterfaces.GetLdapInterface() + if *cfg.LdapSettings.Enable && ldapInterface != nil && *cfg.LdapSettings.UserFilter != "" { + if err := ldapInterface.ValidateFilter(*cfg.LdapSettings.UserFilter); err != nil { + return err + } + } + return nil +} |