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
48
49
50
51
52
53
54
55
56
# 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'
  require 'sorcery/providers/paypal'
  require 'sorcery/providers/slack'
  require 'sorcery/providers/wechat'
  require 'sorcery/providers/microsoft'
  require 'sorcery/providers/instagram'
  require 'sorcery/providers/auth0'
  require 'sorcery/providers/line'
  require 'sorcery/providers/discord'
  require 'sorcery/providers/battlenet'

  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 <<-RUBY, __FILE__, __LINE__ + 1
            def self.#{name}
              @#{name} ||= Sorcery::Providers.const_get('#{name}'.to_s.camelcase).new
            end
          RUBY
        end
      end

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