Module: OmniAuth::Strategy
- Included in:
- OmniAuth::Strategies::Password
- Defined in:
- lib/omniauth/strategy.rb
Class Method Summary collapse
Instance Method Summary collapse
- #auth_hash ⇒ Object
- #call(env) ⇒ Object
- #call!(env) ⇒ Object
- #call_app! ⇒ Object
- #callback_phase ⇒ Object
- #callback_url ⇒ Object
- #fail!(message_key, exception = nil) ⇒ Object
- #full_host ⇒ Object
- #initialize(app, name, *args) ⇒ Object
- #redirect(uri) ⇒ Object
- #request ⇒ Object
- #request_phase ⇒ Object
- #session ⇒ Object
- #user_info ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 |
# File 'lib/omniauth/strategy.rb', line 7 def self.included(base) base.class_eval do attr_reader :app, :name, :env end end |
Instance Method Details
#auth_hash ⇒ Object
53 54 55 56 57 58 |
# File 'lib/omniauth/strategy.rb', line 53 def auth_hash { 'provider' => name.to_s, 'uid' => nil } end |
#call(env) ⇒ Object
18 19 20 |
# File 'lib/omniauth/strategy.rb', line 18 def call(env) dup.call!(env) end |
#call!(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/strategy.rb', line 22 def call!(env) @env = env if request.path == "#{OmniAuth.config.path_prefix}/#{name}" request_phase elsif request.path == "#{OmniAuth.config.path_prefix}/#{name}/callback" callback_phase else if respond_to?(:other_phase) other_phase else call_app! end end end |
#call_app! ⇒ Object
46 47 48 49 50 51 |
# File 'lib/omniauth/strategy.rb', line 46 def call_app! @env['rack.auth'] = env['omniauth.auth'] if env.key?('omniauth.auth') @env['rack.auth.error'] = env['omniauth.error'] if env.key?('omniauth.error') @app.call(@env) end |
#callback_phase ⇒ Object
41 42 43 44 |
# File 'lib/omniauth/strategy.rb', line 41 def callback_phase @env['omniauth.auth'] = auth_hash call_app! end |
#callback_url ⇒ Object
67 68 69 |
# File 'lib/omniauth/strategy.rb', line 67 def callback_url full_host + "#{OmniAuth.config.path_prefix}/#{name}/callback" end |
#fail!(message_key, exception = nil) ⇒ Object
87 88 89 90 |
# File 'lib/omniauth/strategy.rb', line 87 def fail!(, exception = nil) self.env['omniauth.error'] = exception OmniAuth.config.on_failure.call(self.env, .to_sym) end |
#full_host ⇒ Object
60 61 62 63 64 65 |
# File 'lib/omniauth/strategy.rb', line 60 def full_host uri = URI.parse(request.url) uri.path = '' uri.query = nil uri.to_s end |
#initialize(app, name, *args) ⇒ Object
13 14 15 16 |
# File 'lib/omniauth/strategy.rb', line 13 def initialize(app, name, *args) @app = app @name = name.to_sym end |
#redirect(uri) ⇒ Object
79 80 81 82 83 |
# File 'lib/omniauth/strategy.rb', line 79 def redirect(uri) r = Rack::Response.new("Redirecting to #{uri}...") r.redirect(uri) r.finish end |
#request ⇒ Object
75 76 77 |
# File 'lib/omniauth/strategy.rb', line 75 def request @request ||= Rack::Request.new(@env) end |
#request_phase ⇒ Object
37 38 39 |
# File 'lib/omniauth/strategy.rb', line 37 def request_phase raise NotImplementedError end |
#session ⇒ Object
71 72 73 |
# File 'lib/omniauth/strategy.rb', line 71 def session @env['rack.session'] end |
#user_info ⇒ Object
85 |
# File 'lib/omniauth/strategy.rb', line 85 def user_info; {} end |