Class: Rack::Session::EncryptedCookie
- Inherits:
-
Object
- Object
- Rack::Session::EncryptedCookie
show all
- Defined in:
- lib/rack/session/encryptedcookie.rb
Constant Summary
collapse
- NOT_FOUND =
[ 404, {}, [ 'Not found' ]].freeze
Instance Method Summary
collapse
Constructor Details
If :domain is nil, the Host header from the request will be used to determine the domain sent for the cookie.
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rack/session/encryptedcookie.rb', line 34
def initialize(app, opts={})
@app = app
@hash = {}
@opts = {
cookie_name: 'rack.session',
domain: nil,
http_only: false,
expires: (15 * 60),
cipher: 'aes-256-cbc',
salt: '3@bG>B@J5vy-FeXJ',
rounds: 2000,
key: 'r`*BqnG:c^;AL{k97=KYN!#',
tag_len: 16,
clear_cookies: false
}.merge(opts)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/rack/session/encryptedcookie.rb', line 68
def method_missing(method, *args, &block)
if @hash.respond_to?(method)
@hash.send(method, *args, &block)
else
raise ArgumentError.new("Method `#{method}` doesn't exist.")
end
end
|
Instance Method Details
#call(env) ⇒ Object
51
52
53
|
# File 'lib/rack/session/encryptedcookie.rb', line 51
def call(env)
dup.call!(env)
end
|
#call!(env) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/rack/session/encryptedcookie.rb', line 55
def call!(env)
@cb = env['async.callback']
env['async.callback'] = method(:save_session) if @cb
env['rack.session'] = self
load_session(env)
if @app
@cb ? @app.call(env) : save_session(@app.call(env))
else
@cb ? @cb.call(NOT_FOUND) : NOT_FOUND
end
end
|