2019-11-20 16:03:40 +01:00
|
|
|
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
|
2023-03-06 17:16:52 +01:00
|
|
|
def signed_id(**options)
|
|
|
|
ActiveStorage.verifier.generate(id, **options, purpose: :blob_id, expires_in: Rails.application.config.active_storage.service_urls_expire_in)
|
2019-11-20 16:03:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|