Class: OmniAuth::Strategies::Pubcookie

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy, Rack::Pubcookie::Auth
Defined in:
lib/omniauth/strategies/pubcookie.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, *args, &block) ⇒ Pubcookie

Override initialize. Omniauth frowns on this but we need to set pubcookie_options on initialize



15
16
17
18
# File 'lib/omniauth/strategies/pubcookie.rb', line 15

def initialize(app, *args, &block)
  super(app, *args, &block)
  self.pubcookie_options = options
end

Instance Method Details

#callback_phaseObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/omniauth/strategies/pubcookie.rb', line 25

def callback_phase
  # Part of the pubcookie spec
  request.env['REMOTE_USER'] = raw_info[:username]

  if raw_info[:username]
    self.env['omniauth.auth'] = auth_hash # provided by Omniauth now
    request.env['REQUEST_METHOD'] = 'GET'

    status, headers, body = call_app!

    # Set the actual cookie for pubcookie, as per its spec
    response = Rack::Response.new body, status, headers
    set_pubcookie! request, response

    response.finish
  else
    fail! :login_failed
  end
end

#raw_infoObject



52
53
54
# File 'lib/omniauth/strategies/pubcookie.rb', line 52

def raw_info
  @raw_info ||= {:username => extract_username(request)}
end

#request_phaseObject



20
21
22
23
# File 'lib/omniauth/strategies/pubcookie.rb', line 20

def request_phase
  @raw_info = nil
  Rack::Response.new().finish
end