Conversation
|
|
||
| ## Content Security Policy | ||
|
|
||
| - Include the `django.middleware.csp.ContentSecurityPolicyMiddleware` module in the `MIDDLEWARE` setting in your project's `settings.py` to add CSP related header to your responses. |
There was a problem hiding this comment.
I would recommend adding a link to Django's documentation for CSP middleware. This will help the reader explore further if they are interested.
| "style-src": [CSP.SELF], | ||
| } | ||
| ``` | ||
| - Add the csp context processor to your TEMPLATES setting, this will add the nonce to the context of all your Django templates |
There was a problem hiding this comment.
I would recommend adding a link to the nonce section of the Content Security Policy Cheatsheet that explains nonces further.
|
These seems small and reasonable. If you give us a clean PR on just this and only this I will accept it. Also, please run your sentences through a grammar checker as well, or ask AI to check your sentences for grammar. |
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Pull request overview
This PR adds a new section on Content Security Policy (CSP) implementation to the Django Security Cheat Sheet. The section aims to provide guidance on configuring CSP headers in Django applications.
Changes:
- Added a new "Content Security Policy" section with middleware configuration, CSP policy settings, template context processor configuration, and nonce usage examples
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You're A Rockstar
Thank you for submitting a Pull Request (PR) to the Cheat Sheet Series.
Please make sure that for your contribution:
[TEXT](URL)If your PR is related to an issue, please finish your PR text with the following line:
This PR fixes issue #
<REPLACE WITH ISSUE NUMBER>.AI Tool Usage Disclosure (required for all PRs)
Please select one of the following options:
the contents and I affirm the results. The LLM used is
[llm name and version]and the prompt used is
[your prompt here]. [Feel free to add more details if needed]Thank you again for your contribution 😃