Class: ActionDispatch::Session::EncryptedCookieStore

Inherits:
Rack::Session::Cookie
  • Object
show all
Includes:
Compatibility, StaleSessionCheck
Defined in:
lib/encrypted_cookie_store/encrypted_cookie_store.rb

Constant Summary collapse

OpenSSLCipherError =
OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError
ENCRYPTION_KEY_SIZE =
32

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ EncryptedCookieStore

Returns a new instance of EncryptedCookieStore.



22
23
24
25
26
27
28
# File 'lib/encrypted_cookie_store/encrypted_cookie_store.rb', line 22

def initialize(app, options = {})
  ensure_encryption_key_secure(options[:encryption_key])
  @encryption_key = unhex(options[:encryption_key]).freeze
  @iv_cipher      = OpenSSL::Cipher::Cipher.new(EncryptedCookieStore.iv_cipher_type)
  @data_cipher    = OpenSSL::Cipher::Cipher.new(EncryptedCookieStore.data_cipher_type)
  super(app, options)
end

Class Attribute Details

.data_cipher_typeObject

Returns the value of attribute data_cipher_type.



16
17
18
# File 'lib/encrypted_cookie_store/encrypted_cookie_store.rb', line 16

def data_cipher_type
  @data_cipher_type
end

.iv_cipher_typeObject

Returns the value of attribute iv_cipher_type.



15
16
17
# File 'lib/encrypted_cookie_store/encrypted_cookie_store.rb', line 15

def iv_cipher_type
  @iv_cipher_type
end

Instance Method Details

#destroy_session(env, session_id, options) ⇒ Object

Override rack’s method



31
32
33
34
35
36
# File 'lib/encrypted_cookie_store/encrypted_cookie_store.rb', line 31

def destroy_session(env, session_id, options)
  new_sid = super
  # Reset hash and Assign the new session id
  env["action_dispatch.request.unsigned_session_cookie"] = new_sid ? { "session_id" => new_sid } : {}
  new_sid
end