diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-06-28 14:53:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-28 14:53:44 -0400 |
commit | 96bddf90169a0d9c39bdb0ae425ff15dfd03f62b (patch) | |
tree | 66aa05158f7ed8f36a6f0c1d88f24b3419fb58f9 /model/config.go | |
parent | 8c2282f89e6c439044afe98eb61f806d5a3215b5 (diff) | |
download | chat-96bddf90169a0d9c39bdb0ae425ff15dfd03f62b.tar.gz chat-96bddf90169a0d9c39bdb0ae425ff15dfd03f62b.tar.bz2 chat-96bddf90169a0d9c39bdb0ae425ff15dfd03f62b.zip |
Adding validation for LDAP settings to configuration (#3425)
Diffstat (limited to 'model/config.go')
-rw-r--r-- | model/config.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go index cbb254768..51a3b252e 100644 --- a/model/config.go +++ b/model/config.go @@ -486,6 +486,11 @@ func (o *Config) SetDefaults() { *o.LdapSettings.EmailAttribute = "" } + if o.LdapSettings.UsernameAttribute == nil { + o.LdapSettings.UsernameAttribute = new(string) + *o.LdapSettings.UsernameAttribute = "" + } + if o.LdapSettings.NicknameAttribute == nil { o.LdapSettings.NicknameAttribute = new(string) *o.LdapSettings.NicknameAttribute = "" @@ -709,6 +714,20 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "") } + if *o.LdapSettings.Enable { + if *o.LdapSettings.LdapServer == "" || + *o.LdapSettings.BaseDN == "" || + *o.LdapSettings.BindUsername == "" || + *o.LdapSettings.BindPassword == "" || + *o.LdapSettings.FirstNameAttribute == "" || + *o.LdapSettings.LastNameAttribute == "" || + *o.LdapSettings.EmailAttribute == "" || + *o.LdapSettings.UsernameAttribute == "" || + *o.LdapSettings.IdAttribute == "" { + return NewLocAppError("Config.IsValid", "Required LDAP field missing", nil, "") + } + } + return nil } |