Skip to main content

A Rust-backed JWT library

Project description

Python Tests

webtoken

Rust-backed JWT

Size

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

Speed

Simple benchmark comparison to PyJWT

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.14
  • Tests are run on and wheels are available for Linux (+ Alpine) / Windows / MacOS / FreeBSD

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

  • 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 is mostly based on aws-lc-rs.

XChaCha20 support, for PASETO v4 and JWE, comes via Graviola.

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.6.0.tar.gz (124.7 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.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

webtoken-0.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

webtoken-0.6.0-cp311-abi3-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11+Windows x86-64

webtoken-0.6.0-cp311-abi3-musllinux_1_2_x86_64.whl (1.9 MB view details)

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

webtoken-0.6.0-cp311-abi3-manylinux_2_28_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

webtoken-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

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

webtoken-0.6.0-cp311-abi3-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for webtoken-0.6.0.tar.gz
Algorithm Hash digest
SHA256 6111e7c1234e14cd4d94ba66008db224dc6592cae38300efd13ae4103eebfb18
MD5 76f025d55c3509672cb8dcff958453e3
BLAKE2b-256 edf099e494b1c1f9d4236f0a0b755fd374498d991f87124bda296bd05f003088

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b88a5345399ee8957ed8fc637c101c24c72d0adefed210fe3f757a866ff7ad70
MD5 fde027e0db873a0d27c137744f2f9072
BLAKE2b-256 06a98c03a03f4387dcfa36849065b36aeca687e71e7b83e02843d174a3426b9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ad94f3229bbcaea0e63562a4fd9543d84347b40e2efcec3b08e292e8487910f3
MD5 6ab1c9ac15778b3c26b6a59e0807a363
BLAKE2b-256 5c42f4ca66a53bcf6c23990abe20a0986087b01c9b4e7698a07f1217bd528279

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: webtoken-0.6.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.3 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.6.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b3ae2a72660c07a3ba23e32b65a98554e70d63b037bd5c7acbe17febbc340486
MD5 9a362a3c343828acf6f6c6628680d7f0
BLAKE2b-256 f25f79b7daceea410d7ff0a0d213ba6cd591c59bc6e8b885d1cb18395622f2ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d4525d9b0c0a0d4bacee0c23792d6e1f328519e2816299e2ca3b192b34d4950e
MD5 118933a82f74271fb87391d277fc5eca
BLAKE2b-256 86a8bb682560495a2871e810a780ca9563184570d2d2f83b1561df0fc13eb592

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 83a14f417d50a8dba79f42cf8568ab908365d1c4a786f0bf5b07b85da6ebedd8
MD5 be4e6b2e49a377c28226093059c17f6c
BLAKE2b-256 66d4c222e7581de06277307dc84b593c58c151fd51f8ad43a782385771ea0ab4

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f9f3f5176228d0c20b34af9b2e717952dbab7e9271895b0045a6b5aac9f3ac9
MD5 c3847776cb01e033ad62056e8f339acd
BLAKE2b-256 65fa93ddd45c561915c70ac26ecd7b9aa348a4e044b49e85d0675013af5095ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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.6.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 00e3c88268f3788f964483202f233b41d7a2736a9b525a3e52962a8fddfabec3
MD5 304757d92eeec8226b7f70a356b57700
BLAKE2b-256 fb0324f4d6841d12874cc1f31a39c4982acd9cec7c25bcc3f4f8d99b97c504a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.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