Class: ActionDispatch::Session::EncryptedCookieStore
- Inherits:
-
CookieStore
- Object
- CookieStore
- ActionDispatch::Session::EncryptedCookieStore
- Defined in:
- lib/encrypted_cookie_store.rb
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/encrypted_cookie_store.rb', line 16 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 @encryption_key = unhex(@secret).freeze ensure_encryption_key_secure @data_cipher = OpenSSL::Cipher::Cipher.new(EncryptedCookieStore.data_cipher_type) [: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
49 50 51 |
# File 'lib/encrypted_cookie_store.rb', line 49 def (request) request. end |
#fetch_header(env, key, &block) ⇒ Object
40 41 42 |
# File 'lib/encrypted_cookie_store.rb', line 40 def fetch_header(req, key, &block) req.fetch_header(key, &block) end |
#get_header(env, key) ⇒ Object
36 37 38 |
# File 'lib/encrypted_cookie_store.rb', line 36 def get_header(req, key) req.get_header(key) end |
#load_session(req) ⇒ Object
overrides method in Rack::Session::Cookie
77 78 79 80 81 82 |
# File 'lib/encrypted_cookie_store.rb', line 77 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
44 45 46 |
# File 'lib/encrypted_cookie_store.rb', line 44 def set_header(req, key, value) req.set_header(key, value) end |