3 ms·
Do CSP headers change dynamically between page loads very often? I can't think of a situation where that would happen. Consequently rebuilding them with PHP see
by onion2k 10y ago
Do CSP headers change dynamically between page loads very often? I can't think of a situation where that would happen. Consequently rebuilding them with PHP seems unnecessary. Writing them using a build tool (eg gulp), and saving them to a static includable file (or even a server config include) would get you the same benefits without adding load to the page on every request.
Take said, this is still far better than not having a CSP or having a static one, so it's an admirable project regardless.
- riffraff 10y agoyou can allow inline script and style tags with nonce, which you would set per request. This makes it much easier to integrate some stuff.
- aidantwoods 10y agoCSP headers are more often than not: static (bar nonces). Having them be dynamic is really just a bonus to the management aspect you gain here. (You can make sure every page truly only has access to load the sources it needs though). As far as using the class to do it goes, there are other benefits other than just CSP management: auto cookie upgrades and error messages about poor configuration to name a few.