Registry / web-framework / fastapi-jwt-auth

fastapi-jwt-auth

JSON →
library0.5.0pypypiunverified

FastAPI extension that provides JWT Auth support. Current version is 0.5.0, release cadence is irregular. It supports access/refresh tokens, token freshness, denylist/revocation, WebSocket authorization, and configurable JWT claims.

pip install fastapi-jwt-auth
INSTALL
IMPORT
SIG · FASTAPI-JWT-AUTH
F
fastapi-jwt-auth
web-frameworkpythonv0.5.0
Install
3.8s avg
Import
—
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 32.2MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.8s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthJWT
✓ from fastapi_jwt_auth import AuthJWT
✗ from fastapi_jwt_auth.auth import AuthJWT
AuthJWT is exported at package level, not from submodule
AuthJWTBearer
✓ from fastapi_jwt_auth import AuthJWTBearer
✗ from fastapi_jwt_auth.bearer import AuthJWTBearer
AuthJWTBearer is exported from package, not from bearer submodule

Minimal FastAPI app with JWT authentication using fastapi-jwt-auth.

from fastapi import FastAPI, Depends from fastapi_jwt_auth import AuthJWT from pydantic import BaseModel app = FastAPI() class Settings(BaseModel): authjwt_secret_key: str = "secret" @AuthJWT.load_config def get_config(): return Settings() @app.post("/login") def login(auth: AuthJWT = Depends()): access_token = auth.create_access_token(subject="test") return {"access_token": access_token} @app.get("/protected") def protected(auth: AuthJWT = Depends()): auth.jwt_required() current_user = auth.get_jwt_subject() return {"user": current_user}
Debug
Known issues
breakingIn v0.3.0, `get_jwt_identity()` was renamed to `get_jwt_subject()`. The old name no longer works.
fix
Use `get_jwt_subject()` instead of `get_jwt_identity()`.
affects: >=0.3.0
breakingIn v0.3.0, `load_end()` was renamed to `load_config()`. The old name no longer works.
fix
Use `@AuthJWT.load_config` decorator instead of `@AuthJWT.load_end`.
affects: >=0.3.0
breakingIn v0.3.0, `blacklist` was renamed to `denylist`. All functions and configuration referring to 'blacklist' are deprecated and removed.
fix
Replace any 'blacklist' references with 'denylist' (e.g., `denylist_enabled`, `denylist_token_verifier`).
affects: >=0.3.0
gotchaThe `create_access_token` and `get_jti` functions must be called from inside a FastAPI endpoint with the AuthJWT dependency injected. They cannot be imported and called standalone.
fix
Always use `Depends()` to inject AuthJWT into your route handler.
affects: >=0.2.0
gotchaEnvironment variable support was deprecated in v0.3.0. Loading settings via environment variables directly is no longer supported; use a Pydantic model with `@AuthJWT.load_config`.
fix
Define a Pydantic BaseModel with your settings and decorate it with `@AuthJWT.load_config`.
affects: >=0.3.0,<0.4.0 (deprecated) or >=0.4.0 (removed)
Upgrade
Version history
0.5.0latest on PyPI · released Nov 6, 2020
Audit
Dependencies
fastapirequiredCore dependency, as this is a FastAPI extension
pydanticrequiredUsed for configuration settings
PyJWTrequiredJWT encoding/decoding
Agent activity
35 hits · last 30 days
node
30
Amazon
2
OpenAI (training)
1
Resources
fastapi-jwt-auth — pip install fastapi-jwt-auth · libregistry