demarches-normaliennes/app/models/concerns/blob_signed_id_concern.rb
2020-01-08 14:43:05 +01:00

12 lines
405 B
Ruby

module BlobSignedIdConcern
extend ActiveSupport::Concern
included do
# We override signed_id to add `expires_in` option to generated hash.
# This is a measure to ensure that we never under any circumstance
# expose permanent attachment url
def signed_id
ActiveStorage.verifier.generate(id, purpose: :blob_id, expires_in: ActiveStorage::Service.url_expires_in)
end
end
end