Class: Gitlab::OmniauthInitializer

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

Constant Summary collapse

OAUTH2_TIMEOUT_SECONDS =
10

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(devise_config) ⇒ OmniauthInitializer

Returns a new instance of OmniauthInitializer.


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

def initialize(devise_config)
  @devise_config = devise_config
end

Class Method Details

.default_arguments_for(provider_name) ⇒ Object


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

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 } } } }
  else
    {}
  end
end

Instance Method Details

#execute(providers) ⇒ Object


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

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