2020-01-28 12:02:06 +01:00
|
|
|
Rails.application.config.active_storage.service_urls_expire_in = 1.hour
|
2019-05-02 11:37:35 +02:00
|
|
|
|
2020-09-02 17:00:26 +02:00
|
|
|
Rails.application.config.active_storage.analyzers.delete ActiveStorage::Analyzer::ImageAnalyzer
|
|
|
|
Rails.application.config.active_storage.analyzers.delete ActiveStorage::Analyzer::VideoAnalyzer
|
|
|
|
|
2019-11-20 16:03:40 +01:00
|
|
|
ActiveSupport.on_load(:active_storage_blob) do
|
2024-04-29 16:53:21 +02:00
|
|
|
include BlobImageProcessorConcern
|
2021-03-11 14:42:57 +01:00
|
|
|
include BlobVirusScannerConcern
|
|
|
|
include BlobSignedIdConcern
|
2023-06-21 15:16:55 +02:00
|
|
|
|
|
|
|
def self.generate_unique_secure_token(length: MINIMUM_TOKEN_LENGTH)
|
|
|
|
token = super
|
2023-07-10 10:51:06 +02:00
|
|
|
"#{Time.current.strftime('%Y/%m/%d')}/#{token[0..1]}/#{token}"
|
2023-06-21 15:16:55 +02:00
|
|
|
end
|
2021-03-11 14:42:57 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
ActiveSupport.on_load(:active_storage_attachment) do
|
2024-04-29 16:53:21 +02:00
|
|
|
include AttachmentImageProcessorConcern
|
2021-03-11 14:42:57 +01:00
|
|
|
include AttachmentVirusScannerConcern
|
2019-11-20 16:03:40 +01:00
|
|
|
end
|
2019-10-30 12:11:45 +01:00
|
|
|
|
2021-04-29 13:57:32 +02:00
|
|
|
Rails.application.reloader.to_prepare do
|
|
|
|
class ActiveStorage::BaseJob
|
|
|
|
include ActiveJob::RetryOnTransientErrors
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-30 12:11:45 +01:00
|
|
|
# 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.
|
|
|
|
#
|
2020-06-04 17:32:25 +02:00
|
|
|
# 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
|
|
|
|
|
2020-06-02 15:03:37 +02:00
|
|
|
require 'fog/openstack/auth/catalog/v3'
|
|
|
|
module Fog::OpenStack::Auth::Catalog
|
|
|
|
class V3
|
|
|
|
def endpoint_url(endpoint, interface)
|
2020-06-19 08:09:42 +02:00
|
|
|
url = endpoint["url"]
|
2020-06-02 15:03:37 +02:00
|
|
|
|
|
|
|
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
|