mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 01:27:49 +01:00
Merge pull request #9493 from stonezdj/remove_nested_group
Remove nested group search
This commit is contained in:
commit
3772ccc163
@ -221,26 +221,6 @@ func (session *Session) SearchUser(username string) ([]models.LdapUser, error) {
|
||||
u.GroupDNList = groupDNList
|
||||
}
|
||||
|
||||
log.Debugf("Searching for nested groups")
|
||||
nestedGroupDNList := []string{}
|
||||
nestedGroupFilter := createNestedGroupFilter(ldapEntry.DN)
|
||||
result, err := session.SearchLdap(nestedGroupFilter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, groupEntry := range result.Entries {
|
||||
if !contains(u.GroupDNList, groupEntry.DN) {
|
||||
nestedGroupDNList = append(nestedGroupDNList, strings.TrimSpace(groupEntry.DN))
|
||||
log.Debugf("Found group %v", groupEntry.DN)
|
||||
} else {
|
||||
log.Debugf("%v is already in GroupDNList", groupEntry.DN)
|
||||
}
|
||||
}
|
||||
|
||||
u.GroupDNList = append(u.GroupDNList, nestedGroupDNList...)
|
||||
log.Debugf("Done searching for nested groups")
|
||||
|
||||
u.DN = ldapEntry.DN
|
||||
ldapUsers = append(ldapUsers, u)
|
||||
|
||||
@ -442,12 +422,6 @@ func createGroupSearchFilter(oldFilter, groupName, groupNameAttribute string) st
|
||||
return filter
|
||||
}
|
||||
|
||||
func createNestedGroupFilter(userDN string) string {
|
||||
filter := ""
|
||||
filter = "(&(objectClass=group)(member:1.2.840.113556.1.4.1941:=" + goldap.EscapeFilter(userDN) + "))"
|
||||
return filter
|
||||
}
|
||||
|
||||
func contains(s []string, e string) bool {
|
||||
for _, a := range s {
|
||||
if a == e {
|
||||
|
Loading…
Reference in New Issue
Block a user