Skip to main content

fastjwt

Supported Python Version Package Version Licence Documentation

Build Status Test Status Publish Status Documentation Status

Coverage Tests Docstring Flake8

Issues Pull Requests Repo Size Downloads

Stars Forks Watchers

FastJWT is a FastAPI Plugin for reusable JWT Authentication Management. fastjwt enables easy JSON Web Tokens management within your FastAPI application.

fastjwt is heavily inspired from its Flask equivalent Flask-JWT-Extended, special thanks to @vimalloc fot the amazing work.

Documentation: https://ocarinow.github.io/fastjwt/

Features

  • Encode/Decode JWT for application Authentication
  • Automatic JWT detection in request
    • JWT in Headers
    • JWT in Cookies
    • JWT in Query strings
    • JWT in JSON Body
  • Implicit/Explicit token refresh mechanism
  • Freshness state of token
  • Route protection
    • Token type based protection (access/refresh)
    • Token freshness protection
    • Partial route protection
  • Handle custom user logic for revoked token validation
  • Handle custom logic for token recipient retrieval (ORM, pydantic serialization...)
  • Provide FastAPI compliant dependency injection API
  • Automatic error handling
  • Scope Management (WIP)

Setup

Requirements

FastJWT is built on top of the following dependencies:

  • FastAPI as web framework
  • Pydantic as data validation
  • PyJWT as python implementation of the JSON Web Token standard

FastJWT also relies on typing-extensions for backward compatibility (python3.9)

Note

FastAPI, while required for fastjwt, is not declared as a dependency and must be installed prior with pip install fastapi

Install

# With pip
pip install fastjwt
# With poetry
poetry add fastjwt
# With pipenv
pipenv install fastjwt

Example

from fastapi import FastAPI, Depends
from fastjwt import FastJWT

app = FastAPI()
security = FastJWT()

@app.get('/login')
def login():
    return security.create_access_token(uid='foo')

@app.get('/protected', dependencies=[Depends(security.access_token_required())])
def protected():
    return "This is a protected endpoint"

Development

WORK IN PROGRESS

The development guide is not available yet

Contributing

WORK IN PROGRESS

The contribution guide is not available yet

License

This project is open source under MIT License

Metadata

Release files for fastjwt 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastjwt 0.4.1
File Size Uploaded Provenance Actions
fastjwt-0.4.1.tar.gz 19.9 kB Without provenance Details for fastjwt-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastjwt 0.4.1
File Interpreter ABI Platform Actions
fastjwt-0.4.1-py3-none-any.whl Python 3 none any Details for fastjwt-0.4.1-py3-none-any.whl

Total release size: 42.5 kB

Release files / fastjwt-0.4.1.tar.gz

Download URL fastjwt-0.4.1.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
032b644bb3df8b012ccc6b20284989752e866525a9a5bafa49d93c55abf7ee9e
BLAKE2b-256 checksum
How to use checksums
373e4ca625d601b168b4c87553455afd74d520f2777a41a7b5fa7950ef6180bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.8 Linux/6.5.0-1015-azure

Release files / fastjwt-0.4.1-py3-none-any.whl

Download URL fastjwt-0.4.1-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71d0277bc63458b869cc93e38f0e10a8d1b998501ed8cb6875634344cb5ab1bb
BLAKE2b-256 checksum
How to use checksums
e4769d81fcfbcfaebed16081582ca197f3c93139b1486070bb68a076566c9eec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.8 Linux/6.5.0-1015-azure

Security for fastjwt 0.4.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page