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
make download URL expiry configurable, use safer default
Markus Kahlaf48244ffd73
diff --git a/app/uploaders/fog_file_uploader.rb b/app/uploaders/fog_file_uploader.rbindex 253339de010..bde1916211b 100644--- a/app/uploaders/fog_file_uploader.rb+++ b/app/uploaders/fog_file_uploader.rb@@ -114,8 +114,7 @@ class FogFileUploader < CarrierWave::Uploader::Basedef set_expires_at!(url_options, options:)if options[:expires_in].present?- # AWS allows at max < 604800 expires time- expires = [options[:expires_in], 604799].min+ expires = [options[:expires_in], OpenProject::Configuration.fog_download_url_expires_in].minurl_options[:expire_at] = ::Fog::Time.now + expiresenddiff --git a/docs/installation-and-operations/configuration/README.md b/docs/installation-and-operations/configuration/README.mdindex c8af4b70bca..d47c8e23d15 100644--- a/docs/installation-and-operations/configuration/README.md+++ b/docs/installation-and-operations/configuration/README.md@@ -39,6 +39,7 @@ Configuring OpenProject through environment variables is detailed [in this separ* [`disable_password_login`](#disable-password-login) (default: false)* [`attachments_storage`](#attachments-storage) (default: file)* [`direct_uploads`](#direct-uploads) (default: true)+* [`fog_download_url_expires_in`](#fog-download-url-expires-in) (default: 21600)* [`hidden_menu_items`](#hidden-menu-items) (default: {})* [`disabled_modules`](#disabled-modules) (default: [])* [`blacklisted_routes`](#blacklisted-routes) (default: [])@@ -188,6 +189,21 @@ to the remote storage in an extra step.**Note**: This only works for S3 right now. When using fog with another provider this configuration will be `false`. The same goes for when no fog storage is configured.+### fog download url expires in++*default: 21600*++Example:++ fog_download_url_expires_in: 60++When using remote storage for attachments via fog - usually S3 (see [`attachments_storage`](#attachments-storage) option) -+each attachment download will generate a temporary URL.+This option determines how long these links will be valid.++The default is 21600 seconds, that is 6 hours, which is the maximum expiry time+allowed by S3 when using IAM roles for authentication.+### Overriding the help linkYou can override the default help menu of OpenProject by specifying a `force_help_link` option todiff --git a/lib/open_project/configuration.rb b/lib/open_project/configuration.rbindex 63b664b6b79..ed240d13f8f 100644--- a/lib/open_project/configuration.rb+++ b/lib/open_project/configuration.rb@@ -50,6 +50,7 @@ module OpenProject# which will be uploaded directly to the cloud storage rather than via OpenProject's# server process.'direct_uploads' => true,+ 'fog_download_url_expires_in' => 21600, # 6h by default as 6 hours is max in S3 when using IAM roles'show_community_links' => true,'log_level' => 'info','scm_git_command' => nil,diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rbindex 4993ad7944f..6dc4c1971e6 100644--- a/spec/models/attachment_spec.rb+++ b/spec/models/attachment_spec.rb@@ -318,7 +318,7 @@ describe Attachment, type: :model dolet(:url_options) { { expires_in: 1.year } }it "uses the allowed max" do- expect(query).to include "X-Amz-Expires=604799"+ expect(query).to include "X-Amz-Expires=#{OpenProject::Configuration.fog_download_url_expires_in}"endendend