Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-10-05 13:47:48 +0300
committerMichael Kozono <mkozono@gmail.com>2017-10-07 20:28:13 +0300
commit8c29a04549d4a956508ef9a92a043a309978fa34 (patch)
tree419a20b968d1a8e458955e6a68c3cfc6c1201d47 /lib
parent1d1ad7e0b68039100029f20a84fd867fe92cbb32 (diff)
Leave bad DNs alone instead of raising errors
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ldap/auth_hash.rb2
-rw-r--r--lib/gitlab/ldap/person.rb11
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/gitlab/ldap/auth_hash.rb b/lib/gitlab/ldap/auth_hash.rb
index b173b879f5f..3123da17fd9 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::DN.new(super).to_normalized_s
+ Gitlab::LDAP::Person.normalize_dn(super)
end
private
diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb
index 81aa352e656..38d7a9ba2f5 100644
--- a/lib/gitlab/ldap/person.rb
+++ b/lib/gitlab/ldap/person.rb
@@ -36,6 +36,14 @@ module Gitlab
]
end
+ def self.normalize_dn(dn)
+ ::Gitlab::LDAP::DN.new(dn).to_normalized_s
+ rescue ::Gitlab::LDAP::DN::FormatError => e
+ Rails.logger.info("Returning original DN \"#{dn}\" due to error during normalization attempt: #{e.message}")
+
+ dn
+ end
+
# Returns the UID in a normalized form.
#
# 1. Excess spaces are stripped
@@ -44,7 +52,6 @@ module Gitlab
::Gitlab::LDAP::DN.normalize_value(uid)
rescue ::Gitlab::LDAP::DN::FormatError => e
Rails.logger.info("Returning original UID \"#{uid}\" due to error during normalization attempt: #{e.message}")
- Rails.logger.info(e.backtrace.join("\n"))
uid
end
@@ -72,7 +79,7 @@ module Gitlab
end
def dn
- DN.new(entry.dn).to_normalized_s
+ self.class.normalize_dn(entry.dn)
end
private