Skip to content

Commit

Permalink
Update seeds to include the CSP configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fblupi committed Apr 1, 2024
1 parent b3ce73f commit 7f6e544
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ Depending on your Decidim version, choose the corresponding Plugin version to en
| 1.1.x | 0.22.x, 0.23.x |
| 1.0.x | 0.18.x - 0.21.x |

### Content Security Policy

You need to include `cdnjs.cloudflare.com` in the section of script from your Content Security Policy (CSP) configuration.
> **IMPORTANT**: If you are upgrading or installing this module for Decidim v0.28.0 or higher you need to include
> `cdnjs.cloudflare.com` in the section of script from your organization's Content Security Policy (CSP) configuration.
> Otherwise, the admin page to manage the maps will not work properly.
## Contributing

Expand Down
8 changes: 8 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,12 @@
description: { en: "Cerdà was from the town of Centelles" }
)
end

csp = organization.content_security_policy
scripts = csp["script-src"]&.split(" ") || []
unless scripts.include?("cdnjs.cloudflare.com")
scripts << "cdnjs.cloudflare.com"
csp["script-src"] = scripts.join(" ")
organization.update!(content_security_policy: csp)
end
end

0 comments on commit 7f6e544

Please sign in to comment.