Stop fighting auth in FastAPI: JWT access/refresh, DB-backed blacklist & rotation, cookie or Bearer modes.
Project description
CACL — Clear Authentication Control Library
Stop fighting authentication in FastAPI.
Controlled JWT auth with database-backed tokens, blacklist, and rotation.
What is CACL?
CACL is a production-grade authentication library for FastAPI.
It provides explicit, database-backed control over JWT authentication:
- access & refresh tokens
- forced token invalidation (blacklist)
- refresh token rotation
- cookie or Bearer header modes — switched by a single flag
No hidden state.
No opinionated framework behavior.
No surprises in production.
You own the database and transactions — CACL handles token mechanics.
Cookie or Bearer — without the headache
CACL supports both browser and API authentication flows:
- Cookie-based auth for web applications
- Bearer tokens via
Authorizationheader for APIs and services
Switching between them requires changing a single configuration flag.
No duplicated logic.
No conditional dependencies in routes.
No separate auth implementations to maintain.
Why CACL exists
Most JWT libraries treat tokens as stateless forever.
That approach breaks down the moment you need:
- real logout
- forced session invalidation
- compromised token handling
- refresh token reuse protection
CACL treats tokens as controlled entities stored in your database.
This allows you to:
- revoke tokens instantly
- track token lifecycle
- enforce refresh rotation
- audit authentication behavior
This is how authentication works in real production systems.
Authentication philosophy
CACL follows a simple principle:
Authentication must be explicit, inspectable, and revocable.
Stateless JWTs optimize for simplicity, not for control.
CACL optimizes for operational clarity.
The library intentionally:
- does not create database engines
- does not manage transactions
- does not hide side effects
Your application owns the session lifecycle.
CACL integrates into it — cleanly and predictably.
Core principles
- Library, not framework — no imposed app structure
- Database-backed — tokens are real records
- Explicit ownership — you control commits and rollbacks
- FastAPI-native — async, dependencies, SQLAlchemy 2.x
Installation
pip install cacl
Minimal mental model
Your application:
- creates DB engine
- manages transactions
- verifies user credentials
CACL:
- creates JWT tokens
- verifies JWT tokens
- blacklists tokens
- enforces authentication rules
Documentation & demo
- Library documentation: packages/cacl/cacl/
- Demo FastAPI application: examples/demo_app/
- Design notes, testing, and verification docs are included in the repository
When should you use CACL?
Use CACL if you need:
- real logout (not "just delete the cookie")
- forced token invalidation
- refresh token rotation without hacks
- clear and auditable auth boundaries
If you want "just slap JWT and forget about it" — this library is intentionally not for you.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cacl-0.2.0.tar.gz.
File metadata
- Download URL: cacl-0.2.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8603c211db95d2e636d1d071e1ba1ab827ce5d1c0c52c7be0c954ab4ee2fc4d5
|
|
| MD5 |
564202c6124ad9cc24a81ce483b3cfe7
|
|
| BLAKE2b-256 |
f642a432e25565ad5ff261bab94eea6ce4901eadbcc5a81e07c07cd69bbe908e
|
Provenance
The following attestation bundles were made for cacl-0.2.0.tar.gz:
Publisher:
publish.yml on CACL-project/CACL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cacl-0.2.0.tar.gz -
Subject digest:
8603c211db95d2e636d1d071e1ba1ab827ce5d1c0c52c7be0c954ab4ee2fc4d5 - Sigstore transparency entry: 1073176862
- Sigstore integration time:
-
Permalink:
CACL-project/CACL@a366b76de871b4c7d3049759e1c097c61ad113cd -
Branch / Tag:
refs/tags/v.0.2.0 - Owner: https://github.com/CACL-project
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a366b76de871b4c7d3049759e1c097c61ad113cd -
Trigger Event:
release
-
Statement type:
File details
Details for the file cacl-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cacl-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9323d7540a98402e4c4f39ebc8f2b76f8483e21d15ed473799faf29f885fd183
|
|
| MD5 |
34da172433a2240c8acdf7f224ae9a3c
|
|
| BLAKE2b-256 |
ee471161547162d405ed5391a555effdd75ca88a740eea204963cd7e3e4d9e57
|
Provenance
The following attestation bundles were made for cacl-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on CACL-project/CACL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cacl-0.2.0-py3-none-any.whl -
Subject digest:
9323d7540a98402e4c4f39ebc8f2b76f8483e21d15ed473799faf29f885fd183 - Sigstore transparency entry: 1073176977
- Sigstore integration time:
-
Permalink:
CACL-project/CACL@a366b76de871b4c7d3049759e1c097c61ad113cd -
Branch / Tag:
refs/tags/v.0.2.0 - Owner: https://github.com/CACL-project
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a366b76de871b4c7d3049759e1c097c61ad113cd -
Trigger Event:
release
-
Statement type: