1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #33199 -- Deprecated passing positional arguments to Signer/TimestampSigner.

Thanks Jacob Walls for the implementation idea.
This commit is contained in:
SirAbhi13
2022-11-30 12:33:36 +05:30
committed by Mariusz Felisiak
parent 3fec3bf90b
commit b8738aea14
6 changed files with 89 additions and 32 deletions

View File

@@ -42,6 +42,9 @@ details on these changes.
* Support for passing encoded JSON string literals to ``JSONField`` and
associated lookups and expressions will be removed.
* Support for passing positional arguments to ``Signer`` and
``TimestampSigner`` will be removed.
.. _deprecation-removed-in-5.0:
5.0

View File

@@ -540,3 +540,6 @@ Miscellaneous
* ``TransactionTestCase.assertQuerysetEqual()`` is deprecated in favor of
``assertQuerySetEqual()``.
* Passing positional arguments to ``Signer`` and ``TimestampSigner`` is
deprecated in favor of keyword-only arguments.

View File

@@ -96,12 +96,12 @@ By default, the ``Signer`` class uses the :setting:`SECRET_KEY` setting to
generate signatures. You can use a different secret by passing it to the
``Signer`` constructor::
>>> signer = Signer('my-other-secret')
>>> signer = Signer(key='my-other-secret')
>>> value = signer.sign('My string')
>>> value
'My string:EkfQJafvGyiofrdGnuthdxImIJw'
.. class:: Signer(key=None, sep=':', salt=None, algorithm=None, fallback_keys=None)
.. class:: Signer(*, key=None, sep=':', salt=None, algorithm=None, fallback_keys=None)
Returns a signer which uses ``key`` to generate signatures and ``sep`` to
separate values. ``sep`` cannot be in the :rfc:`URL safe base64 alphabet
@@ -115,6 +115,10 @@ generate signatures. You can use a different secret by passing it to the
The ``fallback_keys`` argument was added.
.. deprecated:: 4.2
Support for passing positional arguments is deprecated.
Using the ``salt`` argument
---------------------------
@@ -172,7 +176,7 @@ created within a specified period of time::
>>> signer.unsign(value, max_age=timedelta(seconds=20))
'hello'
.. class:: TimestampSigner(key=None, sep=':', salt=None, algorithm='sha256')
.. class:: TimestampSigner(*, key=None, sep=':', salt=None, algorithm='sha256')
.. method:: sign(value)
@@ -195,6 +199,10 @@ created within a specified period of time::
otherwise raises ``SignatureExpired``. The ``max_age`` parameter can
accept an integer or a :py:class:`datetime.timedelta` object.
.. deprecated:: 4.2
Support for passing positional arguments is deprecated.
.. _signing-complex-data:
Protecting complex data structures