Module: Sorcery::Controller::Submodules::External

Defined in:
lib/sorcery/controller/submodules/external.rb

Overview

This submodule helps you login users from external auth providers such as Twitter. This is the controller part which handles the http requests and tokens passed between the app and the @provider.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sorcery/controller/submodules/external.rb', line 7

def self.included(base)
  base.send(:include, InstanceMethods)

  require 'sorcery/providers/base'
  require 'sorcery/providers/facebook'
  require 'sorcery/providers/twitter'
  require 'sorcery/providers/vk'
  require 'sorcery/providers/linkedin'
  require 'sorcery/providers/liveid'
  require 'sorcery/providers/xing'
  require 'sorcery/providers/github'
  require 'sorcery/providers/heroku'
  require 'sorcery/providers/google'
  require 'sorcery/providers/jira'
  require 'sorcery/providers/salesforce'

  Config.module_eval do
    class << self
      attr_reader :external_providers
      attr_accessor :ca_file

      def external_providers=(providers)
        @external_providers = providers

        providers.each do |name|
          class_eval "def self.\#{name}\n@\#{name} ||= Sorcery::Providers.const_get('\#{name}'.to_s.capitalize).new\nend\n"
        end
      end

      def merge_external_defaults!
        @defaults.merge!(:@external_providers => [],
                         :@ca_file => File.join(File.expand_path(File.dirname(__FILE__)), '../../protocols/certs/ca-bundle.crt'))
      end
    end
    merge_external_defaults!
  end
end