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