diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 78c81f7..13543b4 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -90,3 +90,4 @@ - [JaeSang Yoo](https://github.com/JSYoo5B) - [Felix](https://github.com/lazyyz) - [Peter Duchnovsky](https://pduchnovsky.com) +- [Alex Miranda](https://ammiranda.com) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 751acf8..a9b89f5 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -80,6 +80,25 @@ disqusShortname = "yourdiscussshortname" [params.cloudflare] token = "token" +# If you want to implement a Content-Security-Policy, add this section +[params.csp] + childsrc = ["'self'"] + fontsrc=["'self'", + "https://fonts.gstatic.com", + "https://cdn.jsdelivr.net/"] + formaction = ["'self'"] + framesrc = ["'self'"] + imgsrc = ["'self'"] + objectsrc = ["'none'"] + stylesrc = ["'self'", + "'unsafe-inline'", + "https://fonts.googleapis.com/", + "https://cdn.jsdelivr.net/"] + scriptsrc = ["'self'", + "'unsafe-inline'", + "https://www.google-analytics.com"] + prefetchsrc = ["'self'"] + [taxonomies] category = "categories" series = "series" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 56f5b3a..435808f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -5,6 +5,9 @@ + {{ if .Site.Params.csp }} + {{ partial "csp.html" . }} + {{ end }} {{ with .Site.Params.author }}{{ end }} diff --git a/layouts/partials/csp.html b/layouts/partials/csp.html new file mode 100644 index 0000000..57ded85 --- /dev/null +++ b/layouts/partials/csp.html @@ -0,0 +1 @@ +{{ printf `` (delimit .Site.Params.csp.childsrc " ") (delimit .Site.Params.csp.fontsrc " ") (delimit .Site.Params.csp.formaction " ") (delimit .Site.Params.csp.framesrc " ") (delimit .Site.Params.csp.imgsrc " ") (delimit .Site.Params.csp.objectsrc " ") (delimit .Site.Params.csp.stylesrc " ") (delimit .Site.Params.csp.scriptsrc " ") (delimit .Site.Params.csp.prefetchsrc " ") | safeHTML }} \ No newline at end of file