Class: Utopia::Session::EncryptedCookie

Inherits:
Object
  • Object
show all
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

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, **options)
	@app = app
	@cookie_name = options.delete(:cookie_name) || (RACK_SESSION + ".encrypted")

	@secret = options.delete(:secret)

	@options = {
		:domain => nil,
		:path => "/",
		:expires_after => nil
	}.merge(options)
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