This release is a pre-release and may not be stable for production use.
axioms-core-py
Core JWT authentication and authorization library for Python web frameworks.
Overview
axioms-core-py provides framework-agnostic JWT token validation, JWKS management with background refresh, and claim-based authorization. This is the foundation for framework-specific integrations:
- axioms-flask-py - Flask integration
- axioms-fastapi - FastAPI integration
- axioms-drf-py - Django REST Framework integration
Note: For most use cases, use one of the framework integrations above instead of using this package directly.
Supports
- JWT token validation with automatic JWKS retrieval
- Background JWKS refresh with thread-safe caching
- Algorithm validation (only secure asymmetric algorithms allowed)
- Token type validation (typ header)
- Issuer validation (iss claim)
- Claim-based authorization (scopes, roles, permissions)
- Custom claim name support for different authorization servers
- Comprehensive logging with JWT ID (jti) tracking
Prerequisite
- Python 3.10+
Installation
pip install axioms-core-py
Quick Start
Configuration
from axioms_core import AxiomsConfig
config = AxiomsConfig(
AXIOMS_AUDIENCE="your-api-audience",
AXIOMS_ISS_URL="https://auth.example.com", # Recommended
# Or use AXIOMS_DOMAIN for simpler setup:
# AXIOMS_DOMAIN="auth.example.com",
)
Initialize JWKS Manager (Optional)
For production, initialize at startup to enable background refresh:
from axioms_core import initialize_jwks_manager, shutdown_jwks_manager
# At startup
initialize_jwks_manager(
config=config,
refresh_interval=3600, # Refresh every hour
cache_ttl=7200, # Cache for 2 hours
prefetch=True # Fetch JWKS immediately
)
# At shutdown (optional - auto-cleanup on exit)
shutdown_jwks_manager()
Token Validation
from axioms_core import get_key_from_jwks_json, check_token_validity
import jwt
# Extract token header
header = jwt.get_unverified_header(token)
kid = header.get("kid")
alg = header.get("alg")
# Get public key from JWKS
key = get_key_from_jwks_json(kid, config)
# Validate token
payload = check_token_validity(
token=token,
key=key,
alg=alg,
audience=config.AXIOMS_AUDIENCE,
issuer=config.AXIOMS_ISS_URL,
)
if payload:
print(f"Valid token for user: {payload.sub}")
Authorization Checks
from axioms_core import check_scopes, check_roles, check_permissions
# Check scopes (space-separated or list)
has_scope = check_scopes(payload.scope, ["read:data"])
# Check roles (list)
has_role = check_roles(payload.roles, ["admin"])
# Check permissions (list)
has_perm = check_permissions(payload.permissions, ["users:read"])
Configuration Options
See AxiomsConfig class for all options:
config = AxiomsConfig(
# Required
AXIOMS_AUDIENCE="your-api-audience",
# Recommended (choose one)
AXIOMS_ISS_URL="https://auth.example.com",
# AXIOMS_DOMAIN="auth.example.com",
# AXIOMS_JWKS_URL="https://auth.example.com/.well-known/jwks.json",
# Optional
AXIOMS_TOKEN_TYPS=["JWT", "at+jwt"], # Allowed token types
AXIOMS_SAFE_METHODS=["OPTIONS"], # HTTP methods to bypass auth
# JWKS settings
AXIOMS_JWKS_REFRESH_INTERVAL=3600, # 1 hour
AXIOMS_JWKS_CACHE_TTL=7200, # 2 hours
AXIOMS_JWKS_PREFETCH=True,
# Custom claim names (for different auth servers)
AXIOMS_SCOPE_CLAIMS=["scope", "scp"],
AXIOMS_ROLES_CLAIMS=["roles", "cognito:groups"],
AXIOMS_PERMISSIONS_CLAIMS=["permissions"],
)
Configuration Hierarchy
AXIOMS_ISS_URL→ constructs →AXIOMS_JWKS_URL(if not set)AXIOMS_DOMAIN→ constructs →AXIOMS_ISS_URL→AXIOMS_JWKS_URL(if not set)
Security
- Allowed algorithms: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512
- Token type validation: Validates
typheader against allowed types - Issuer validation: Validates
issclaim to prevent token substitution - Expiration validation: Validates
expclaim exists and is valid - Comprehensive logging: All validation failures logged with jti (if available)
License
MIT License - see LICENSE file for details.
Metadata
Release files for axioms-core-py 0.0.5rc41792462079
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| axioms_core_py-0.0.5rc41792462079.tar.gz | 35.5 kB | With provenance | Details for axioms_core_py-0.0.5rc41792462079.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| axioms_core_py-0.0.5rc41792462079-py3-none-any.whl | Python 3 | none | any | Details for axioms_core_py-0.0.5rc41792462079-py3-none-any.whl |
Total release size: 53.8 kB
Release files / axioms_core_py-0.0.5rc41792462079.tar.gz
| Download URL | axioms_core_py-0.0.5rc41792462079.tar.gz |
|---|---|
| Size | 35.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bfe986b15c590f44812f118ffd7f68ded244ba7cfde0c01342d5a1a981bff86
|
|
BLAKE2b-256 checksum How to use checksums |
ee4f7b84ed7c08038c0ee291a104194c569b96e10113212ae4e750bde97a77d7
|
| 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 Oct 20, 2026.
Transparency logRelease files / axioms_core_py-0.0.5rc41792462079-py3-none-any.whl
| Download URL | axioms_core_py-0.0.5rc41792462079-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d2282ffc0254fa96eba34c8f4c17f2eebb236aeb7054c66df818adaf4aee67d
|
|
BLAKE2b-256 checksum How to use checksums |
1494b7d2564d36b942d67c336df400d04b0980e6679426c2ef23031a7fc357c9
|
| 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 Oct 20, 2026.
Transparency logSecurity for axioms-core-py 0.0.5rc41792462079
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for axioms_core_py-0.0.5rc41792462079.tar.gz
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 Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.