Commit 9a68cad8 authored by Drew Blessing's avatar Drew Blessing

Add some additional checking for LDAP DNs in Group Sync

parent faad5120
require 'net/ldap/dn'
module Gitlab module Gitlab
module LDAP module LDAP
class GroupSync class GroupSync
...@@ -181,13 +183,17 @@ module Gitlab ...@@ -181,13 +183,17 @@ module Gitlab
# account for that. See gitlab-ee#442 # account for that. See gitlab-ee#442
def ensure_full_dns!(dns) def ensure_full_dns!(dns)
dns.map! do |dn| dns.map! do |dn|
# If there is more than one equal sign we must have a full DN parsed_dn = Net::LDAP::DN.new(dn).to_a
# Or at least the probability is higher. # If there is more than one key/value set we must have a full DN,
return dn if dn.count('=') > 1 # or at least the probability is higher.
if parsed_dn.count > 2
# If there is only one equal sign, we may only have a `uid`. dn
# In this case, strip the first part and look up full DN by UID elsif parsed_dn[0] == 'uid'
dn_for_uid(dn.split('=')[1]) dn_for_uid(parsed_dn[1])
else
logger.warn { "Found potentially malformed/incomplete DN: '#{dn}'" }
dn
end
end end
end end
......
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