FEATURE: Add setting to disable automatic CORS rule install in S3 buckets (#9872)

FEATURE: Add setting to disable automatic CORS rule install in S3 buckets (#9872)

diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf
index ac71f6a..39df104 100644
--- a/config/discourse_defaults.conf
+++ b/config/discourse_defaults.conf
@@ -200,6 +200,7 @@ s3_use_iam_profile =
 s3_cdn_url =
 s3_endpoint =
 s3_http_continue_timeout =
+s3_install_cors_rule =
 
 ### rate limits apply to all sites
 max_user_api_reqs_per_minute = 20
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 6209cc6..cfeb711 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1207,6 +1207,9 @@ files:
   s3_http_continue_timeout:
     default: 1
     hidden: true
+  s3_install_cors_rule:
+    default: true
+    hidden: true
   s3_cdn_url:
     default: ""
     regex: '^https?:\/\/.+[^\/]$'
diff --git a/lib/s3_helper.rb b/lib/s3_helper.rb
index ef3bc7d..8021c78 100644
--- a/lib/s3_helper.rb
+++ b/lib/s3_helper.rb
@@ -90,6 +90,8 @@ class S3Helper
   # make sure we have a cors config for assets
   # otherwise we will have no fonts
   def ensure_cors!(rules = nil)
+    return unless SiteSetting.s3_install_cors_rule
+
     rule = nil
 
     begin

GitHub sha: b48299f8

This commit appears in #9872 which was approved by eviltrout. It was merged by Falco.