Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-07-02 17:33:38 +0300
committerDouwe Maan <douwe@gitlab.com>2015-07-23 16:20:12 +0300
commit70a3c165a9f3882a82cf8946a783ace091635797 (patch)
tree2d09f34639859b2eadf5b648ac42f55b2419ceb2 /lib
parent5dd4dea93baa6386ed860a50125dce3ca3890f16 (diff)
Allow custom label to be set for authentication providers.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/o_auth/provider.rb28
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