summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/initializers/omniauth.rb8
-rw-r--r--lib/gitlab/auth.rb19
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:)