paseto


Namepaseto JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/rlittlefield/pypaseto
SummaryPlatform-Agnostic Security Tokens for Python (PASETO)
upload_time2024-06-04 18:17:36
maintainerNone
docs_urlNone
authorRyan Littlefield
requires_python<4.0,>=3.8
licenseMIT
keywords paseto pypaseto jwt token
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PASETO Tokens for Python
============================================
[![PyPI](https://img.shields.io/pypi/v/paseto.svg)](https://pypi.python.org/pypi/paseto)
[![PyPI - License](https://img.shields.io/pypi/l/paseto.svg)](https://pypi.python.org/pypi/paseto)
[![CI](https://github.com/rlittlefield/pypaseto/actions/workflows/main.yml/badge.svg)](https://github.com/rlittlefield/pypaseto/actions/workflows/main.yml)

This is an unofficial implementation of
![PASETO: Platform-Agnostic Security Tokens](https://paseto.io/) 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).

```python
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:

```python
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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rlittlefield/pypaseto",
    "name": "paseto",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "paseto, pypaseto, jwt, token",
    "author": "Ryan Littlefield",
    "author_email": "ryan@ryanlittlefield.com",
    "download_url": "https://files.pythonhosted.org/packages/67/8d/9191b1e1d966f00e606c04239d6f7c8246fb1cb86c0498b15a667afdfaf2/paseto-2.0.0.tar.gz",
    "platform": null,
    "description": "PASETO Tokens for Python\n============================================\n[![PyPI](https://img.shields.io/pypi/v/paseto.svg)](https://pypi.python.org/pypi/paseto)\n[![PyPI - License](https://img.shields.io/pypi/l/paseto.svg)](https://pypi.python.org/pypi/paseto)\n[![CI](https://github.com/rlittlefield/pypaseto/actions/workflows/main.yml/badge.svg)](https://github.com/rlittlefield/pypaseto/actions/workflows/main.yml)\n\nThis is an unofficial implementation of\n![PASETO: Platform-Agnostic Security Tokens](https://paseto.io/) for Python.\n\nPASETO versions supported: v2, v3, and v4\n\nPlease 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.\n\nInstallation\n------------\n\n    pip install paseto\n\n\nUsage\n-----\n\nTo create/parse paseto tokens, use the create/parse functions. These will\nautomatically handle encoding/decoding the JSON payload for you, and validate\nclaims (currently just the 'exp' expiration registered claim).\n\n```python\nimport paseto\nfrom paseto.keys.symmetric_key import SymmetricKey\nfrom paseto.protocols.v4 import ProtocolVersion4\nmy_key = SymmetricKey.generate(protocol=ProtocolVersion4)\n\n# create a paseto token that expires in 5 minutes (300 seconds)\ntoken = paseto.create(\n    key=my_key,\n    purpose='local',\n    claims={'my claims': [1, 2, 3]},\n    exp_seconds=300\n)\n\nparsed = paseto.parse(\n    key=my_key,\n    purpose='local',\n    token=token,\n)\nprint(parsed)\n# {'message': {'exp': '2021-10-25T22:43:20-06:00', 'my claims': [1, 2, 3]}, 'footer': None}\n```\n\nYou can also make and verify \"public\" tokens, which are signed but not\nencrypted:\n\n```python\nimport paseto\nfrom paseto.keys.asymmetric_key import AsymmetricSecretKey\nfrom paseto.protocols.v4 import ProtocolVersion4\nmy_key = AsymmetricSecretKey.generate(protocol=ProtocolVersion4)\n\n# create a paseto token that expires in 5 minutes (300 seconds)\ntoken = paseto.create(\n    key=my_key,\n    purpose='public',\n    claims={'my claims': [1, 2, 3]},\n    exp_seconds=300\n)\n\nparsed = paseto.parse(\n    key=my_key,\n    purpose='public',\n    token=token,\n)\nprint(parsed)\n# {'message': {'exp': '2021-10-25T22:43:20-06:00', 'my claims': [1, 2, 3]}, 'footer': None}\n```\n\n\nChangelog\n---------\n\n### v2.0.0\n* Dropping support for python 3.7\n* Adding support for python 3.11 and 3.12\n* Dependency updates for pendulum, pysodium, pycryptodomex\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Platform-Agnostic Security Tokens for Python (PASETO)",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/rlittlefield/pypaseto",
        "Repository": "https://github.com/rlittlefield/pypaseto"
    },
    "split_keywords": [
        "paseto",
        " pypaseto",
        " jwt",
        " token"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "755f71716f91509873788678a752b6b47dd0c0e0cae6375205ce03d4d2c5390c",
                "md5": "d5ee47a90e16e55d56b5e51d379b5804",
                "sha256": "670651ef94fc7cd98ffa94e5893434e9f659ea57d1986bfe39f473efa5aaf1b1"
            },
            "downloads": -1,
            "filename": "paseto-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d5ee47a90e16e55d56b5e51d379b5804",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 14562,
            "upload_time": "2024-06-04T18:17:34",
            "upload_time_iso_8601": "2024-06-04T18:17:34.932177Z",
            "url": "https://files.pythonhosted.org/packages/75/5f/71716f91509873788678a752b6b47dd0c0e0cae6375205ce03d4d2c5390c/paseto-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "678d9191b1e1d966f00e606c04239d6f7c8246fb1cb86c0498b15a667afdfaf2",
                "md5": "54c3b074fcea5e7cb9fbe906f1387c15",
                "sha256": "93d904b5f502ae662e651bc9b5142100bb3a3b986b5bafdf05454644d7f95421"
            },
            "downloads": -1,
            "filename": "paseto-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "54c3b074fcea5e7cb9fbe906f1387c15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 10241,
            "upload_time": "2024-06-04T18:17:36",
            "upload_time_iso_8601": "2024-06-04T18:17:36.564194Z",
            "url": "https://files.pythonhosted.org/packages/67/8d/9191b1e1d966f00e606c04239d6f7c8246fb1cb86c0498b15a667afdfaf2/paseto-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-04 18:17:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rlittlefield",
    "github_project": "pypaseto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "paseto"
}
        
Elapsed time: 0.31644s