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

provider.rb « o_auth « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 90c3fe8da3339d10139e8a5a88eaacc633cf8eaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Gitlab
  module OAuth
    class Provider
      def self.providers
        Devise.omniauth_providers
      end

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

      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

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