82c89fb56f
As the comment states, it would be nice to load the Virus Scanner on the Attachment (rather than the blob). However, in order not to clobber the blob metadata, we want to run the VirusScanner once the blob analyzer did run. And the most direct way to detect that the blob analyzer did run is to add an `on_update_commit` hook on the blob, as this hook will be trigerred when saving changes to the metadata. This is what the current solution uses. So the current solution is almost optimal, and has a low chance of accidentally clobbering the blob metadata – as the virus scanner is only started when the analysis phase is finished.
59 lines
1.4 KiB
Ruby
59 lines
1.4 KiB
Ruby
Rails.application.config.active_storage.service_urls_expire_in = 1.hour
|
|
|
|
ActiveSupport.on_load(:active_storage_blob) do
|
|
include BlobSignedIdConcern
|
|
include BlobVirusScannerConcern
|
|
end
|
|
|
|
# When an OpenStack service is initialized it makes a request to fetch
|
|
# `publicURL` to use for all operations. We intercept the method that reads
|
|
# this url and replace the host with DS_Proxy host. This way all the operation
|
|
# are performed through DS_Proxy.
|
|
#
|
|
# https://github.com/fog/fog-openstack/blob/37621bb1d5ca78d037b3c56bd307f93bba022ae1/lib/fog/openstack/auth/catalog/v2.rb#L16
|
|
require 'fog/openstack/auth/catalog/v2'
|
|
|
|
module Fog::OpenStack::Auth::Catalog
|
|
class V2
|
|
def endpoint_url(endpoint, interface)
|
|
url = endpoint["#{interface}URL"]
|
|
|
|
if interface == 'public'
|
|
publicize(url)
|
|
else
|
|
url
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def publicize(url)
|
|
search = %r{^https://[^/]+/}
|
|
replace = "#{ENV['DS_PROXY_URL']}/"
|
|
url.gsub(search, replace)
|
|
end
|
|
end
|
|
end
|
|
|
|
require 'fog/openstack/auth/catalog/v3'
|
|
module Fog::OpenStack::Auth::Catalog
|
|
class V3
|
|
def endpoint_url(endpoint, interface)
|
|
url = endpoint["url"]
|
|
|
|
if interface == 'public'
|
|
publicize(url)
|
|
else
|
|
url
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def publicize(url)
|
|
search = %r{^https://[^/]+/}
|
|
replace = "#{ENV['DS_PROXY_URL']}/"
|
|
url.gsub(search, replace)
|
|
end
|
|
end
|
|
end
|