Skip to main content

A Rust-backed JWT library

Project description

Python Version

webtoken

Rust-backed JWT

Size

The .so size on linux is ~3.5Mb, no external dependencies.

Speed

Simple benchmark

HS256
Enc: 2.1x | Dec: 1.5x

RS256
Enc: 54.4x | Dec: 1.3x

ES256
Enc: 1.9x | Dec: 1.4x

EdDSA
Enc: 2.9x | Dec: 2.5x

ES512
Enc: 1.9x | Dec: 1.5x

More under benchmarks.

Installation

pip install webtoken

  • Developed on Linux / Python 3.13
  • Tested on Linux (+ Alpine) / Windows / MacOS / FreeBSD
  • Wheels available for Linux (+ Alpine) / Windows / MacOS

Usage

PyJWT Style (Drop-in Replacement)

import webtoken as jwt

key = "secret"
payload = {"sub": "1234567890", "name": "John Doe", "iat": 1516239022}
token = jwt.encode(payload, key, algorithm="HS256")

decoded = jwt.decode(token, key, algorithms=["HS256"])
print(decoded)
# {'sub': '1234567890', 'name': 'John Doe', 'iat': 1516239022}

Asyncio variants

  • The rust based encode/decode release the GIL

  • You can send them away on asyncio.to_thread(), or use the provided wrappers

import webtoken as wt

payload = {"name": "Bob"}
token = await wt.encode_async(payload, "secret", algorithm="HS256")

decoded = await wt.decode_async(token, "secret", algorithms=["HS256"])
print(decoded)
# {'name': 'Bob'}

Crypto / base64 complementary utils

  • Since webtoken already has aws-lc-rs in its standalone module, it exposes several auxiliary utilities

  • This, for example, allows running tests, such as the PyJWT ported test suites, without importing cryptography

import webtoken as wt


wt.base64url_encode('bob')    # utf8 strings or bytes
# b'Ym9i'

wt.base64url_decode(b'Ym9i').decode()
# 'bob'

rand_7 = wt.random_bytes(7)       # Get your cryptographically secure random bytes here 

priv, pub = wt.generate_key_pair('rs256')  

verifier, challenge = wt.generate_pkce_pair()

Compatibility

Effort is made to make toke as compatible as possible with PyJWT. For compatibility details, See the readme under tests.

Crypto

The crypto backend used by webtoken is aws-lc-rs.

Supported algorithms

PyJWT compat -

  • HS256
  • HS384
  • HS512
  • RS256
  • RS384
  • RS512
  • ES512

As well as -

  • ES256K
  • ML-DSA-65

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webtoken-0.5.0.tar.gz (87.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

webtoken-0.5.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded PyPymusllinux: musl 1.2+ x86-64

webtoken-0.5.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

webtoken-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

webtoken-0.5.0-cp313-cp313t-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

webtoken-0.5.0-cp311-abi3-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

webtoken-0.5.0-cp311-abi3-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

webtoken-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

webtoken-0.5.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

webtoken-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file webtoken-0.5.0.tar.gz.

File metadata

  • Download URL: webtoken-0.5.0.tar.gz
  • Upload date:
  • Size: 87.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for webtoken-0.5.0.tar.gz
Algorithm Hash digest
SHA256 665c9a90fb4830a97376a4b040471519893cda0da7ff291c7c814c3af76d2074
MD5 fc39184a6d62014b0ef8380374b37421
BLAKE2b-256 1a181b44e889fe51e57208a1cbfc487eaccc8ce3970b030d24819d99e28f775d

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0.tar.gz:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f8a1721893cf6c843d0ece8e2a4e57e42966e4e07abbb4186d6884efa5c974d8
MD5 6016031bff67c99a343ee16c0f21101c
BLAKE2b-256 05bd931a6648e137c6094bb9617e4830c0d8c3db07437bf217f094208f3908d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c7463cdb58e7373753b12f2bb25cdd3c1ec0cc24eb0515f8d6571fff17c6ed2
MD5 6b7f8bfc87f32b5fe7b397052b2bf935
BLAKE2b-256 d5e2d0cefeb069fce03ef7b48d8785a7b6138b828a3075ccbeaa410211c0e52e

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 37a3d01eb366079c4a37eec6718693933459834404d8e05947b764dde267e64d
MD5 47e28f601a41858a4390585e07fe675b
BLAKE2b-256 374d5ed0b055d7ee2c78d47264251bd49e3a693eb34831b6ff9950b3888e631a

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 291f3948cc4c44f42e09c4e10342bd68b8154db22c2d8bf35c09c9844508f983
MD5 f0e101df549d2b1591d6f08f99275f36
BLAKE2b-256 880931ffec783d1706718f76a19f34538a1e19d79b7e4fca266a9135b2484a32

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp313-cp313t-musllinux_1_2_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: webtoken-0.5.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for webtoken-0.5.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 184b69df8c6ea3cf34beedffbd6606aa31d3b514e30064ca4c9d60290dff87ae
MD5 c4120427bd31cb7575368b9e9841d928
BLAKE2b-256 cb6f8a585cb5b7c99d2495b1d38aba92f303c400caec2169fd40adf65586dbfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp311-abi3-win_amd64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8868874f031a6a4e46671f0154b60711c6e9532dee959e9bcb738d934522549e
MD5 6a182b210217490f7d985a048719993f
BLAKE2b-256 9177434fbbb76242416227c8b0decad75837d6461f8be459119643286f98023a

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 af70e29f261b1e2049e6196672efa67a17efbd1897c92636744757da178a5c66
MD5 85f9f9b90150a2f4bbc9f7a20d7f5b71
BLAKE2b-256 5413ee76e4b4c761c139f403af95db4b69b51dac39d1e454c44085d21b104f77

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1ae4dd42d3455f4f85b1ac526248427929f5f67d53ecfb1ac80e565e3827be9b
MD5 1dceb5459e94033e2f713c7e00c17f9b
BLAKE2b-256 aff325aa44021c8d04db50fedd3057cbf79ee065d12203013d440d6df5e554bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file webtoken-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0dc7a7dffc551fbefb3d7487330ddd5b6bd9e35e800b62c4d3ea4f7c1c3f15b6
MD5 d56635588574baa1145720d7398ab033
BLAKE2b-256 78de634eccae3a9a3ac51f57d07a34a397e1b18e3e9d05e672726fb62280ebb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.5.0-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on h5rdly/webtoken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page