summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Blessing <drew@gitlab.com>2018-01-25 16:18:15 -0600
committerDrew Blessing <drew@gitlab.com>2018-02-13 08:42:40 -0600
commitb45c7dd5fecd33d1fbc9053cb353d7ed0c6d57dd (patch)
tree42e72062303e77e28fc7729b5dc214f4fb4a6e3c
parent7a18675c59d46da7234dd0cdf6960b527b513a80 (diff)
downloadgitlab-ce-b45c7dd5fecd33d1fbc9053cb353d7ed0c6d57dd.tar.gz
Revert problematic LDAP person validation that threw exceptions
Constructors shouldn't throw exceptions. We also learned that different LDAP servers behave a bit unexpectedly sometimes - returning attributes we didn't ask for, or returned attributes with language subtypes.
-rw-r--r--changelogs/unreleased/remove_ldap_person_validation.yml5
-rw-r--r--lib/gitlab/ldap/person.rb15
-rw-r--r--spec/lib/gitlab/ldap/person_spec.rb9
3 files changed, 5 insertions, 24 deletions
diff --git a/changelogs/unreleased/remove_ldap_person_validation.yml b/changelogs/unreleased/remove_ldap_person_validation.yml
new file mode 100644
index 00000000000..da7f0a52886
--- /dev/null
+++ b/changelogs/unreleased/remove_ldap_person_validation.yml
@@ -0,0 +1,5 @@
+---
+title: LDAP Person no longer throws exception on invalid entry
+merge_request:
+author:
+type: fixed
diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb
index e81cec6ba1a..ec41f0ea090 100644
--- a/lib/gitlab/ldap/person.rb
+++ b/lib/gitlab/ldap/person.rb
@@ -63,8 +63,6 @@ module Gitlab
Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" }
@entry = entry
@provider = provider
-
- validate_entry
end
def name
@@ -115,19 +113,6 @@ module Gitlab
entry.public_send(selected_attr) # rubocop:disable GitlabSecurity/PublicSend
end
-
- def validate_entry
- allowed_attrs = self.class.ldap_attributes(config).map(&:downcase)
-
- # Net::LDAP::Entry transforms keys to symbols. Change to strings to compare.
- entry_attrs = entry.attribute_names.map { |n| n.to_s.downcase }
- invalid_attrs = entry_attrs - allowed_attrs
-
- if invalid_attrs.any?
- raise InvalidEntryError,
- "#{self.class.name} initialized with Net::LDAP::Entry containing invalid attributes(s): #{invalid_attrs}"
- end
- end
end
end
end
diff --git a/spec/lib/gitlab/ldap/person_spec.rb b/spec/lib/gitlab/ldap/person_spec.rb
index ff29d9aa5be..381bf2bc0e0 100644
--- a/spec/lib/gitlab/ldap/person_spec.rb
+++ b/spec/lib/gitlab/ldap/person_spec.rb
@@ -66,15 +66,6 @@ describe Gitlab::LDAP::Person do
end
end
- describe '.validate_entry' do
- it 'raises InvalidEntryError' do
- entry['foo'] = 'bar'
-
- expect { described_class.new(entry, 'ldapmain') }
- .to raise_error(Gitlab::LDAP::Person::InvalidEntryError)
- end
- end
-
describe '#name' do
it 'uses the configured name attribute and handles values as an array' do
name = 'John Doe'