Class: EncryptedCookieStore::EncryptedCookieStore

Inherits:
ActionDispatch::Session::CookieStore
  • Object
show all
Defined in:
lib/encrypted-cookie-store/encrypted_cookie_store.rb

Overview

swap out the signed cookie jar for an encrypted cookie jar

Instance Method Summary (collapse)

Instance Method Details



16
17
18
# File 'lib/encrypted-cookie-store/encrypted_cookie_store.rb', line 16

def set_cookie(request, options)
  request.cookie_jar.encrypted[@key] = options
end


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/encrypted-cookie-store/encrypted_cookie_store.rb', line 4

def unpacked_cookie_data(env)
  env["action_dispatch.request.unsigned_session_cookie"] ||= begin
    stale_session_check! do
      request = ActionDispatch::Request.new(env)
      if data = request.cookie_jar.encrypted[@key]
        data.stringify_keys!
      end
      data || {}
    end
  end
end