Skip to content

Commit 43ec028

Browse files
Consolidate csp_nonce usages to a single property on the toolbar. (#2099)
* Consolidate csp_nonce usages to a single property on the toolbar. * Unpin django-csp for tests.
1 parent aa229c0 commit 43ec028

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

debug_toolbar/toolbar.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def csp_nonce(self):
7474
have a nonce associated with the request. Use the private attribute
7575
because the lazy object wrapped value can generate a nonce by
7676
accessing it. This isn't ideal when the toolbar is injecting context
77-
into the response because it may set a nonce that is not used with
77+
into the response because it may set a nonce not used with
7878
other assets.
7979
"""
80-
return getattr(self.request, "_csp_nonce", None)
80+
return getattr(self.request, "csp_nonce", None)
8181

8282
def get_panel_by_id(self, panel_id):
8383
"""

docs/changes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Pending
1111
or ``async_to_sync`` to allow sync/async compatibility.
1212
* Make ``require_toolbar`` decorator compatible to async views.
1313
* Added link to contributing documentation in ``CONTRIBUTING.md``.
14-
* Rely on django-csp's private attribute for nonce, ``request._csp_nonce``.
14+
* Create a CSP nonce property on the toolbar ``Toolbar().csp_nonce``.
1515

1616
5.0.1 (2025-01-13)
1717
------------------

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ deps =
2525
pygments
2626
selenium>=4.8.0
2727
sqlparse
28-
django-csp<4
28+
django-csp
2929
passenv=
3030
CI
3131
COVERAGE_ARGS

0 commit comments

Comments
 (0)