-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSP_INCLUDE_NONCE_IN
not working?
#182
Comments
It looks like the nonce does not get sent in the header if no nonce is being evaluated in your template. Once my template was evaluating a nonce, things work as expected. Perhaps the docs should be updated to reflect this? I'd be happy to give it a shot if folks are open to it. |
Thanks for opening this issue. Was hit with the exact same one today. |
Took a stab at a PR here. I wonder if it makes sense to change this behaviour slightly though as it seems somewhat unsafe. If the nonce isn't used and it's not going to be included in the header, shouldn't the source list be set to 'none'? |
It might be because of the middleware SimpleLazyObject. The SimpleLazyObject may not be properly calling the _make_nonce method. To fix this, you can change the process_request method to directly call the _make_nonce method:
|
I've been unable to get a nonce included in the CSP header generated by
django-csp
. I've followed the instructions in the docs, and everything else seems to be working - other than getting a nonce to show up in the CSP header sent in my responses.My
settings.py
:Header:
Content-Security-Policy: default-src foo bar 'self'
I'd expect something like:
Content-Security-Policy: default-src foo bar 'self' nonce-h893hjkfhdsu9hf8fd8a773hda
Am I doing something wrong or looking in the wrong place? Thanks!
The text was updated successfully, but these errors were encountered: