Пример #1
0
func (o *SyncGroupsOptions) GetGroupLister(syncBuilder SyncBuilder, clientConfig *ldaputil.LDAPClientConfig) (interfaces.LDAPGroupLister, error) {
	// if we have a whitelist, it trumps alls
	if len(o.WhitelistContents) != 0 {
		if o.Source == GroupSyncSourceOpenShift {
			return syncgroups.NewOpenShiftWhitelistGroupLister(o.WhitelistContents, o.GroupInterface), nil
		}
		return syncgroups.NewLDAPWhitelistGroupLister(o.WhitelistContents), nil
	}

	// openshift as a listing source works the same for all schemas
	if o.Source == GroupSyncSourceOpenShift {
		return syncgroups.NewAllOpenShiftGroupLister(clientConfig.Host, o.GroupInterface), nil
	}

	return syncBuilder.GetGroupLister()
}
Пример #2
0
func getLDAPGroupLister(syncBuilder SyncBuilder, info GroupNameRestrictions) (interfaces.LDAPGroupLister, error) {
	if len(info.GetWhitelist()) != 0 {
		ldapWhitelist := syncgroups.NewLDAPWhitelistGroupLister(info.GetWhitelist())
		if len(info.GetBlacklist()) == 0 {
			return ldapWhitelist, nil
		}
		return syncgroups.NewLDAPBlacklistGroupLister(info.GetBlacklist(), ldapWhitelist), nil
	}

	syncLister, err := syncBuilder.GetGroupLister()
	if err != nil {
		return nil, err
	}
	if len(info.GetBlacklist()) == 0 {
		return syncLister, nil
	}

	return syncgroups.NewLDAPBlacklistGroupLister(info.GetBlacklist(), syncLister), nil
}
Пример #3
0
func (o *SyncGroupsOptions) GetLDAPGroupLister(syncBuilder SyncBuilder) (interfaces.LDAPGroupLister, error) {
	if o.Source != GroupSyncSourceLDAP {
		return nil, errors.New("ldap is not a valid group source for this config")
	}

	if len(o.Whitelist) != 0 {
		ldapWhitelist := syncgroups.NewLDAPWhitelistGroupLister(o.Whitelist)
		if len(o.Blacklist) == 0 {
			return ldapWhitelist, nil
		}
		return syncgroups.NewLDAPBlacklistGroupLister(o.Blacklist, ldapWhitelist), nil
	}

	syncLister, err := syncBuilder.GetGroupLister()
	if err != nil {
		return nil, err
	}
	if len(o.Blacklist) == 0 {
		return syncLister, nil
	}

	return syncgroups.NewLDAPBlacklistGroupLister(o.Blacklist, syncLister), nil
}