BigW Consortium Gitlab

provider.rb 694 Bytes
Newer Older
1 2 3
module Gitlab
  module OAuth
    class Provider
4 5 6
      def self.providers
        Devise.omniauth_providers
      end
7

8 9 10
      def self.enabled?(name)
        providers.include?(name.to_sym)
      end
11

12 13 14 15 16 17 18 19 20 21
      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 }
22
        end
23
      end
24

25 26 27
      def self.label_for(name)
        config = config_for(name)
        (config && config['label']) || name.to_s.titleize
28 29 30 31
      end
    end
  end
end