| 1 |
.. rst-class:: hide-header |
| 2 |
|
| 3 |
ItsDangerous |
| 4 |
============ |
| 5 |
|
| 6 |
.. image:: _static/itsdangerous-logo.png |
| 7 |
:align: center |
| 8 |
:target: https://palletsprojects.com/p/itsdangerous/ |
| 9 |
|
| 10 |
Sometimes you want to send some data to untrusted environments, then get |
| 11 |
it back later. To do this safely, the data must be signed to detect |
| 12 |
changes. |
| 13 |
|
| 14 |
Given a key only you know, you can cryptographically sign your data and |
| 15 |
hand it over to someone else. When you get the data back you can ensure |
| 16 |
that nobody tampered with it. |
| 17 |
|
| 18 |
The receiver can see the data, but they can not modify it unless they |
| 19 |
also have your key. So if you keep the key secret and complex, you will |
| 20 |
be fine. |
| 21 |
|
| 22 |
|
| 23 |
Installing |
| 24 |
---------- |
| 25 |
|
| 26 |
Install and update using `pip`_: |
| 27 |
|
| 28 |
.. code-block:: text |
| 29 |
|
| 30 |
pip install -U itsdangerous |
| 31 |
|
| 32 |
.. _pip: https://pip.pypa.io/en/stable/quickstart/ |
| 33 |
|
| 34 |
|
| 35 |
Example Use Cases |
| 36 |
----------------- |
| 37 |
|
| 38 |
- Sign a user ID in a URL and email it to them to unsubscribe from a |
| 39 |
newsletter. This way you don't need to generate one-time tokens and |
| 40 |
store them in the database. Same thing with any kind of activation |
| 41 |
link for accounts and similar things. |
| 42 |
- Signed objects can be stored in cookies or other untrusted sources |
| 43 |
which means you don't need to have sessions stored on the server, |
| 44 |
which reduces the number of necessary database queries. |
| 45 |
- Signed information can safely do a round trip between server and |
| 46 |
client in general which makes them useful for passing server-side |
| 47 |
state to a client and then back. |
| 48 |
|
| 49 |
|
| 50 |
Table of Contents |
| 51 |
----------------- |
| 52 |
|
| 53 |
.. toctree:: |
| 54 |
|
| 55 |
concepts |
| 56 |
serializer |
| 57 |
signer |
| 58 |
exceptions |
| 59 |
timed |
| 60 |
url_safe |
| 61 |
encoding |
| 62 |
license |
| 63 |
changes |