Class: ActionDispatch::Session::EncryptedCookieStore
- Inherits:
-
CookieStore
- Object
- CookieStore
- ActionDispatch::Session::EncryptedCookieStore
- Defined in:
- lib/encrypted_cookie_store.rb
Constant Summary collapse
- EXPIRE_AFTER_KEY =
"encrypted_cookie_store.session_expire_after"- OpenSSLCipherError =
OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError
Class Attribute Summary collapse
-
.data_cipher_type ⇒ Object
Returns the value of attribute data_cipher_type.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ EncryptedCookieStore
constructor
A new instance of EncryptedCookieStore.
-
#load_session(env) ⇒ Object
overrides method in Rack::Session::Cookie.
Constructor Details
#initialize(app, options = {}) ⇒ EncryptedCookieStore
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/encrypted_cookie_store.rb', line 24 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 @allow_legacy_hmac = [:allow_legacy_hmac] @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.
16 17 18 |
# File 'lib/encrypted_cookie_store.rb', line 16 def data_cipher_type @data_cipher_type end |
Instance Method Details
#call(env) ⇒ Object
45 46 47 48 |
# File 'lib/encrypted_cookie_store.rb', line 45 def call(env) @expire_after = env[EXPIRE_AFTER_KEY] super end |
#load_session(env) ⇒ Object
overrides method in Rack::Session::Cookie
51 52 53 54 55 56 |
# File 'lib/encrypted_cookie_store.rb', line 51 def load_session(env) if time = (env) env['encrypted_cookie_store.session_refreshed_at'] ||= Time.at(time).utc end super end |