2021-02-03 16:09:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
|
|
|
2022-04-18 23:09:43 -04:00
|
|
|
OmniAuth.config.full_host =
|
2022-05-06 11:09:03 -04:00
|
|
|
if Feature.feature_flags_available? && ::Feature.enabled?(:omniauth_initializer_fullhost_proc)
|
2022-04-18 23:09:43 -04:00
|
|
|
Gitlab::AppLogger.debug("Using OmniAuth proc initializer")
|
|
|
|
Gitlab::OmniauthInitializer.full_host
|
|
|
|
else
|
|
|
|
Gitlab::AppLogger.debug("Fallback to OmniAuth static full_host")
|
|
|
|
Settings.gitlab['base_url']
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
2021-08-03 17:09:39 -04:00
|
|
|
OmniAuth.config.logger = Gitlab::AppLogger
|