mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 18:45:41 +01:00
add SWIFT object storage uri to CSP media hosts (#32439)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
7d89cea0ea
commit
f2378aca40
1 changed files with 9 additions and 1 deletions
|
@ -36,7 +36,7 @@ class ContentSecurityPolicy
|
||||||
end
|
end
|
||||||
|
|
||||||
def cdn_host_value
|
def cdn_host_value
|
||||||
s3_alias_host || s3_cloudfront_host || azure_alias_host || s3_hostname_host
|
s3_alias_host || s3_cloudfront_host || azure_alias_host || s3_hostname_host || swift_object_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def paperclip_root_url
|
def paperclip_root_url
|
||||||
|
@ -72,6 +72,14 @@ class ContentSecurityPolicy
|
||||||
host_to_url ENV.fetch('S3_HOSTNAME', nil)
|
host_to_url ENV.fetch('S3_HOSTNAME', nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def swift_object_url
|
||||||
|
url = ENV.fetch('SWIFT_OBJECT_URL', nil)
|
||||||
|
return if url.blank? || !url.start_with?('https://')
|
||||||
|
|
||||||
|
url += '/' unless url.end_with?('/')
|
||||||
|
url
|
||||||
|
end
|
||||||
|
|
||||||
def uri_from_configuration_and_string(host_string)
|
def uri_from_configuration_and_string(host_string)
|
||||||
Addressable::URI.parse("#{host_protocol}://#{host_string}").tap do |uri|
|
Addressable::URI.parse("#{host_protocol}://#{host_string}").tap do |uri|
|
||||||
uri.path += '/' unless uri.path.blank? || uri.path.end_with?('/')
|
uri.path += '/' unless uri.path.blank? || uri.path.end_with?('/')
|
||||||
|
|
Loading…
Reference in a new issue