Skip to main content

Stop fighting auth in FastAPI: JWT access/refresh, DB-backed blacklist & rotation, cookie or Bearer modes.

Project description

CACL logo

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
  • Authorization: Bearer tokens 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[postgres]

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: cacl/
  • Demo FastAPI application: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacl-0.1.3.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cacl-0.1.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file cacl-0.1.3.tar.gz.

File metadata

  • Download URL: cacl-0.1.3.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cacl-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1c5357141a9d6cd4d4707fcc295a39398bceed9df6b66e44df27e3a4c543fece
MD5 20f8084769f5c7fd94ceb209a3f84af2
BLAKE2b-256 b2d060b5e028948a4f6989d1ab157e34e4c4cd33fa1f9a31c434fc1e2f70008b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cacl-0.1.3.tar.gz:

Publisher: publish.yml on CACL-project/CACL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cacl-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cacl-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cacl-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 526bfed728d0bab902c710a5737b15b6b5b762c4f22a581c8e124689f30fc406
MD5 18dbd95f65175f4145d7dc4039994e3d
BLAKE2b-256 8d46562a23afd129602e7217c01cd4fdaa6c83fea5c2b6f5e01f22a60bbf5188

See more details on using hashes here.

Provenance

The following attestation bundles were made for cacl-0.1.3-py3-none-any.whl:

Publisher: publish.yml on CACL-project/CACL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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