Class: Rack::Pubcookie

Inherits:
Object
  • Object
show all
Includes:
Auth
Defined in:
lib/rack/pubcookie.rb,
lib/rack/pubcookie/aes.rb,
lib/rack/pubcookie/des.rb,
lib/rack/pubcookie/auth.rb,
lib/rack/pubcookie/version.rb

Defined Under Namespace

Modules: AES, Auth, DES

Constant Summary collapse

VERSION =
'0.0.3'

Instance Method Summary collapse

Methods included from Auth

#callback_path, #extract_username, #login_page_html, #pubcookie_options=, #set_pubcookie!

Methods included from DES

#des_decrypt

Methods included from AES

#aes_decrypt

Constructor Details

#initialize(app, options) ⇒ Pubcookie

Returns a new instance of Pubcookie.



11
12
13
14
# File 'lib/rack/pubcookie.rb', line 11

def initialize app, options
  @app = app
  self.pubcookie_options = options
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rack/pubcookie.rb', line 16

def call env
  request = Rack::Request.new env

  if request.path == '/auth/pubcookie'
    response = Rack::Response.new 
  else
    request.env['REMOTE_USER'] = extract_username request
    status, headers, body = @app.call(request.env)
    response = Rack::Response.new body, status, headers

    set_pubcookie! request, response
  end

  response.finish
end