mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 08:53:41 +08:00
a059c7251f
In preparation for adding automatic CORS rules creation for direct S3 uploads, I am adding tests here and moving the CORS rule definitions into a dedicated class so they are all in the one place. There is a problem with ensure_cors! as well -- if there is already a CORS rule defined (presumably the asset one) then we do nothing and do not apply the new rule. This means that the S3BackupStore.ensure_cors method does nothing right now if the assets rule is already defined, and it will mean the same for any direct S3 upload rules I add for uppy. We need to be able to add more rules, not just one. This is not a problem on our hosting because we define the rules at an infra level.
18 lines
388 B
Ruby
18 lines
388 B
Ruby
# frozen_string_literal: true
|
|
|
|
class S3CorsRulesets
|
|
ASSETS = {
|
|
allowed_headers: ["Authorization"],
|
|
allowed_methods: ["GET", "HEAD"],
|
|
allowed_origins: ["*"],
|
|
max_age_seconds: 3000
|
|
}.freeze
|
|
|
|
BACKUP_DIRECT_UPLOAD = {
|
|
allowed_headers: ["*"],
|
|
allowed_methods: ["PUT"],
|
|
allowed_origins: [Discourse.base_url_no_prefix],
|
|
max_age_seconds: 3000
|
|
}.freeze
|
|
end
|