diff options
author | Jan-Willem van der Meer <mail@jewilmeer.nl> | 2014-10-14 13:11:53 +0200 |
---|---|---|
committer | Jan-Willem van der Meer <mail@jewilmeer.nl> | 2014-10-14 13:13:59 +0200 |
commit | 6ce65a3e950532e8fb65cf188eb5df9a6eddfb39 (patch) | |
tree | ace2949d72914b88506691910b940588db0f2e81 /config/initializers | |
parent | 9bf7bfda20a466b375a459b95068de8c0139fc9a (diff) | |
download | gitlab-ce-6ce65a3e950532e8fb65cf188eb5df9a6eddfb39.tar.gz |
Use Hash syntax for LDAP server declaration
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/1_settings.rb | 10 | ||||
-rw-r--r-- | config/initializers/7_omniauth.rb | 8 | ||||
-rw-r--r-- | config/initializers/devise.rb | 4 |
3 files changed, 12 insertions, 10 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index abd0c970554..7e7c91ced77 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -62,14 +62,16 @@ if Settings.ldap['enabled'] || Rails.env.test? if Settings.ldap['host'].present? server = Settings.ldap.except('sync_time') server['label'] = 'LDAP' - server['provider_id'] = '' - Settings.ldap['servers'] = [server] + server['provider_name'] = 'ldap' + Settings.ldap['servers'] = { + 'ldap' => server + } end - Settings.ldap['servers'].each do |server| + Settings.ldap['servers'].each do |key, server| 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['provider_name'] = "ldap#{server['provider_id']}".downcase + server['provider_name'] ||= "ldap#{key}".downcase server['provider_class'] = OmniAuth::Utils.camelize(server['provider_name']) end end diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb index 22e2d740fdc..7ef5c10da08 100644 --- a/config/initializers/7_omniauth.rb +++ b/config/initializers/7_omniauth.rb @@ -1,9 +1,9 @@ module OmniAuth::Strategies - server = Gitlab.config.ldap.servers.first - const_set(server.provider_class, Class.new(LDAP)) + server = Gitlab.config.ldap.servers.values.first + const_set(server['provider_class'], Class.new(LDAP)) end OmniauthCallbacksController.class_eval do - server = Gitlab.config.ldap.servers.first - alias_method server.provider_name, :ldap + server = Gitlab.config.ldap.servers.values.first + alias_method server['provider_name'], :ldap end
\ No newline at end of file diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 7770f018a15..226cacfe0d1 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -205,14 +205,14 @@ Devise.setup do |config| # end if Gitlab.config.ldap.enabled - Gitlab.config.ldap.servers.each do |server| + Gitlab.config.ldap.servers.values.each do |server| if server['allow_username_or_email_login'] email_stripping_proc = ->(name) {name.gsub(/@.*$/,'')} else email_stripping_proc = ->(name) {name} end - config.omniauth server.provider_name, + config.omniauth server['provider_name'], host: server['host'], base: server['base'], uid: server['uid'], |