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.

Simple RAM usage benchmark -

RAM Footprint on Import (Native Linux /proc/self/status):

jwt:         17.54 MB
webtoken:    5.14 MB

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.3.tar.gz (136.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.6.3-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

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

webtoken-0.6.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

webtoken-0.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

webtoken-0.6.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

webtoken-0.6.3-cp312-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12+Windows x86-64

webtoken-0.6.3-cp312-abi3-musllinux_1_2_x86_64.whl (2.0 MB view details)

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

webtoken-0.6.3-cp312-abi3-manylinux_2_28_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

webtoken-0.6.3-cp312-abi3-macosx_10_12_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for webtoken-0.6.3.tar.gz
Algorithm Hash digest
SHA256 e60c90462644639881ede0756421502db1733b71e2ecc1241d90e389fee9b8af
MD5 21d1cc664e89bed4054e1c816cd20fce
BLAKE2b-256 0e8052859bf92bca65a1b985811f6f31c9e9f1289277c7902253be0119f60fbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3.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.3-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e151ee804f179439fe963b400044d437b7e4fc31ea694d4aa192859d9d5f4f6
MD5 18b3b1a890d4f1dffb0238708e2f1bc9
BLAKE2b-256 94daf989cf3129e8807770cf050fb0f951cda13e3fadf4d30d149cef6c99c964

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp315-abi3.abi3t-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.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f14bc8b41f4bed578a4bd226c113887af01810108bd6a07fa2b5f3922a7cb7a9
MD5 03a3e695fd2bf75806a9fd97ce70b919
BLAKE2b-256 87066f21a43138670d07444131da04f979e1d94dd4afc614b920ec0124b8d6b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp314-cp314-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.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af97668ce9b324f2b2f04ced0d02826842717659f952f1bc2fc320e71adf41ab
MD5 4c5a4a18ad1875ca3ca50370037e61e6
BLAKE2b-256 3cfa021a3df2f022f4ff389b324a190634ce6286b093e79788550cf940ca9fd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp313-cp313-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.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e824ac87c2a75b10b28a18cec10219827cd228f36b7a50317eeb97f9681874f
MD5 dea7604db3e31136a7f5b55ed06c51a7
BLAKE2b-256 3f2932195d69ff7b906302c7e94e8efc472dc7d8323971278108cc3c878c1436

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp312-cp312-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.3-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: webtoken-0.6.3-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for webtoken-0.6.3-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3b68c1159711c458c29e9972c8e3ccba5fb07515491c66ee16c675339837940d
MD5 eec39efb2254ed42ef605fa315e2e96f
BLAKE2b-256 030db97f2cb3b18d9f679ecaafb59e4c80338a6d80ad3b4bb5fc8b7915966d6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp312-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.3-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 16fa097afa84cf1c8ebaeb764df4c0b4bd8f2ead9f14b9fba174eddeaba5a0bf
MD5 8e1081c308e9502b9fd63803e130004f
BLAKE2b-256 6d361579b013b1f16e9574a93ac1ccaca0989a3cfe07726faf71a94b17715264

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp312-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.3-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 06dbf715e7da031cb0371c3328148e5702c322a43e4db66e0c882b861837d574
MD5 a9d45893c0b554e08dcde068785f8b21
BLAKE2b-256 4f4ab1fb884bd58389b799a87a2e300bdd289fd938ca305ae07131a16ca19105

See more details on using hashes here.

Provenance

The following attestation bundles were made for webtoken-0.6.3-cp312-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.3-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for webtoken-0.6.3-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9584c25a4a4ff36a97606e02a5c3f3a9c6b52930c1ce8e0413365bd05ddc35e1
MD5 82c695086fec3e94de8c48f8298f12d9
BLAKE2b-256 f8268f5d503d5f7f384b5eb759a651fa5932f4f37db50ba4fad91c4a76071370

See more details on using hashes here.

Provenance

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