OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
s3 hosts differ for pre-signed form uploads and downloads
Markus Kahl939f1d1df786
diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rbindex dfb343a85b6..6d3c231fe45 100644--- a/config/initializers/secure_headers.rb+++ b/config/initializers/secure_headers.rb@@ -21,7 +21,7 @@ SecureHeaders::Configuration.default do |config|frame_src << OpenProject::Configuration[:security_badge_url]# Default src- default_src = %w('self') + [OpenProject::Configuration.remote_storage_host].compact+ default_src = %w('self') + OpenProject::Configuration.remote_storage_hosts# Allow requests to CLI in dev modeconnect_src = default_srcdiff --git a/lib/open_project/configuration/helpers.rb b/lib/open_project/configuration/helpers.rbindex 058654b5e19..ebb3ffdbda4 100644--- a/lib/open_project/configuration/helpers.rb+++ b/lib/open_project/configuration/helpers.rb@@ -76,12 +76,22 @@ module OpenProjectfog_credentials[:provider] == "AWS"end- def remote_storage_host+ def remote_storage_upload_hostif remote_storage_aws?"#{fog_directory}.s3.amazonaws.com"endend+ def remote_storage_download_host+ if remote_storage_aws?+ "#{fog_directory}.s3.#{fog_credentials[:region]}.amazonaws.com"+ end+ end++ def remote_storage_hosts+ [remote_storage_upload_host, remote_storage_download_host].compact+ end+def attachments_storage_pathRails.root.join(self['attachments_storage_path'] || 'files')enddiff --git a/spec/support/shared/with_direct_uploads.rb b/spec/support/shared/with_direct_uploads.rbindex c0ebd68325c..00e18793d4f 100644--- a/spec/support/shared/with_direct_uploads.rb+++ b/spec/support/shared/with_direct_uploads.rb@@ -93,7 +93,7 @@ class WithDirectUploadsenddef stub_frontend(redirect: false)- proxy.stub("https://" + OpenProject::Configuration.remote_storage_host + ":443/", method: 'options').and_return(+ proxy.stub("https://" + OpenProject::Configuration.remote_storage_upload_host + ":443/", method: 'options').and_return(headers: {'Access-Control-Allow-Methods' => 'POST','Access-Control-Allow-Origin' => '*'@@ -110,7 +110,7 @@ class WithDirectUploadsdef stub_with_redirectproxy- .stub("https://" + OpenProject::Configuration.remote_storage_host + ":443/", method: 'post')+ .stub("https://" + OpenProject::Configuration.remote_storage_upload_host + ":443/", method: 'post').and_return(Proc.new { |params, headers, body, url, method|key = body.scan(/key"\s*([^\s]+)\s/m).flatten.firstredirect_url = body.scan(/success_action_redirect"\s*(http[^\s]+)\s/m).flatten.first@@ -129,7 +129,7 @@ class WithDirectUploadsdef stub_with_statusproxy- .stub("https://" + OpenProject::Configuration.remote_storage_host + ":443/", method: 'post')+ .stub("https://" + OpenProject::Configuration.remote_storage_upload_host + ":443/", method: 'post').and_return(Proc.new { |params, headers, body, url, method|{code: (body =~ /X-Amz-Signature/) ? 201 : 403, # check that the expected post to AWS was made with the form fields