Plugin groups (#30320)
* add new pluginapi methods * SAML login hook * set ReAddRemovedMembers to true for plugin groups * change to DoLogin signature for SAML
Этот коммит содержится в:
@@ -6,12 +6,16 @@ package model
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
GroupSourceLdap GroupSource = "ldap"
|
||||
GroupSourceCustom GroupSource = "custom"
|
||||
|
||||
// plugin groups must prefix their source with this
|
||||
GroupSourcePluginPrefix GroupSource = "plugin_"
|
||||
|
||||
GroupNameMaxLength = 64
|
||||
GroupSourceMaxLength = 64
|
||||
GroupDisplayNameMaxLength = 128
|
||||
@@ -21,15 +25,6 @@ const (
|
||||
|
||||
type GroupSource string
|
||||
|
||||
var allGroupSources = []GroupSource{
|
||||
GroupSourceLdap,
|
||||
GroupSourceCustom,
|
||||
}
|
||||
|
||||
var groupSourcesRequiringRemoteID = []GroupSource{
|
||||
GroupSourceLdap,
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
Id string `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
@@ -157,6 +152,9 @@ type GroupSearchOpts struct {
|
||||
|
||||
// Only return archived groups
|
||||
FilterArchived bool
|
||||
|
||||
// OnlySyncableSources filters the groups to only those that are syncable
|
||||
OnlySyncableSources bool
|
||||
}
|
||||
|
||||
type GetGroupOpts struct {
|
||||
@@ -214,12 +212,12 @@ func (group *Group) IsValidForCreate() *AppError {
|
||||
}
|
||||
|
||||
isValidSource := false
|
||||
for _, groupSource := range allGroupSources {
|
||||
if group.Source == groupSource {
|
||||
isValidSource = true
|
||||
break
|
||||
}
|
||||
if group.Source == GroupSourceLdap ||
|
||||
group.Source == GroupSourceCustom ||
|
||||
strings.HasPrefix(string(group.Source), string(GroupSourcePluginPrefix)) {
|
||||
isValidSource = true
|
||||
}
|
||||
|
||||
if !isValidSource {
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.source.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -232,12 +230,19 @@ func (group *Group) IsValidForCreate() *AppError {
|
||||
}
|
||||
|
||||
func (group *Group) requiresRemoteId() bool {
|
||||
for _, groupSource := range groupSourcesRequiringRemoteID {
|
||||
if groupSource == group.Source {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return group.Source == GroupSourceLdap || strings.HasPrefix(string(group.Source), string(GroupSourcePluginPrefix))
|
||||
}
|
||||
|
||||
func GetSyncableGroupSources() []GroupSource {
|
||||
return []GroupSource{GroupSourceLdap}
|
||||
}
|
||||
|
||||
func GetSyncableGroupSourcePrefixes() []GroupSource {
|
||||
return []GroupSource{GroupSourcePluginPrefix}
|
||||
}
|
||||
|
||||
func (group *Group) IsSyncable() bool {
|
||||
return group.Source == GroupSourceLdap || strings.HasPrefix(string(group.Source), string(GroupSourcePluginPrefix))
|
||||
}
|
||||
|
||||
func (group *Group) IsValidForUpdate() *AppError {
|
||||
|
||||
Ссылка в новой задаче
Block a user