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.4.tar.gz (138.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.4-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.4-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.4-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.4-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.4-cp312-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12+Windows x86-64

webtoken-0.6.4-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.4-cp312-abi3-manylinux_2_28_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

webtoken-0.6.4-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.4.tar.gz.

File metadata

  • Download URL: webtoken-0.6.4.tar.gz
  • Upload date:
  • Size: 138.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.4.tar.gz
Algorithm Hash digest
SHA256 c9584af14cd98aed0aa7c87fc210e8d8df0f18cd1e7f2f56f09dbc3e6c51f311
MD5 c6bf6cc8c11a971ad5993e99831cf75e
BLAKE2b-256 aac5919de3edd84af7de9192029a2729b8e170c06592193d5d151ae41397a049

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21cdb538d603d0f3dbbb717316239cf2dfb0924f5747cfdd79b95de6facdd5d8
MD5 fcb933e05d5850827c8a8371316efeaa
BLAKE2b-256 0066b0d1a342e1efd36ff0fe1e06aaa099916eae0ffeec9b99c1d4401e7cb074

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 964dd74906934228aff9cdbd9cf95800b1cfa8a95f87bce5e542a6d725b1eb77
MD5 02afbb59dd7051110e15f0adbed61fc3
BLAKE2b-256 1fc1a8c88f41d4f2155d612a7d1eec24bfdc35437fea7621f46ef60df6196a84

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca96186bfa454756f395ac466a917e364fa410e00485dd2dda7ced7dd5b1ceeb
MD5 0c2e694e70b97eab2cd4156b5a150cec
BLAKE2b-256 83de46699bd42b4b863dd8d221a734cf316beb9cd07243d18e4feee0882cf574

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5142aa62330046ff311f7d83203dd39b44002a432f2210720fb95475eadfd862
MD5 76181ed219f133d1b644e027377f557f
BLAKE2b-256 dfa43c146e2d2b7160df8185efeed82c7da949fb3291f9ac2f21259c1a14acdc

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: webtoken-0.6.4-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.4-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 acf54bf2bd87039d7eface5b392e84f780e6ad07e2869041f61126ab75d5e686
MD5 917a7cfa462368f5ea2dd6f3cadb76a6
BLAKE2b-256 2824fdb565c25d6291d832405ee7cc5148392ebf379503fca6db69a41f3b1de8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 253110bfe681bf089d7517e692765f95feed583a1f7c7ff7b5677bdf89db77f9
MD5 99b320955e9a3072d18538d56f2c2791
BLAKE2b-256 ab3340357000b101e97c493603c5384b88d87ba14c6620241b0e36dc8c18e03c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b1e94e77fa37fe96b7e1b6d0376a5b20b60986bd39a5567a5b819f83ea88bd6e
MD5 19d207f8aa7c33a5696a817224dbb486
BLAKE2b-256 e0a00a6fa761e97746ee1efd8026c6c1d07cba431cc99d3e547a9173cf303bf5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for webtoken-0.6.4-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 141bc1f93fb14ca05ce96aaeb1bf2e3057fc9f3e8a8407332d3c8c4f0273f1b1
MD5 2869fbfe285e0c3b08efd952515dacac
BLAKE2b-256 af8e2f45188d14acf958fd1da24f1047f68aea6cfaa4075239f6573840e84a32

See more details on using hashes here.

Provenance

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