Commit da310025 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'backport-2844-ldap-ee-license-checks' into 'master'

Backport some recent changes related to LDAP from EE

See merge request !13119
parents 190fae5f ef97cb54
......@@ -23,12 +23,7 @@ class SessionsController < Devise::SessionsController
def new
set_minimum_password_length
@ldap_servers =
if Gitlab.config.ldap.enabled
Gitlab::LDAP::Config.servers
else
[]
end
@ldap_servers = Gitlab::LDAP::Config.available_servers
super
end
......
if Gitlab::LDAP::Config.enabled?
module OmniAuth::Strategies
server = Gitlab.config.ldap.servers.values.first
klass = server['provider_class']
const_set(klass, Class.new(LDAP)) unless klass == 'LDAP'
Gitlab::LDAP::Config.available_servers.each do |server|
# do not redeclare LDAP
next if server['provider_name'] == 'ldap'
const_set(server['provider_class'], Class.new(LDAP))
end
end
OmniauthCallbacksController.class_eval do
server = Gitlab.config.ldap.servers.values.first
alias_method server['provider_name'], :ldap
Gitlab::LDAP::Config.available_servers.each do |server|
alias_method server['provider_name'], :ldap
end
end
end
......
......@@ -18,6 +18,12 @@ module Gitlab
Gitlab.config.ldap.servers.values
end
def self.available_servers
return [] unless enabled?
Array.wrap(servers.first)
end
def self.providers
servers.map { |server| server['provider_name'] }
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