Class: Utopia::Session::EncryptedCookie
- Inherits:
-
Object
- Object
- Utopia::Session::EncryptedCookie
- Defined in:
- lib/utopia/session/encrypted_cookie.rb
Overview
Stores all session data client side using a private symmetric encrpytion key.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, **options) ⇒ EncryptedCookie
constructor
A new instance of EncryptedCookie.
Constructor Details
#initialize(app, **options) ⇒ EncryptedCookie
Returns a new instance of EncryptedCookie.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/utopia/session/encrypted_cookie.rb', line 31 def initialize(app, **) @app = app @cookie_name = .delete(:cookie_name) || (RACK_SESSION + ".encrypted") @secret = .delete(:secret) @options = { :domain => nil, :path => "/", :expires_after => nil }.merge() end |
Instance Method Details
#call(env) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/utopia/session/encrypted_cookie.rb', line 44 def call(env) session_hash = prepare_session(env) status, headers, body = @app.call(env) if session_hash.changed? commit(session_hash.values, headers) end return [status, headers, body] end |