Commit 4a298648 authored by Imre Farkas's avatar Imre Farkas

Merge branch '36753-dashes-not-supported-in-cn-for-ldap-group-sync-on-first-login' into 'master'

Resolve "Dashes not supported in CN for LDAP Group Sync on first login"

Closes #36753

See merge request gitlab-org/gitlab!20402
parents 59ec1084 4f97eb9f
---
title: Support dashes in LDAP group CN for sync on users first log in
merge_request: 20402
author:
type: fixed
......@@ -91,7 +91,7 @@ module EE
def cn_from_memberof(memberof)
# Only get the first CN value of the string, that's the one that contains
# the group name
memberof.match(/(?:cn=([\w\s]+))/i)&.captures&.first
memberof.match(/(?:cn=([\w\s-]+))/i)&.captures&.first
end
end
end
......
......@@ -232,7 +232,7 @@ describe Gitlab::Auth::LDAP::Person do
it 'gets the group cn from the memberof value' do
person = described_class.new(entry, 'ldapmain')
expect(person.cn_from_memberof('cN=Group Policy Creator Owners,CN=Users,DC=Vosmaer,DC=com'))
expect(person.cn_from_memberof('CN=Group Policy Creator Owners,CN=Users,DC=Vosmaer,DC=com'))
.to eq('Group Policy Creator Owners')
end
......@@ -242,6 +242,13 @@ describe Gitlab::Auth::LDAP::Person do
expect(person.cn_from_memberof('DC=Vosmaer,DC=com'))
.to be_nil
end
it "supports dashes in the group cn" do
person = described_class.new(entry, 'ldapmain')
expect(person.cn_from_memberof('CN=Group-Policy-Creator-Owners,CN=Users,DC=Vosmaer,DC=com'))
.to eq('Group-Policy-Creator-Owners')
end
end
describe '#group_cns' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment