discourse/lib/content_security_policy.rb
Krzysztof Kotlarek 427d54b2b0 DEV: Upgrading Discourse to Zeitwerk (#8098)
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. 

We no longer need to use Rails "require_dependency" anywhere and instead can just use standard 
Ruby patterns to require files.

This is a far reaching change and we expect some followups here.
2019-10-02 14:01:53 +10:00

29 lines
638 B
Ruby

# frozen_string_literal: true
require 'content_security_policy/builder'
require 'content_security_policy/extension'
class ContentSecurityPolicy
class << self
def policy(theme_ids = [])
new.build(theme_ids)
end
def base_url
@base_url || Discourse.base_url
end
attr_writer :base_url
end
def build(theme_ids)
builder = Builder.new
Extension.theme_extensions(theme_ids).each { |extension| builder << extension }
Extension.plugin_extensions.each { |extension| builder << extension }
builder << Extension.site_setting_extension
builder.build
end
end
CSP = ContentSecurityPolicy