| 1 |
.. module:: itsdangerous.timed |
| 2 |
|
| 3 |
Signing With Timestamps |
| 4 |
======================= |
| 5 |
|
| 6 |
If you want to expire signatures you can use the |
| 7 |
:class:`TimestampSigner` class which adds timestamp information and |
| 8 |
signs it. On unsigning you can validate that the timestamp is not older |
| 9 |
than a given age. |
| 10 |
|
| 11 |
.. code-block:: python |
| 12 |
|
| 13 |
from itsdangerous import TimestampSigner |
| 14 |
s = TimestampSigner('secret-key') |
| 15 |
string = s.sign('foo') |
| 16 |
|
| 17 |
.. code-block:: python |
| 18 |
|
| 19 |
s.unsign(string, max_age=5) |
| 20 |
Traceback (most recent call last): |
| 21 |
... |
| 22 |
itsdangerous.exc.SignatureExpired: Signature age 15 > 5 seconds |
| 23 |
|
| 24 |
.. autoclass:: TimestampSigner |
| 25 |
:members: |
| 26 |
|
| 27 |
.. autoclass:: TimedSerializer |
| 28 |
:members: |