Introduce Gitlab::Auth.omniauth_setup_providers

Which could extend from EE
This commit is contained in:
Lin Jen-Shin 2018-06-01 14:05:07 +08:00
parent 39b6f31c66
commit 1e2b6cf514
2 changed files with 18 additions and 9 deletions

View File

@ -19,11 +19,5 @@ end
if Gitlab.config.omniauth.enabled
provider_names = Gitlab.config.omniauth.providers.map(&:name)
require 'omniauth-kerberos' if provider_names.include?('kerberos')
Gitlab::Auth.omniauth_providers.each do |provider|
if provider_names.include?(provider)
require_dependency "omni_auth/strategies/#{provider}"
end
end
Gitlab::Auth.omniauth_setup_providers(provider_names)
end

View File

@ -14,8 +14,23 @@ module Gitlab
DEFAULT_SCOPES = [:api].freeze
class << self
def omniauth_providers
%w[bitbucket jwt]
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:)