Class: ActionDispatch::Session::EncryptedCookieStore
- Inherits:
-
CookieStore
- Object
- CookieStore
- ActionDispatch::Session::EncryptedCookieStore
- Defined in:
- lib/encrypted_cookie_store.rb
Constant Summary collapse
- SESSION_KEY =
if Rack.release >= '2' Rack::RACK_SESSION else Rack::Session::Abstract::ENV_SESSION_KEY end
Class Attribute Summary collapse
-
.data_cipher_type ⇒ Object
Returns the value of attribute data_cipher_type.
Instance Method Summary collapse
-
#cookie_jar(env) ⇒ Object
overrides method in ActionDispatch::Session::CookieStore.
- #fetch_header(env, key, &block) ⇒ Object
- #get_header(env, key) ⇒ Object
-
#initialize(app, options = {}) ⇒ EncryptedCookieStore
constructor
A new instance of EncryptedCookieStore.
-
#load_session(req) ⇒ Object
overrides method in Rack::Session::Cookie.
- #set_header(env, key, value) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ EncryptedCookieStore
Returns a new instance of EncryptedCookieStore.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/encrypted_cookie_store.rb', line 22 def initialize(app, = {}) @logger = .delete(:logger) @digest = .delete(:digest) || 'SHA1' @compress = [:compress] @compress = true if @compress.nil? @secret = .delete(:secret) @secret = @secret.call if @secret.respond_to?(:call) @secret.freeze @data_cipher = OpenSSL::Cipher.new(EncryptedCookieStore.data_cipher_type) @encryption_key = unhex(@secret[0...(@data_cipher.key_len * 2)]).freeze ensure_encryption_key_secure [:refresh_interval] ||= 5.minutes super(app, ) end |
Class Attribute Details
.data_cipher_type ⇒ Object
Returns the value of attribute data_cipher_type.
12 13 14 |
# File 'lib/encrypted_cookie_store.rb', line 12 def data_cipher_type @data_cipher_type end |
Instance Method Details
#cookie_jar(env) ⇒ Object
overrides method in ActionDispatch::Session::CookieStore
55 56 57 |
# File 'lib/encrypted_cookie_store.rb', line 55 def (request) request. end |
#fetch_header(env, key, &block) ⇒ Object
46 47 48 |
# File 'lib/encrypted_cookie_store.rb', line 46 def fetch_header(req, key, &block) req.fetch_header(key, &block) end |
#get_header(env, key) ⇒ Object
42 43 44 |
# File 'lib/encrypted_cookie_store.rb', line 42 def get_header(req, key) req.get_header(key) end |
#load_session(req) ⇒ Object
overrides method in Rack::Session::Cookie
83 84 85 86 87 88 |
# File 'lib/encrypted_cookie_store.rb', line 83 def load_session(req) if time = (req) fetch_header(req, 'encrypted_cookie_store.session_refreshed_at') { |k| set_header(req, k, Time.at(time).utc) } end super end |
#set_header(env, key, value) ⇒ Object
50 51 52 |
# File 'lib/encrypted_cookie_store.rb', line 50 def set_header(req, key, value) req.set_header(key, value) end |