Class: Gitlab::OmniauthInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/omniauth_initializer.rb

Constant Summary collapse

OAUTH2_TIMEOUT_SECONDS =
10
ConfigurationError =
Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(devise_config) ⇒ OmniauthInitializer

Returns a new instance of OmniauthInitializer.


8
9
10
# File 'lib/gitlab/omniauth_initializer.rb', line 8

def initialize(devise_config)
  @devise_config = devise_config
end

Class Method Details

.default_arguments_for(provider_name) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gitlab/omniauth_initializer.rb', line 22

def default_arguments_for(provider_name)
  case provider_name
  when 'cas3'
    { on_single_sign_out: cas3_signout_handler }
  when 'authentiq'
    { remote_sign_out_handler: authentiq_signout_handler }
  when 'shibboleth'
    { fail_with_empty_uid: true }
  when 'google_oauth2'
    { client_options: { connection_opts: { request: { timeout: OAUTH2_TIMEOUT_SECONDS } } } }
  when 'gitlab'
    {
      authorize_params: { gl_auth_type: 'login' }
    }
  else
    {}
  end
end

.full_hostObject


41
42
43
# File 'lib/gitlab/omniauth_initializer.rb', line 41

def full_host
  proc { |_env| Settings.gitlab['base_url'] }
end

Instance Method Details

#execute(providers) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/gitlab/omniauth_initializer.rb', line 12

def execute(providers)
  providers.each do |provider|
    name = provider['name'].to_sym

    add_provider_to_devise(name, *arguments_for(provider))
    setup_provider(name)
  end
end