diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-09-20 17:28:57 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-10-07 10:28:13 -0700 |
commit | 45ab20dca91024602e7c73814e8ff89df2000189 (patch) | |
tree | 66b2016cf703177a8e838edcd6f6876bff408413 /lib | |
parent | fe46c11de81e122433b1b275a1078840b289dfcd (diff) | |
download | gitlab-ce-45ab20dca91024602e7c73814e8ff89df2000189.tar.gz |
Switch to new DN class
for normalizing and parsing DNs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ldap/auth_hash.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ldap/person.rb | 17 |
2 files changed, 2 insertions, 17 deletions
diff --git a/lib/gitlab/ldap/auth_hash.rb b/lib/gitlab/ldap/auth_hash.rb index 3123da17fd9..2ea0a51b18f 100644 --- a/lib/gitlab/ldap/auth_hash.rb +++ b/lib/gitlab/ldap/auth_hash.rb @@ -4,7 +4,7 @@ module Gitlab module LDAP class AuthHash < Gitlab::OAuth::AuthHash def uid - Gitlab::LDAP::Person.normalize_dn(super) + Gitlab::LDAP::DN.new(super).to_s_normalized end private diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb index 6b1a308d521..44cb6a065c9 100644 --- a/lib/gitlab/ldap/person.rb +++ b/lib/gitlab/ldap/person.rb @@ -49,21 +49,6 @@ module Gitlab uid end - # Returns the DN in a normalized form. - # - # 1. Excess spaces around attribute names and values are stripped - # 2. The string is downcased (for case-insensitivity) - def self.normalize_dn(dn) - dn.split(/(?<!\\)([,+=])/).map do |part| - normalize_dn_part(part) - end.join('') - rescue StandardError => e - Rails.logger.info("Returning original DN \"#{dn}\" due to error during normalization attempt: #{e.message}") - Rails.logger.info(e.backtrace.join("\n")) - - dn - end - def initialize(entry, provider) Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } @entry = entry @@ -87,7 +72,7 @@ module Gitlab end def dn - self.class.normalize_dn(entry.dn) + DN.new(entry.dn).to_s_normalized end private |