Commit ef97cb54 authored by Rubén Dávila's avatar Rubén Dávila

Backport some recent changes related to LDAP from EE

parent 4eebd8e1
...@@ -23,12 +23,7 @@ class SessionsController < Devise::SessionsController ...@@ -23,12 +23,7 @@ class SessionsController < Devise::SessionsController
def new def new
set_minimum_password_length set_minimum_password_length
@ldap_servers = @ldap_servers = Gitlab::LDAP::Config.available_servers
if Gitlab.config.ldap.enabled
Gitlab::LDAP::Config.servers
else
[]
end
super super
end end
......
if Gitlab::LDAP::Config.enabled? if Gitlab::LDAP::Config.enabled?
module OmniAuth::Strategies module OmniAuth::Strategies
server = Gitlab.config.ldap.servers.values.first Gitlab::LDAP::Config.available_servers.each do |server|
klass = server['provider_class'] # do not redeclare LDAP
const_set(klass, Class.new(LDAP)) unless klass == 'LDAP' next if server['provider_name'] == 'ldap'
const_set(server['provider_class'], Class.new(LDAP))
end
end end
OmniauthCallbacksController.class_eval do OmniauthCallbacksController.class_eval do
server = Gitlab.config.ldap.servers.values.first Gitlab::LDAP::Config.available_servers.each do |server|
alias_method server['provider_name'], :ldap alias_method server['provider_name'], :ldap
end
end end
end end
......
...@@ -18,6 +18,12 @@ module Gitlab ...@@ -18,6 +18,12 @@ module Gitlab
Gitlab.config.ldap.servers.values Gitlab.config.ldap.servers.values
end end
def self.available_servers
return [] unless enabled?
Array.wrap(servers.first)
end
def self.providers def self.providers
servers.map { |server| server['provider_name'] } servers.map { |server| server['provider_name'] }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment