-
-
Notifications
You must be signed in to change notification settings - Fork 46
Add support for Content-Security-Policy #367
Comments
Any good reading on the subject? |
I think it could be done in two ways via .htaccess and via Html :: tag ('meta') |
https://websec.be/blog/cspstrictdynamic/ @terabytesoftw as a PHP framework |
@SamMousa I've checked it. Seems what's proposed with hashes still require extensive fallback usage. While hashes could be automated, I'm not sure about fallback. If it could be done in a universal way, I am all for implementing it as part of assets concept. |
in
and the remaining headers. |
No, that is not the place to do it. SapiEmitter is just "echoing" what is contained in the response object as is. If you need extra headers, these should be added in a middleware. |
Since this is the view component, would it make sense to always use a meta tag? Regarding script src verification, we could use a random nonce for every request; this would be really simple to implement. |
OK.
Fine. |
We have the ForceSecureConnection middleware with CSP policy support |
@roxblnfk that doesn't include external file hashes. |
yes. |
To be honest, looking at the code in The class header Why not have a trivial Furthermore, an HSTS header is added to normal HTTP requests, but that will always be ignored: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security For me CSP is a subject totally unrelated to HTTPS redirects and HSTS headers... Since the CSP support that would best fit the framework is a dynamically generated one, it makes more sense to have a middleware later in the chain that gathers (or receives) parts from application services (like the view). Since at the end of the request we know which inline and external scripts we have etc we can then decide calculate the final CSP header. |
This is just notice, not solution. The If we will create a detailed solution with CSP, taking into account assets and so on, it will be cool. Then it will be possible to remove unnecessary responsibility from this middleware. |
We should add advanced support for
Content-Security-Policy
directives:registerJs
,registerJsFile
.The text was updated successfully, but these errors were encountered: