Commit 6999f717 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Introduce Gitlab::Auth.omniauth_setup_providers

Which could extend from EE
parent d46e0a3b
......@@ -19,10 +19,5 @@ end
if Gitlab.config.omniauth.enabled
provider_names = Gitlab.config.omniauth.providers.map(&:name)
require 'omniauth-kerberos' if provider_names.include?('kerberos')
require_dependency 'omni_auth/strategies/kerberos_spnego' if provider_names.include?('kerberos_spnego')
if provider_names.include?('group_saml')
OmniAuth.config.on_failure = ::Gitlab::Auth::GroupSaml::FailureHandler.new(OmniAuth.config.on_failure)
end
Gitlab::Auth.omniauth_setup_providers(provider_names)
end
module EE
module Gitlab
module Auth
extend ::Gitlab::Utils::Override
override :omniauth_customized_providers
def omniauth_customized_providers
@omniauth_customized_providers ||=
super.concat(%w[kerberos_spnego group_saml])
end
override :omniauth_setup_a_provider
def omniauth_setup_a_provider(provider)
super
if provider == 'group_saml'
OmniAuth.config.on_failure =
::Gitlab::Auth::GroupSaml::FailureHandler.new(
OmniAuth.config.on_failure)
end
end
def find_with_user_password(login, password)
if Devise.omniauth_providers.include?(:kerberos)
kerberos_user = ::Gitlab::Kerberos::Authentication.login(login, password)
......
......@@ -16,6 +16,25 @@ module Gitlab
class << self
prepend EE::Gitlab::Auth
def omniauth_customized_providers
@omniauth_customized_providers ||= %w[bitbucket jwt]
end
def omniauth_setup_providers(provider_names)
provider_names.each do |provider|
omniauth_setup_a_provider(provider)
end
end
def omniauth_setup_a_provider(provider)
case provider
when 'kerberos'
require 'omniauth-kerberos'
when *omniauth_customized_providers
require_dependency "omni_auth/strategies/#{provider}"
end
end
def find_for_git_client(login, password, project:, ip:)
raise "Must provide an IP for rate limiting" if ip.nil?
......
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