mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 19:29:54 +00:00
Lowercase the LDAP DN in UnderBaseDN
Fixes #13362: Unable to add LDAP group with different letter case in DN Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
parent
d55f55aeb9
commit
ca245d3545
|
@ -434,11 +434,11 @@ func (session *Session) searchGroup(groupDN, filter, gName, groupNameAttribute s
|
|||
|
||||
// UnderBaseDN - check if the childDN is under the baseDN, if the baseDN equals current DN, return true
|
||||
func UnderBaseDN(baseDN, childDN string) (bool, error) {
|
||||
base, err := goldap.ParseDN(baseDN)
|
||||
base, err := goldap.ParseDN(strings.ToLower(baseDN))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
child, err := goldap.ParseDN(childDN)
|
||||
child, err := goldap.ParseDN(strings.ToLower(childDN))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
@ -517,6 +517,12 @@ func TestUnderBaseDN(t *testing.T) {
|
|||
wantError: true,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: `should be case-insensitive`,
|
||||
in: args{"CN=Users,CN=harbor,DC=com", "cn=harbor_group_1,cn=users,cn=harbor,dc=com"},
|
||||
wantError: false,
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user