2020-03-12 11:09:39 -04:00
|
|
|
if Gitlab::Auth::Ldap::Config.enabled?
|
2014-10-15 03:53:16 -04:00
|
|
|
module OmniAuth::Strategies
|
2020-03-12 11:09:39 -04:00
|
|
|
Gitlab::Auth::Ldap::Config.available_servers.each do |server|
|
2017-07-26 19:12:20 -04:00
|
|
|
# do not redeclare LDAP
|
|
|
|
next if server['provider_name'] == 'ldap'
|
2017-11-14 04:02:39 -05:00
|
|
|
|
2017-07-26 19:12:20 -04:00
|
|
|
const_set(server['provider_class'], Class.new(LDAP))
|
|
|
|
end
|
2014-10-15 03:53:16 -04:00
|
|
|
end
|
2015-02-03 00:53:27 -05:00
|
|
|
end
|
2015-04-24 11:03:18 -04:00
|
|
|
|
2015-08-23 16:31:02 -04:00
|
|
|
OmniAuth.config.full_host = Settings.gitlab['base_url']
|
2015-04-24 11:03:18 -04:00
|
|
|
OmniAuth.config.allowed_request_methods = [:post]
|
2016-05-31 18:33:46 -04:00
|
|
|
# In case of auto sign-in, the GET method is used (users don't get to click on a button)
|
2015-05-27 11:40:21 -04:00
|
|
|
OmniAuth.config.allowed_request_methods << :get if Gitlab.config.omniauth.auto_sign_in_with_provider.present?
|
2015-04-24 11:03:18 -04:00
|
|
|
OmniAuth.config.before_request_phase do |env|
|
2017-06-22 01:19:14 -04:00
|
|
|
Gitlab::RequestForgeryProtection.call(env)
|
2015-04-24 11:03:18 -04:00
|
|
|
end
|
2020-02-24 04:08:51 -05:00
|
|
|
|
|
|
|
# Use json formatter
|
|
|
|
OmniAuth.config.logger.formatter = Gitlab::OmniauthLogging::JSONFormatter.new
|
|
|
|
OmniAuth.config.logger.level = Logger::ERROR if Rails.env.production?
|