PLT-5813 support SAML sync via LDAP (#7668)
* PLT-5813 support SAML sync via LDAP * Cleaning up based on review
Этот коммит содержится в:
@@ -13,7 +13,8 @@ import (
|
|||||||
|
|
||||||
func (a *App) SyncLdap() {
|
func (a *App) SyncLdap() {
|
||||||
a.Go(func() {
|
a.Go(func() {
|
||||||
if utils.IsLicensed() && *utils.License().Features.LDAP && *a.Config().LdapSettings.Enable {
|
|
||||||
|
if utils.IsLicensed() && *utils.License().Features.LDAP && *a.Config().LdapSettings.EnableSync {
|
||||||
if ldapI := a.Ldap; ldapI != nil {
|
if ldapI := a.Ldap; ldapI != nil {
|
||||||
ldapI.StartSynchronizeJob(false)
|
ldapI.StartSynchronizeJob(false)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -223,6 +223,7 @@
|
|||||||
},
|
},
|
||||||
"LdapSettings": {
|
"LdapSettings": {
|
||||||
"Enable": false,
|
"Enable": false,
|
||||||
|
"EnableSync": false,
|
||||||
"LdapServer": "",
|
"LdapServer": "",
|
||||||
"LdapPort": 389,
|
"LdapPort": 389,
|
||||||
"ConnectionSecurity": "",
|
"ConnectionSecurity": "",
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ type LdapInterface interface {
|
|||||||
GetAllLdapUsers() ([]*model.User, *model.AppError)
|
GetAllLdapUsers() ([]*model.User, *model.AppError)
|
||||||
UserFromLdapUser(ldapUser *ldap.Entry) *model.User
|
UserFromLdapUser(ldapUser *ldap.Entry) *model.User
|
||||||
UserHasUpdateFromLdap(existingUser *model.User, currentLdapUser *model.User) bool
|
UserHasUpdateFromLdap(existingUser *model.User, currentLdapUser *model.User) bool
|
||||||
UpdateLdapUser(existingUser *model.User, currentLdapUser *model.User) *model.User
|
UpdateLocalLdapUser(existingUser *model.User, currentLdapUser *model.User) *model.User
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func (workers *Workers) Start() *Workers {
|
|||||||
go workers.ElasticsearchAggregation.Run()
|
go workers.ElasticsearchAggregation.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if workers.LdapSync != nil && *workers.Config().LdapSettings.Enable {
|
if workers.LdapSync != nil && *workers.Config().LdapSettings.EnableSync {
|
||||||
go workers.LdapSync.Run()
|
go workers.LdapSync.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +103,9 @@ func (workers *Workers) handleConfigChange(oldConfig *model.Config, newConfig *m
|
|||||||
}
|
}
|
||||||
|
|
||||||
if workers.LdapSync != nil {
|
if workers.LdapSync != nil {
|
||||||
if !*oldConfig.LdapSettings.Enable && *newConfig.LdapSettings.Enable {
|
if !*oldConfig.LdapSettings.EnableSync && *newConfig.LdapSettings.EnableSync {
|
||||||
go workers.LdapSync.Run()
|
go workers.LdapSync.Run()
|
||||||
} else if *oldConfig.LdapSettings.Enable && !*newConfig.LdapSettings.Enable {
|
} else if *oldConfig.LdapSettings.EnableSync && !*newConfig.LdapSettings.EnableSync {
|
||||||
workers.LdapSync.Stop()
|
workers.LdapSync.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ func (workers *Workers) Stop() *Workers {
|
|||||||
workers.ElasticsearchAggregation.Stop()
|
workers.ElasticsearchAggregation.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
if workers.LdapSync != nil && *workers.Config().LdapSettings.Enable {
|
if workers.LdapSync != nil && *workers.Config().LdapSettings.EnableSync {
|
||||||
workers.LdapSync.Stop()
|
workers.LdapSync.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ type ClientRequirements struct {
|
|||||||
type LdapSettings struct {
|
type LdapSettings struct {
|
||||||
// Basic
|
// Basic
|
||||||
Enable *bool
|
Enable *bool
|
||||||
|
EnableSync *bool
|
||||||
LdapServer *string
|
LdapServer *string
|
||||||
LdapPort *int
|
LdapPort *int
|
||||||
ConnectionSecurity *string
|
ConnectionSecurity *string
|
||||||
@@ -439,7 +440,9 @@ type LocalizationSettings struct {
|
|||||||
|
|
||||||
type SamlSettings struct {
|
type SamlSettings struct {
|
||||||
// Basic
|
// Basic
|
||||||
Enable *bool
|
Enable *bool
|
||||||
|
EnableSyncWithLdap *bool
|
||||||
|
|
||||||
Verify *bool
|
Verify *bool
|
||||||
Encrypt *bool
|
Encrypt *bool
|
||||||
|
|
||||||
@@ -987,6 +990,12 @@ func (o *Config) SetDefaults() {
|
|||||||
o.LdapSettings.Enable = NewBool(false)
|
o.LdapSettings.Enable = NewBool(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When unset should default to LDAP Enabled
|
||||||
|
if o.LdapSettings.EnableSync == nil {
|
||||||
|
o.LdapSettings.EnableSync = new(bool)
|
||||||
|
*o.LdapSettings.EnableSync = *o.LdapSettings.Enable
|
||||||
|
}
|
||||||
|
|
||||||
if o.LdapSettings.LdapServer == nil {
|
if o.LdapSettings.LdapServer == nil {
|
||||||
o.LdapSettings.LdapServer = NewString("")
|
o.LdapSettings.LdapServer = NewString("")
|
||||||
}
|
}
|
||||||
@@ -1209,6 +1218,11 @@ func (o *Config) SetDefaults() {
|
|||||||
o.SamlSettings.Enable = NewBool(false)
|
o.SamlSettings.Enable = NewBool(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.SamlSettings.EnableSyncWithLdap == nil {
|
||||||
|
o.SamlSettings.EnableSyncWithLdap = new(bool)
|
||||||
|
*o.SamlSettings.EnableSyncWithLdap = false
|
||||||
|
}
|
||||||
|
|
||||||
if o.SamlSettings.Verify == nil {
|
if o.SamlSettings.Verify == nil {
|
||||||
o.SamlSettings.Verify = NewBool(true)
|
o.SamlSettings.Verify = NewBool(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user