diff options
-rw-r--r-- | app/controllers/sessions_controller.rb | 2 | ||||
-rw-r--r-- | app/views/devise/sessions/new.html.haml | 6 | ||||
-rw-r--r-- | config/gitlab.yml.example | 22 | ||||
-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 | ||||
-rw-r--r-- | lib/gitlab/ldap/config.rb | 6 |
7 files changed, 29 insertions, 29 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index e918f46bb3e..5ced98152a5 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -19,7 +19,7 @@ class SessionsController < Devise::SessionsController end if Gitlab.config.ldap.enabled - @ldap_servers = Gitlab.config.ldap.servers + @ldap_servers = Gitlab::LDAP::Config.servers end super diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 04e998f8be4..b9832787446 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -6,13 +6,13 @@ %ul.nav.nav-tabs - @ldap_servers.each_with_index do |server, i| %li{class: (:active if i==0)} - = link_to server['label'], "#tab-#{server.provider_name}", 'data-toggle' => 'tab' + = link_to server['label'], "#tab-#{server['provider_name']}", 'data-toggle' => 'tab' %li = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' .tab-content - @ldap_servers.each_with_index do |server,i| - %div.tab-pane{id: "tab-#{server.provider_name}", class: (:active if i==0)} - = render 'devise/sessions/new_ldap', provider: server.provider_name + %div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i==0)} + = render 'devise/sessions/new_ldap', provider: server['provider_name'] %div#tab-signin.tab-pane = render 'devise/sessions/new_base' diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 9302dca4ed8..59bd1442994 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -135,18 +135,16 @@ production: &base ldap: enabled: false servers: - - - ## provider_id - # - # This identifier is used by GitLab to keep track of which LDAP server each - # GitLab user belongs to. Each LDAP server known to GitLab should have a unique - # provider_id. This identifier cannot be changed once users from the LDAP server - # have started logging in to GitLab. - # - # Format: one word, using a-z (lower case) and 0-9 - # Example: 'paris' or 'uswest2' - - provider_id: main + ## provider id + # + # This identifier is used by GitLab to keep track of which LDAP server each + # GitLab user belongs to. Each LDAP server known to GitLab should have a unique + # provider id. This identifier cannot be changed once users from the LDAP server + # have started logging in to GitLab. + # + # Format: one word, using a-z (lower case) and 0-9 + # Example: 'paris' or 'uswest2' + main: ## label # 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'], diff --git a/lib/gitlab/ldap/config.rb b/lib/gitlab/ldap/config.rb index 697b66dcdaa..d41bfba9b0f 100644 --- a/lib/gitlab/ldap/config.rb +++ b/lib/gitlab/ldap/config.rb @@ -9,11 +9,11 @@ module Gitlab end def self.servers - Gitlab.config.ldap.servers + Gitlab.config.ldap.servers.values end def self.providers - servers.map &:provider_name + servers.map {|server| server['provider_name'] } end def initialize(provider) @@ -75,7 +75,7 @@ module Gitlab end def config_for(provider) - base_config.servers.find { |server| server.provider_name == provider } + base_config.servers.values.find { |server| server['provider_name'] == provider } end def encryption |