AuthX
Ready-to-use and customizable Authentications and Oauth2 management for FastAPI ⚡
| Project | Status |
|---|---|
| CI | |
| Meta |
Source Code: https://github.com/yezz123/authx
Documentation: https://authx.yezz.me/
Add a fully featured authentication and authorization system to your FastAPI project. AuthX is designed to be simple, customizable, and secure.
Installation
pip install authx
Quick Start
from fastapi import FastAPI, Depends, HTTPException
from authx import AuthX, AuthXConfig
app = FastAPI()
config = AuthXConfig(
JWT_SECRET_KEY="your-secret-key", # Change this!
JWT_TOKEN_LOCATION=["headers"],
)
auth = AuthX(config=config)
auth.handle_errors(app)
@app.post("/login")
def login(username: str, password: str):
if username == "test" and password == "test":
token = auth.create_access_token(uid=username)
return {"access_token": token}
raise HTTPException(401, detail="Invalid credentials")
@app.get("/protected", dependencies=[Depends(auth.access_token_required)])
def protected():
return {"message": "Hello World"}
Test it:
# Get a token
curl -X POST "http://localhost:8000/login?username=test&password=test"
# Access protected route
curl -H "Authorization: Bearer <your-token>" http://localhost:8000/protected
Features
- Support for Python 3.9+ and Pydantic 2
- JWT authentication with multiple token locations:
- Headers (Bearer token)
- Cookies (with CSRF protection)
- Query parameters
- JSON body
- Access and refresh token support
- Token freshness for sensitive operations
- Token blocklist/revocation
- Built-in
AuthManagerfor isolated multi-login-type applications - Pluggable policy engine for scopes, attributes, environment checks, and custom evaluators
- Extensible error handling
Extra Features
Install authx-extra for additional features:
pip install authx-extra
- Redis session store and cache
- HTTP caching
- Performance profiling with pyinstrument
- Prometheus metrics
Note: Check Release Notes.
Contributors and Sponsors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
License
This project is licensed under the terms of the MIT License.
Metadata
Release files for authx 1.7.1
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 |
|---|---|---|---|---|
| authx-1.7.1.tar.gz | 96.8 kB | With provenance | Details for authx-1.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| authx-1.7.1-py3-none-any.whl | Python 3 | none | any | Details for authx-1.7.1-py3-none-any.whl |
Total release size: 141.3 kB
Release files / authx-1.7.1.tar.gz
| Download URL | authx-1.7.1.tar.gz |
|---|---|
| Size | 96.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b52c75096b9459be91058720833d09886a58b2b7d87f85624e1fef7ae358686
|
|
BLAKE2b-256 checksum How to use checksums |
48def8dbcc5dae9c9be4f6145a3ff69250b2540c2c55e360cb48e28bf47cebc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 27, 2026.
Transparency logRelease files / authx-1.7.1-py3-none-any.whl
| Download URL | authx-1.7.1-py3-none-any.whl |
|---|---|
| Size | 44.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d28896ff78865d724eef21a704b2cfa28da5beaf411c6e3893fac35f1df4a26b
|
|
BLAKE2b-256 checksum How to use checksums |
7ee8bc92951b01e0ccf3e3c447bc274f19725a3bc4042fdd87ce515a8841d71f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 27, 2026.
Transparency logSecurity for authx 1.7.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for authx-1.7.1.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 Jun 27, 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.