PASETO Tokens for Python
This is an unofficial implementation of
for Python.
PASETO versions supported: v2, v3, and v4
Please note that the v2 token type standard is expected to be deprecated in 2022, so new development should be done ideally on versions 3 or 4.
Installation
pip install paseto
Usage
To create/parse paseto tokens, use the create/parse functions. These will automatically handle encoding/decoding the JSON payload for you, and validate claims (currently just the 'exp' expiration registered claim).
import paseto
from paseto.keys.symmetric_key import SymmetricKey
from paseto.protocols.v4 import ProtocolVersion4
my_key = SymmetricKey.generate(protocol=ProtocolVersion4)
# create a paseto token that expires in 5 minutes (300 seconds)
token = paseto.create(
key=my_key,
purpose='local',
claims={'my claims': [1, 2, 3]},
exp_seconds=300
)
parsed = paseto.parse(
key=my_key,
purpose='local',
token=token,
)
print(parsed)
# {'message': {'exp': '2021-10-25T22:43:20-06:00', 'my claims': [1, 2, 3]}, 'footer': None}
You can also make and verify "public" tokens, which are signed but not encrypted:
import paseto
from paseto.keys.asymmetric_key import AsymmetricSecretKey
from paseto.protocols.v4 import ProtocolVersion4
my_key = AsymmetricSecretKey.generate(protocol=ProtocolVersion4)
# create a paseto token that expires in 5 minutes (300 seconds)
token = paseto.create(
key=my_key,
purpose='public',
claims={'my claims': [1, 2, 3]},
exp_seconds=300
)
parsed = paseto.parse(
key=my_key,
purpose='public',
token=token,
)
print(parsed)
# {'message': {'exp': '2021-10-25T22:43:20-06:00', 'my claims': [1, 2, 3]}, 'footer': None}
Changelog
v2.0.0
- Dropping support for python 3.7
- Adding support for python 3.11 and 3.12
- Dependency updates for pendulum, pysodium, pycryptodomex
Metadata
Release files for paseto 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| paseto-2.0.0.tar.gz | 10.2 kB | Without provenance | Details for paseto-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| paseto-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for paseto-2.0.0-py3-none-any.whl |
Total release size: 24.8 kB
Release files / paseto-2.0.0.tar.gz
| Download URL | paseto-2.0.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93d904b5f502ae662e651bc9b5142100bb3a3b986b5bafdf05454644d7f95421
|
|
BLAKE2b-256 checksum How to use checksums |
678d9191b1e1d966f00e606c04239d6f7c8246fb1cb86c0498b15a667afdfaf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / paseto-2.0.0-py3-none-any.whl
| Download URL | paseto-2.0.0-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
670651ef94fc7cd98ffa94e5893434e9f659ea57d1986bfe39f473efa5aaf1b1
|
|
BLAKE2b-256 checksum How to use checksums |
755f71716f91509873788678a752b6b47dd0c0e0cae6375205ce03d4d2c5390c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for paseto 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.