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
- #callback_phase ⇒ Object
- #callback_url ⇒ Object
- #fail!(message_key) ⇒ 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
46 47 48 49 50 51 |
# File 'lib/omniauth/strategy.rb', line 46 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 @app.call(env) end end end |
#callback_phase ⇒ Object
41 42 43 44 |
# File 'lib/omniauth/strategy.rb', line 41 def callback_phase request['auth'] = auth_hash @app.call(env) end |
#callback_url ⇒ Object
60 61 62 |
# File 'lib/omniauth/strategy.rb', line 60 def callback_url full_host + "#{OmniAuth.config.path_prefix}/#{name}/callback" end |
#fail!(message_key) ⇒ Object
80 81 82 |
# File 'lib/omniauth/strategy.rb', line 80 def fail!() OmniAuth.config.on_failure.call(self.env, .to_sym) end |
#full_host ⇒ Object
53 54 55 56 57 58 |
# File 'lib/omniauth/strategy.rb', line 53 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
72 73 74 75 76 |
# File 'lib/omniauth/strategy.rb', line 72 def redirect(uri) r = Rack::Response.new("Redirecting to #{uri}...") r.redirect(uri) r.finish end |
#request ⇒ Object
68 69 70 |
# File 'lib/omniauth/strategy.rb', line 68 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
64 65 66 |
# File 'lib/omniauth/strategy.rb', line 64 def session @env['rack.session'] end |
#user_info ⇒ Object
78 |
# File 'lib/omniauth/strategy.rb', line 78 def user_info; {} end |