mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +08:00
Add config option for disabling whitelisting external services in CSP and option for disabling links preload in headers [SCI-10795] (#7677)
This commit is contained in:
parent
8b042db2d9
commit
da98f627e4
2 changed files with 28 additions and 14 deletions
|
|
@ -53,6 +53,8 @@ module Scinote
|
||||||
|
|
||||||
config.action_dispatch.cookies_serializer = :hybrid
|
config.action_dispatch.cookies_serializer = :hybrid
|
||||||
|
|
||||||
|
config.action_view.preload_links_header = false if ENV['RAILS_NO_PRELOAD_LINKS_HEADER'] == 'true'
|
||||||
|
|
||||||
# Max uploaded file size in MB
|
# Max uploaded file size in MB
|
||||||
config.x.file_max_size_mb = (ENV['FILE_MAX_SIZE_MB'] || 50).to_i
|
config.x.file_max_size_mb = (ENV['FILE_MAX_SIZE_MB'] || 50).to_i
|
||||||
|
|
||||||
|
|
@ -62,6 +64,8 @@ module Scinote
|
||||||
|
|
||||||
config.x.custom_sanitizer_config = nil
|
config.x.custom_sanitizer_config = nil
|
||||||
|
|
||||||
|
config.x.no_external_csp_exceptions = ENV['SCINOTE_NO_EXT_CSP_EXCEPTIONS'] == 'true'
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
config.log_formatter = proc do |severity, datetime, progname, msg|
|
config.log_formatter = proc do |severity, datetime, progname, msg|
|
||||||
"[#{datetime}] #{severity}: #{msg}\n"
|
"[#{datetime}] #{severity}: #{msg}\n"
|
||||||
|
|
|
||||||
|
|
@ -595,13 +595,22 @@ class Extends
|
||||||
'FluicsLabelTemplate' => 'Fluics'
|
'FluicsLabelTemplate' => 'Fluics'
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTERNAL_SCRIPT_SERVICES = %w(
|
EXTERNAL_SCRIPT_SERVICES =
|
||||||
|
if Rails.application.config.x.no_external_csp_exceptions
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
%w(
|
||||||
https://marvinjs.chemicalize.com/
|
https://marvinjs.chemicalize.com/
|
||||||
www.recaptcha.net/
|
www.recaptcha.net/
|
||||||
www.gstatic.com/recaptcha/
|
www.gstatic.com/recaptcha/
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
EXTERNAL_CONNECT_SERVICES = %w(
|
EXTERNAL_CONNECT_SERVICES =
|
||||||
|
if Rails.application.config.x.no_external_csp_exceptions
|
||||||
|
%w(http://127.0.0.1:9100/)
|
||||||
|
else
|
||||||
|
%w(
|
||||||
https://www.protocols.io/
|
https://www.protocols.io/
|
||||||
http://127.0.0.1:9100/
|
http://127.0.0.1:9100/
|
||||||
newrelic.com
|
newrelic.com
|
||||||
|
|
@ -610,6 +619,7 @@ class Extends
|
||||||
extras.scinote.net
|
extras.scinote.net
|
||||||
https://www.scinote.net
|
https://www.scinote.net
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
if Constants::ASSET_SYNC_URL && EXTERNAL_CONNECT_SERVICES.exclude?(Constants::ASSET_SYNC_URL)
|
if Constants::ASSET_SYNC_URL && EXTERNAL_CONNECT_SERVICES.exclude?(Constants::ASSET_SYNC_URL)
|
||||||
asset_sync_url = URI.parse(Constants::ASSET_SYNC_URL)
|
asset_sync_url = URI.parse(Constants::ASSET_SYNC_URL)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue