diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-07-02 16:33:38 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-07-23 15:20:12 +0200 |
commit | 70a3c165a9f3882a82cf8946a783ace091635797 (patch) | |
tree | 2d09f34639859b2eadf5b648ac42f55b2419ceb2 /lib | |
parent | 5dd4dea93baa6386ed860a50125dce3ca3890f16 (diff) | |
download | gitlab-ce-70a3c165a9f3882a82cf8946a783ace091635797.tar.gz |
Allow custom label to be set for authentication providers.auth-icons-labels
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/o_auth/provider.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/gitlab/o_auth/provider.rb b/lib/gitlab/o_auth/provider.rb index f986499a27c..90c3fe8da33 100644 --- a/lib/gitlab/o_auth/provider.rb +++ b/lib/gitlab/o_auth/provider.rb @@ -1,18 +1,30 @@ module Gitlab module OAuth class Provider - def self.names - providers = [] + def self.providers + Devise.omniauth_providers + end - Gitlab.config.ldap.servers.values.each do |server| - providers << server['provider_name'] - end + def self.enabled?(name) + providers.include?(name.to_sym) + end - Gitlab.config.omniauth.providers.each do |provider| - providers << provider['name'] + def self.ldap_provider?(name) + name.to_s.start_with?('ldap') + end + + 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 - providers + def self.label_for(name) + config = config_for(name) + (config && config['label']) || name.to_s.titleize end end end |