Class: Gitlab::OAuth::Provider

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

Constant Summary collapse

LABELS =
{
  "github"         => "GitHub",
  "gitlab"         => "GitLab.com",
  "google_oauth2"  => "Google"
}.freeze

Class Method Summary collapse

Class Method Details

.config_for(name) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/gitlab/o_auth/provider.rb', line 22

def self.config_for(name)
  name = name.to_s
  if ldap_provider?(name)
    Gitlab::LDAP::Config.new(name).options
  else
    Gitlab.config.omniauth.providers.find { |provider| provider.name == name }
  end
end

.enabled?(name) ⇒ Boolean


14
15
16
# File 'lib/gitlab/o_auth/provider.rb', line 14

def self.enabled?(name)
  providers.include?(name.to_sym)
end

.label_for(name) ⇒ Object


31
32
33
34
35
# File 'lib/gitlab/o_auth/provider.rb', line 31

def self.label_for(name)
  name = name.to_s
  config = config_for(name)
  (config && config['label']) || LABELS[name] || name.titleize
end

.ldap_provider?(name) ⇒ Boolean


18
19
20
# File 'lib/gitlab/o_auth/provider.rb', line 18

def self.ldap_provider?(name)
  name.to_s.start_with?('ldap')
end

.providersObject


10
11
12
# File 'lib/gitlab/o_auth/provider.rb', line 10

def self.providers
  Devise.omniauth_providers
end