Skip to main content

FastAPI Plugin for reusable JWT Authentication Management

Project description

fastjwt

Python Version Latest Version Licence Documentation

Build Status Test Status Publish Status

Coverage Docstring Flake8 Tests

Commit Activity Repo Size Issues Pull Requests Downloads

Stars Forks Watchers

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

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

Features

  • Handles request for JWT in Cookies, Headers, Query Parameters and request Body
  • Handles Token Blocklist via custom callbacks
  • Handles User ORM via custom callbacks
  • Protected routes
  • Protected routes with fresh token/login
  • Implicit/Explicit Token Refresh mechanisms
  • Partially protected routes

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)

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

WORK IN PROGRESS

The license is not available yet (open source MIT considered)

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

fastjwt-0.2.1.tar.gz (14.9 kB view hashes)

Uploaded Source

Built Distribution

fastjwt-0.2.1-py3-none-any.whl (16.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page