Skip to main content

A Rust-backed JWT library

Project description

Python Tests

webtoken

Rust-backed JWT

Size

The .so size on linux is ~4.4Mb, 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.5.tar.gz (141.9 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.5-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

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

webtoken-0.6.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

webtoken-0.6.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

webtoken-0.6.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

webtoken-0.6.5-cp312-abi3-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12+Windows x86-64

webtoken-0.6.5-cp312-abi3-musllinux_1_2_x86_64.whl (2.2 MB view details)

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

webtoken-0.6.5-cp312-abi3-manylinux_2_28_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

webtoken-0.6.5-cp312-abi3-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: webtoken-0.6.5.tar.gz
  • Upload date:
  • Size: 141.9 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.5.tar.gz
Algorithm Hash digest
SHA256 27485e43a5a4e8b0c17abcbda9f9999cde6113ea332024f87ec97232c4af90be
MD5 0460a1ff47e36ec8bdab1faa59c6c6b7
BLAKE2b-256 72ae718572e7d00d998ea96d01f69a33d80555186a46496ae86600b99317251b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9da793dcbf02dffc00e53abd0828e9cc5957be380247351ae4e39c89484a26d
MD5 4a601bc38c020da18080348864eeb769
BLAKE2b-256 9bb294220e9b1f9803d43965979977201a642d639aff5309cd2d37497284a328

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 532a7887568425bf5a182fe5afe5da11609a706ff010fe484b76549666bcabee
MD5 a882cf58a26fbe065a25122207baf589
BLAKE2b-256 5eb732c61f313ab54e6bd7d7ebd17f97b9c4e3117d07eb4db96d4dcc578da03b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6ae7766d61aed50bfbc660cf7dd0055bbea9e5a12d449651996c5a13e93056c
MD5 8c1c242580cfa463abba7aaeede9edf5
BLAKE2b-256 8da68107731d49b2ca7d41ca21c846f7e56de61ee29713a7a24ed30a7128e0a8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e53cf30d9865747cfe8c7ebaacd239ff0e5ef731d6274fef75a2bfc95baa3193
MD5 5325df3fa2a972eb1941e094a445b7f6
BLAKE2b-256 ccf1a81a3a06344ca8cdf2b27afff7de4ea06982f4cf3014ebe982c39f6c4384

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: webtoken-0.6.5-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.5-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e964d1d46ea3ee4a2fb83bfbab49c5bdb58230d5397bc8a1daa059df754579dc
MD5 1d839e49a5028564e46fe4137f5c963f
BLAKE2b-256 18deedaee03e2ffe7d1d404c63d9d7d807465f61f3ebc012e92365e8e7000d06

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 593b67a5172f23dc512a4d76ec4fd9c37957634b42d8036947a4bb39a385234d
MD5 b1027c87bd3208c0123ca12a6b302019
BLAKE2b-256 f5f7289c0b31ca349603ed43a293b6a9cc63f43c476a1ebebd636c80ce300a93

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c465fa1e0c04bc7a8748396b3cb8cabca870b53c4a45f68bbaf3e58e5e056319
MD5 e5b56d2048f28573b0708e247c177260
BLAKE2b-256 161e7032cc4fd04d5da3cf331664b9097246313583cc4ebab90d42f8c09fad17

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.5-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a87d740d615f839ae9b34dfc59d42959b602777986fe2a8c2afde9338bdd7ea6
MD5 c80f9b4c494da99285c8a2a12bcd6dee
BLAKE2b-256 227f6ed897f0b6dbe2b7b7f8df1a346a64a4d79f4ee3bfb4a1418690c9c520db

See more details on using hashes here.

Provenance

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