Sha256: 457b91c54f03fa79bf7e026be6b63d717ca3fef8e10f547773b97936539d032a

Contents?: true

Size: 524 Bytes

Versions: 2

Compression:

Stored size: 524 Bytes

Contents

class Warden::CookieSession::EncryptedCookie

  attr_reader :store, :cookie, :secret, :encryptor

  def initialize(store:, cookie:, secret:)
    @store = store
    @cookie = cookie
    @secret = secret

    @encryptor ||= ActiveSupport::MessageEncryptor.new(secret)
  end

  def get
    value = store[cookie]
    return nil unless value

    JSON(encryptor.decrypt_and_verify(value))
  end

  def put(data)
    store[cookie] = encryptor.encrypt_and_sign(data.to_json)
  end

  def clear
    store.delete(cookie)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
warden_cookie_session-0.1.0.18558 lib/warden/cookie_session/encrypted_cookie.rb
warden_cookie_session-0.1.0.18557 lib/warden/cookie_session/encrypted_cookie.rb