Sha256: 9a7369a64a9ab4c7a115e3437417b7a2762f6fcb9878e3c8bec62ccdf759d4e2
Contents?: true
Size: 923 Bytes
Versions: 8
Compression:
Stored size: 923 Bytes
Contents
module Scrivito module BinaryParamVerifier InvalidSignature = Class.new(StandardError) class << self def verify(params) params = message_verifier.verify(params) expires = DateAttribute.parse(params['expires']) raise InvalidSignature if expires && expires < Time.zone.now Binary.new(params['binary_id'], expires.nil?, params['transformation_definition']) rescue ActiveSupport::MessageVerifier::InvalidSignature raise InvalidSignature end def generate(binary) params = {binary_id: binary.id, transformation_definition: binary.transformation_definition} params[:expires] = DateAttribute.serialize(Time.zone.now + 1.hour) if binary.private? message_verifier.generate(params) end private def message_verifier ActiveSupport::MessageVerifier.new( Rails.application.secrets.secret_key_base, serializer: JSON) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems