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:
authorValery Sizov <valery@gitlab.com>2015-07-24 14:28:55 +0300
committerValery Sizov <valery@gitlab.com>2015-07-24 14:28:55 +0300
commit70de5114fbedf7c6a4557b10649003f5ccba6804 (patch)
tree073482203083c6f36346d8468c5aa94439b3adf0 /lib
parentf84ba4c0262a60fb5e1f507261fb35706da6eb2a (diff)
parent70a3c165a9f3882a82cf8946a783ace091635797 (diff)
Merge branch 'auth-icons-labels' into 'master'
Allow custom label to be set for authentication providers. Addresses internal issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2341 Beside the above, I've: - Refactored `OauthHelper` to have clearer method names and behaviour - Moved some of `OauthHelper` behaviour to `Gitlab::OAuth::Provider` - Renamed `OauthHelper` to `AuthHelper` since LDAP, SAML, Kerberos aren't OAuth - Updated the icons for GitHub and GitLab In the examples below, "OurAuth" is a SAML provider with a custom label. ![Screen_Shot_2015-07-02_at_16.29.52](https://gitlab.com/gitlab-org/gitlab-ce/uploads/7d425bde69dc34e1667ebd5375d0266d/Screen_Shot_2015-07-02_at_16.29.52.png) ![Screen_Shot_2015-07-02_at_16.31.40](https://gitlab.com/gitlab-org/gitlab-ce/uploads/cbb273321ecdf4cab3d3ef0dc35553e7/Screen_Shot_2015-07-02_at_16.31.40.png) ![Screen_Shot_2015-07-02_at_16.32.39](https://gitlab.com/gitlab-org/gitlab-ce/uploads/d8dd6e1d0dc45a788e869cdcdc99e178/Screen_Shot_2015-07-02_at_16.32.39.png) ![Screen_Shot_2015-07-02_at_16.33.18](https://gitlab.com/gitlab-org/gitlab-ce/uploads/7dbfe8b0ae229c32a08d6c7442976d83/Screen_Shot_2015-07-02_at_16.33.18.png) See merge request !927
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