Sha256: 26b1c60c3012d2a5a0b6af18acd5c0ef80c84f08448248a6a61bbabe23adba27
Contents?: true
Size: 682 Bytes
Versions: 3
Compression:
Stored size: 682 Bytes
Contents
class Warden::CookieSession::EncryptedCookie attr_reader :store, :cookie, :secret, :encryptor def initialize(store:, cookie:, secret:) @store = store @cookie = cookie @secret = secret raise ArgumentError.new('secret must be 32 bytes') if @secret.length != 32 @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, domain: nil) c = { value: encryptor.encrypt_and_sign(data.to_json) } c[:domain] = domain if domain store[cookie] = c end def clear store.delete(cookie) end end
Version data entries
3 entries across 3 versions & 1 rubygems