⚡ OxyJWT
A high-performance Python JWT/JWS library backed by a native Rust core.
Drop-in replacement for PyJWT with up to 4× higher throughput, native security, and full JWKS support.
Documentation • Benchmarks • Quickstart • JWKS Client • Security
✨ Features
- 🚀 Blazing Fast: Up to 4× faster encoding and 3.3× faster decoding than PyJWT for HS256 and EdDSA. Built with a single-pass Rust parser, fast Python dispatch, and fat Link-Time Optimization (LTO).
- 🔄 Drop-in PyJWT Replacement: Fully compatible API for
encode,decode,decode_complete,get_unverified_header,PyJWKClient, and standard claim validation options. - 🛡️ Secure by Default: Mandatory server-side algorithm allowlists, strictly rejects
alg: "none", constant-time signature comparisons, and SSRF-hardened JWKS client with cache and rate limits. - 🔑 Modern Cryptography: Powered by
aws-lc-rs(AWS Libcrypto). Supports HMAC, RSA, RSA-PSS, ECDSA, and EdDSA (Ed25519). - ⚡ High-Speed Serialization: Deep integration with
orjsonfor ultrafast JSON parsing and serialization. - 📦 Batteries Included: Pre-built binary wheels available for Linux (x86_64, aarch64), macOS (Apple Silicon, Intel), and Windows.
📊 Performance Benchmarks
Measured on modern Linux hardware comparing median operations per second (ops/sec) across libraries (higher is better):
| Algorithm | Operation | OxyJWT | PyJWT | Authlib | python-jose | OxyJWT Speedup |
|---|---|---|---|---|---|---|
| HS256 | Encode | 666,018 | 172,057 | 121,276 | 118,782 | ~3.9× faster 🚀 |
| HS256 | Decode | 421,031 | 131,095 | 118,723 | 63,573 | ~3.2× faster 🚀 |
| EdDSA | Encode | 73,626 | 18,551 | 16,443 | N/A | ~4.0× faster 🚀 |
| EdDSA | Decode | 29,773 | 10,757 | 9,914 | N/A | ~2.8× faster 🚀 |
| RS256 | Decode | 62,634 | 28,565 | 28,727 | 25,335 | ~2.2× faster 🚀 |
| ES256 | Encode | 47,428 | 22,113 | 16,032 | 21,758 | ~2.1× faster 🚀 |
📦 Installation
pip install oxyjwt
Requires Python 3.10+. Binary wheels include pre-compiled Rust extensions for all major operating systems.
🚀 Quick Start
1. HMAC (Symmetric)
import time
import oxyjwt
secret = "your-256-bit-secret"
payload = {
"sub": "user_42",
"role": "admin",
"iss": "https://auth.example.com",
"aud": "https://api.example.com",
"exp": int(time.time()) + 3600,
}
# Encode a token
token = oxyjwt.encode(payload, secret, algorithm="HS256", headers={"kid": "key-2026"})
# Decode and validate claims
claims = oxyjwt.decode(
token,
secret,
algorithms=["HS256"], # Fixed allow-list is required
audience="https://api.example.com",
issuer="https://auth.example.com",
)
print(claims["sub"]) # "user_42"
2. Asymmetric Keys (RSA, ECDSA, EdDSA)
For asymmetric cryptography, parse keys once using explicit constructors:
import oxyjwt
# Load keys
signing_key = oxyjwt.EncodingKey.from_rsa_pem(private_pem_bytes)
verifying_key = oxyjwt.DecodingKey.from_rsa_pem(public_pem_bytes)
# Sign with RS256
token = oxyjwt.encode({"sub": "user_42"}, signing_key, algorithm="RS256")
# Verify with RS256
claims = oxyjwt.decode(token, verifying_key, algorithms=["RS256"])
OxyJWT also supports Ed25519 (EdDSA):
signing_key = oxyjwt.EncodingKey.from_ed_pem(ed25519_private_pem)
verifying_key = oxyjwt.DecodingKey.from_ed_pem(ed25519_public_pem)
token = oxyjwt.encode({"sub": "service-worker"}, signing_key, algorithm="EdDSA")
claims = oxyjwt.decode(token, verifying_key, algorithms=["EdDSA"])
3. JWKS Client Integration
Fetch and cache remote JSON Web Key Sets (e.g., Auth0, Keycloak, Cognito, Okta) seamlessly:
from oxyjwt import PyJWKClient
import oxyjwt
jwks_client = PyJWKClient(
"https://your-domain.auth0.com/.well-known/jwks.json",
cache_keys=True,
max_cached_keys=16,
cache_jwk_set=True,
lifespan=3600, # 1 hour cache
)
# Automatically resolve the signing key using the token's header `kid`
signing_key = jwks_client.get_signing_key_from_jwt(token)
claims = oxyjwt.decode(
token,
signing_key.key,
algorithms=["RS256"],
audience="https://api.example.com",
)
4. Complete Inspection & Fast Path
import oxyjwt
# Inspect headers without verifying signature (debugging only)
header = oxyjwt.get_unverified_header(token)
# Retrieve header, claims payload, and raw signature together
token_data = oxyjwt.decode_complete(token, key, algorithms=["HS256"])
print(token_data["header"])
print(token_data["payload"])
print(token_data["signature"])
🛡️ Exception Hierarchy
OxyJWT provides a predictable exception tree that mirrors PyJWT for easy catch blocks:
import oxyjwt
try:
claims = oxyjwt.decode(token, key, algorithms=["HS256"])
except oxyjwt.ExpiredSignatureError:
# Token has expired (exp claim)
...
except oxyjwt.ImmatureSignatureError:
# Token is not yet valid (nbf claim)
...
except oxyjwt.InvalidAudienceError:
# Audience claim mismatch (aud claim)
...
except oxyjwt.InvalidIssuerError:
# Issuer mismatch (iss claim)
...
except oxyjwt.InvalidSignatureError:
# Signature verification failed
...
except oxyjwt.InvalidTokenError:
# Malformed token or general decoding error
...
except oxyjwt.OxyJWTError:
# Base class for all OxyJWT exceptions
...
🔒 Supported Algorithms
| Family | Algorithms | Key Type |
|---|---|---|
| HMAC | HS256, HS384, HS512 |
str or bytes (shared secret) |
| RSA | RS256, RS384, RS512 |
EncodingKey.from_rsa_pem / DecodingKey.from_rsa_pem |
| RSA-PSS | PS256, PS384, PS512 |
EncodingKey.from_rsa_pem / DecodingKey.from_rsa_pem |
| ECDSA | ES256, ES384 |
EncodingKey.from_ec_pem / DecodingKey.from_ec_pem |
| EdDSA | EdDSA (Ed25519) |
EncodingKey.from_ed_pem / DecodingKey.from_ed_pem |
🛡️ Security by Default
- Fixed Algorithm Allow-List: Passing an
algorithmsparameter todecodeis mandatory when signature verification is active. - No
alg: "none": Unsigned tokens are fundamentally disallowed. - Constant-Time Verification: Cryptographic comparisons are protected against timing attacks.
- Hardened JWKS Client: Protects against SSRF, limits downloaded key sizes, and enforces key rate-limiting.
- No Key Confusion: Asymmetric algorithms require explicit typed
EncodingKey/DecodingKeystructures to prevent HMAC key confusion attacks.
📖 Documentation & Local Development
Full documentation is available at oxyjwt.queryahub.com.
Local Setup & Testing
# Clone and setup environment
git clone https://github.com/QueryaHub/OxyJWT.git
cd OxyJWT
python -m venv .venv
source .venv/bin/activate
# Install build & test dependencies
pip install -U pip maturin pytest pytest-cov cryptography pyjwt authlib python-jose
# Compile Rust extension and run tests
maturin develop --release
pytest
# Run extended performance benchmarks
OXYJWT_BENCHMARK=1 pytest tests/test_benchmark_jwt_libraries.py -v
Documentation Preview
pip install -r docs-site/requirements.txt
mkdocs serve -f docs-site/mkdocs.yml
🤝 Contributing & Security
- Contributions are welcome! Please read our CONTRIBUTING.md for development guidelines and code standards.
- To report security vulnerabilities, please refer to SECURITY.md.
📄 License
This project is licensed under the MIT License.
Metadata
Release files for oxyjwt 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| oxyjwt-0.8.0.tar.gz | 43.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| oxyjwt-0.8.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| oxyjwt-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| oxyjwt-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| oxyjwt-0.8.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| oxyjwt-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 5.9 MB
Release files / oxyjwt-0.8.0.tar.gz
| Download URL | oxyjwt-0.8.0.tar.gz |
|---|---|
| Size | 43.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2475e9a7d4ad4743664b61d0b04e72d42b74dbffa80bfffcddd86cf5ad11baff
|
|
BLAKE2b-256 checksum How to use checksums |
4f49bc15500df669b84a8e5a0b01f26c9551b287dbbc31e0bc48a5bcedc49781
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / oxyjwt-0.8.0-cp310-abi3-win_amd64.whl
| Download URL | oxyjwt-0.8.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
075ba4e7c3c41860b616f8dda642cd0baa5e1fda11c7788ebe5b2c63828742ef
|
|
BLAKE2b-256 checksum How to use checksums |
feabc483c72d9bbfe2df001e8ac084ce9f64efbe2ab1db2565d87fac962a0a23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / oxyjwt-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | oxyjwt-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ca710b626920ea7aa1cd7c5b5a762dbe1c2dcc56e26b45fb53ba5afb75528de7
|
|
BLAKE2b-256 checksum How to use checksums |
b7094fc7115a11f23fe61f80feedcc024218ebe4989c73f24978c233fe8afee9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / oxyjwt-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | oxyjwt-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 674.4 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
261c8e70c2c8ecf2ecf4feaf6d183e8b6b5273076f5edbb241da5d6445be41c0
|
|
BLAKE2b-256 checksum How to use checksums |
0fc7298034750718bb9fc84fcf8b72efcd34e908054c8cbdafbfe1b8bd330e6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / oxyjwt-0.8.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | oxyjwt-0.8.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ba84f9c9604c9e380208b3a83f77664e36a788ed76df12f83a33c43a6692c58c
|
|
BLAKE2b-256 checksum How to use checksums |
8a2ffb2a7b161d72c78ea86c39f5ab27dff1155e3dfec854c86ab8bb932f98f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency logRelease files / oxyjwt-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | oxyjwt-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
07203a265a7e7ffdc9bb923e3d6b8187e6c5ed314d6e665eefa8f8f8cc56eea3
|
|
BLAKE2b-256 checksum How to use checksums |
1e8ddc982e7d634c92c2830f4511d8291957e80b04d2eaf73442ca90374148fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.
Transparency log