diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-06-01 14:05:07 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-06-01 14:30:10 +0800 |
commit | 1e2b6cf514bcefd21520fef63b3fee5a29d334cd (patch) | |
tree | 462fc79ea4dd3b80af793f35a69ee0c5bf8bbc1e | |
parent | 39b6f31c66ff51451033ff84a2832731065cd28d (diff) | |
download | gitlab-ce-1e2b6cf514bcefd21520fef63b3fee5a29d334cd.tar.gz |
Introduce Gitlab::Auth.omniauth_setup_providers
Which could extend from EE
-rw-r--r-- | config/initializers/omniauth.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/auth.rb | 19 |
2 files changed, 18 insertions, 9 deletions
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index a93a43d88ee..a7fa926a853 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -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 diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 7047724cfe1..0f7a7b0ce8d 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -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:) |