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

Defined in:
lib/sorcery/controller/submodules/external.rb,
lib/sorcery.rb,
lib/sorcery/controller/submodules/external/protocols/oauth1.rb,
lib/sorcery/controller/submodules/external/protocols/oauth2.rb,
lib/sorcery/controller/submodules/external/providers/github.rb,
lib/sorcery/controller/submodules/external/providers/twitter.rb,
lib/sorcery/controller/submodules/external/providers/facebook.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, Protocols, Providers

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
# File 'lib/sorcery/controller/submodules/external.rb', line 7

def self.included(base)
  base.send(:include, InstanceMethods)
  Config.module_eval do
    class << self
      attr_reader :external_providers                           # external providers like twitter.
      attr_accessor :ca_file                                    # path to ca_file. By default use a internal ca-bundle.crt.
                                  
      def merge_external_defaults!
        @defaults.merge!(:@external_providers => [],
                         :@ca_file => File.join(File.expand_path(File.dirname(__FILE__)), 'external/protocols/certs/ca-bundle.crt'))
      end
      
      def external_providers=(providers)
        providers.each do |provider|
          include Providers.const_get(provider.to_s.split("_").map {|p| p.capitalize}.join(""))
        end
      end
    end
    merge_external_defaults!
  end
end