summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/vscode_cdn_csp.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/vscode_cdn_csp.rb')
-rw-r--r--app/controllers/concerns/vscode_cdn_csp.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/concerns/vscode_cdn_csp.rb b/app/controllers/concerns/vscode_cdn_csp.rb
new file mode 100644
index 00000000000..8446d237f16
--- /dev/null
+++ b/app/controllers/concerns/vscode_cdn_csp.rb
@@ -0,0 +1,17 @@
+# rubocop:disable Naming/FileName
+# frozen_string_literal: true
+
+module VSCodeCDNCSP
+ extend ActiveSupport::Concern
+
+ included do
+ content_security_policy do |policy|
+ next if !Feature.enabled?(:vscode_web_ide) || policy.directives.blank?
+
+ default_src = Array(policy.directives['default-src'] || [])
+ policy.directives['frame-src'] ||= default_src
+ policy.directives['frame-src'].concat(['https://*.vscode-cdn.net/'])
+ end
+ end
+end
+# rubocop:enable Naming/FileName