diff --git a/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb b/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb new file mode 100644 index 000000000..4a9bc26c5 --- /dev/null +++ b/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Decidim + module DecidimAwesome + module ContentSecurityPolicy + extend ActiveSupport::Concern + + included do + after_action :append_awesome_csp_directives + end + + private + + def append_awesome_csp_directives + return unless DecidimAwesome.enabled?(:intergram_for_admins) || DecidimAwesome.enabled?(:intergram_for_public) + + intergram = URI.parse(DecidimAwesome.intergram_url) + if intergram.host && intergram.scheme + content_security_policy.append_csp_directive("script-src", "#{intergram.scheme}://#{intergram.host}") + content_security_policy.append_csp_directive("frame-src", "#{intergram.scheme}://#{intergram.host}") + # content_security_policy.append_csp_directive("frame-src", "http://www.loadmill.com") + # content_security_policy.append_csp_directive("frame-src", "http://app.loadmill.com") + end + end + end + end +end diff --git a/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface b/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface index c886b07bb..b73147dd5 100644 --- a/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface +++ b/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface @@ -4,3 +4,6 @@ <% append_stylesheet_pack_tag("decidim_admin_decidim_awesome_global") %> <% append_javascript_pack_tag("decidim_admin_decidim_awesome_global") %> <% append_javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %> +<% if awesome_config[:intergram_for_admins] %> + <%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_admins_settings] } %> +<% end %> \ No newline at end of file diff --git a/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb b/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb index 4eab58821..80691ee0c 100644 --- a/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +++ b/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb @@ -1,4 +1,4 @@ -