Content Security Policy - Part 1
Figuring out a ‘proper’ CSP for my site was a process of elimination; a repeating cycle of whack-a-mole, adding parameters to the policy to remove error messages for my site resulted in the configuration below. There must be a more clever way!
The AWS Lambda HTTP Response Header Configuration that I ended up with is below in case it’s useful for anyone.
This scores a B from Mozilla Observatory. It loses points because of inline javascript and CSS. I’ll shoot for the A, but it will mean surgery on the code and I don’t have time to do that work right now.
Until I can get round to fixing it, unsafe-inline is enabled (which is a security vulnerability) in this policy - as well as a number of browser JavaScript Console errors messages relating to Disqus loading. It seems to work fine & seems to use some clever techniques to work despite a tight(ish) CSP. I also haven’t tested cross-browser-compatibility.
Don’t use this in a production configuration without understanding the implications. It’s not a completely safe configuration until the unsafe-inline and unsafe-eval has been removed - assuming that will be possible while continuing to use Google Analytics, Disqus, etc.
More to follow…