diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-07-13 13:39:31 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-07-20 13:54:46 +0300 |
commit | d0afab482f1157d0b41631cb4dbdfdfeadabb7c8 (patch) | |
tree | 5ac1f6769b6ee311878d0c7d2960414c26ce7f54 /lib/gitlab/omniauth_initializer.rb | |
parent | 8895863cf340a8a6c9a708dc864af77fe48beaaa (diff) |
Disable SAML if OmniAuth is disabled
We also try to unify the way we setup OmniAuth, and how we check
if it's enabled or not.
Diffstat (limited to 'lib/gitlab/omniauth_initializer.rb')
-rw-r--r-- | lib/gitlab/omniauth_initializer.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/gitlab/omniauth_initializer.rb b/lib/gitlab/omniauth_initializer.rb index a71acda8701..f33ea0880df 100644 --- a/lib/gitlab/omniauth_initializer.rb +++ b/lib/gitlab/omniauth_initializer.rb @@ -1,23 +1,21 @@ module Gitlab class OmniauthInitializer - def self.enabled? - Gitlab.config.omniauth.enabled || - Gitlab.config.omniauth.auto_sign_in_with_provider.present? - end - def initialize(devise_config) @devise_config = devise_config end def execute(providers) providers.each do |provider| - add_provider(provider['name'].to_sym, *arguments_for(provider)) + name = provider['name'].to_sym + + add_provider_to_devise(name, *arguments_for(provider)) + setup_provider(name) end end private - def add_provider(*args) + def add_provider_to_devise(*args) @devise_config.omniauth(*args) end @@ -76,5 +74,23 @@ module Gitlab end end end + + def omniauth_customized_providers + @omniauth_customized_providers ||= build_omniauth_customized_providers + end + + # We override this in EE + def build_omniauth_customized_providers + %i[bitbucket jwt] + end + + def setup_provider(provider) + case provider + when :kerberos + require 'omniauth-kerberos' + when *omniauth_customized_providers + require_dependency "omni_auth/strategies/#{provider}" + end + end end end |