summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-08 17:34:18 +0100
committerDouwe Maan <douwe@gitlab.com>2015-09-08 17:34:18 +0100
commit0e9ba0a4fa3a2e8335e7b902dd50710e2309773f (patch)
tree4005bafc62781ee9cb74565034963fd4f28e88d9
parentc915e2c8237ddcae57ec48e700badd9d5bfd8c8c (diff)
downloadgitlab-ce-0e9ba0a4fa3a2e8335e7b902dd50710e2309773f.tar.gz
Add attributes to LDAP::Config.
-rw-r--r--config/initializers/1_settings.rb1
-rw-r--r--lib/gitlab/ldap/config.rb4
-rw-r--r--lib/gitlab/ldap/user.rb7
-rw-r--r--spec/lib/gitlab/ldap/user_spec.rb2
4 files changed, 10 insertions, 4 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index c47e5dab27c..c23f00a6f05 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -97,6 +97,7 @@ if Settings.ldap['enabled'] || Rails.env.test?
server['block_auto_created_users'] = false if server['block_auto_created_users'].nil?
server['allow_username_or_email_login'] = false if server['allow_username_or_email_login'].nil?
server['active_directory'] = true if server['active_directory'].nil?
+ server['attributes'] = {} if server['attributes'].nil?
server['provider_name'] ||= "ldap#{key}".downcase
server['provider_class'] = OmniAuth::Utils.camelize(server['provider_name'])
end
diff --git a/lib/gitlab/ldap/config.rb b/lib/gitlab/ldap/config.rb
index d2ffa2e1fe8..101a3285f4b 100644
--- a/lib/gitlab/ldap/config.rb
+++ b/lib/gitlab/ldap/config.rb
@@ -84,6 +84,10 @@ module Gitlab
options['block_auto_created_users']
end
+ def attributes
+ options['attributes']
+ end
+
protected
def base_config
Gitlab.config.ldap
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb
index e568b0e3b31..e5023f5da11 100644
--- a/lib/gitlab/ldap/user.rb
+++ b/lib/gitlab/ldap/user.rb
@@ -68,12 +68,13 @@ module Gitlab
Gitlab::LDAP::Access.allowed?(gl_user)
end
- def ldap_config
- Gitlab::LDAP::Config.new(auth_hash.provider)
+ def ldap_config(provider = auth_hash.provider)
+ Gitlab::LDAP::Config.new(provider)
end
def auth_hash=(auth_hash)
- @auth_hash = Gitlab::LDAP::AuthHash.new(auth_hash, ldap_config)
+ config = ldap_config(auth_hash.provider)
+ @auth_hash = Gitlab::LDAP::AuthHash.new(auth_hash, config)
end
end
end
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb
index 84d9fb54b61..fd2e5f6d0e1 100644
--- a/spec/lib/gitlab/ldap/user_spec.rb
+++ b/spec/lib/gitlab/ldap/user_spec.rb
@@ -11,7 +11,7 @@ describe Gitlab::LDAP::User do
}
end
let(:auth_hash) do
- double(uid: 'my-uid', provider: 'ldapmain', info: double(info))
+ OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info)
end
describe :changed? do