Update dependency django-csp to v4 #163
Loading…
Reference in a new issue
No description provided.
Delete branch "renovate/django-csp-4.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
==3.8→==4.0Release Notes
mozilla/django-csp (django-csp)
v4.0Compare Source
===
This release contains several breaking changes. For a complete migration guide, see:
https://django-csp.readthedocs.io/en/latest/migration-guide.html
Breaking Changes
Configuration Format: Moved to dict-based configuration which allows for setting policies for
both enforced and report-only. Instead of using individual settings with
CSP_prefixes, you nowuse dictionaries called
CONTENT_SECURITY_POLICYand/orCONTENT_SECURITY_POLICY_REPORT_ONLY.(#219)
You can use Django's check command to automatically identify existing CSP settings and generate a
template for the new configuration format:
This will detect your old
CSP_prefixed settings and output a draft of the new dict-basedconfiguration, giving you a starting point for migration.
Example:
Change from:
to:
Nonce Configuration: Switched from specifying directives that should contain nonces as a
separate list to using a sentinel
NONCEvalue in the directive itself.(#223)
Example:
Change from:
to:
Nonce Behavior: Changed how
request.csp_nonceworks - it is now Falsy(
bool(request.csp_nonce)) until it is read as a string (e.g., used in a template or withstr(request.csp_nonce)). Previously, it always tested asTrue, and testing generated the nonce.(#270)
Before:
After:
Dropped support for Django ≤3.2.
Dropped support for Python 3.8.
New Features and Improvements
Dual Policy Support: Added support for enforced and report-only policies simultaneously using
the separate
CONTENT_SECURITY_POLICYandCONTENT_SECURITY_POLICY_REPORT_ONLYsettings.Example:
CSP Constants: Added CSP keyword constants in
csp.constants(e.g.,SELFinstead of"'self'") to minimize quoting mistakes and typos.(#222)
Example:
Change from:
to:
Added comprehensive type hints. (#228)
Added
EXCLUDE_URL_PREFIXEScheck not a string. (#252)Added support for CSP configuration as sets. (#251)
Changed
REPORT_PERCENTAGEto be a float between0.0and100.0and improved behavior for 100%report percentage to always send CSP reports.
Added ability to read the nonce after response if it was included in the header. This will raise
an error when nonce is accessed after response if not already generated.
(#269)
Made changes to simplify middleware logic and make
CSPMiddlewareeasier to subclass. The updatedmiddleware returns a PolicyParts dataclass that can be modified before the policy is built.
(#237)
Other Changes
Configuration
📅 Schedule: Branch creation - Only on Sunday and Saturday ( * * * * 0,6 ) in timezone America/New_York, Automerge - Only on Sunday and Saturday ( * * * * 0,6 ) in timezone America/New_York.
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.
Renovate Ignore Notification
Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future
4.xreleases. But if you manually upgrade to4.xthen Renovate will re-enableminorandpatchupdates automatically.If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.