Documentation · Source code on GitHub

The problem

Authentication is easier to integrate than to understand. A login cookie, an OAuth2 access token and an OpenID Connect ID token serve different purposes. Account changes also need to affect sessions and previously issued credentials consistently.

ZeroAuthLite gives Python developers a runnable reference for exploring those relationships. Its documented scope includes learning, prototypes and internal applications on one node, with readable code that can be tested and adapted.

The solution

The server combines identity management with browser authentication and a defined subset of OAuth2 and OpenID Connect. Registration, invitations, email verification, password reset and account administration sit alongside organization roles and permissions.

Browser applications can use server-side sessions. OAuth2 clients can use authorization code with mandatory PKCE S256, client credentials, device authorization and refresh tokens. OIDC adds signed ID tokens, discovery, JWKS and UserInfo. Revocation and introspection expose token lifecycle operations. These flows are implemented, rather than merely listed as extension ideas.

Architecture and operation

A single FastAPI application composes modules for identity, passwords, browser sessions, OAuth2 and OIDC. SQLAlchemy persists identity, session and token state in SQLite; Alembic manages schema migrations. Application JSON routes live under /api/v1, while protocol endpoints use /oauth2 and issuer-derived discovery paths.

In a browser authorization flow, the user signs in, the server validates the client’s request and obtains consent when required, then returns a short-lived authorization code. The client exchanges it with its PKCE verifier. When the granted scope includes openid, the response also contains an ID token. Machine clients use client credentials without impersonating a user; device clients obtain approval through a separate browser.

Cookie-authenticated mutations receive CSRF checks. Bearer authentication verifies both the signed token and persisted session, client and identity state. Refresh tokens rotate, and detected reuse revokes the associated token family. Security-sensitive account changes can revoke browser and OAuth2 sessions in the same database transaction.

Authentication emails use a durable outbox: the identity transaction records a delivery intention, and a separate worker sends it through SMTP. Session and OAuth2 cleanup also run as explicit side processes.

Technical choices

Readable composition. Feature modules keep behavior and persistence close together, with top-level composition in one application factory. Optional Jinja forms, HTMX-enhanced management pages and JSON adapters use the same services. This makes it possible to study a flow without introducing another application framework.

SQLite as an explicit boundary. SQLAlchemy provides composable queries and transactions, not a promise of database portability. SQLite is the only supported database. Short write transactions matter because writes serialize; adding web processes does not remove that constraint.

Transactional identity and token state. Persisting session authority allows immediate server-side revocation checks. The outbox separates database commits from mail delivery, at the cost of operating a worker. Ed25519 signing and JWKS provide public verification keys; operators still manage private keys and rotation.

Current state and limitations

The initial scope is considered complete on this portfolio. The repository nevertheless describes functional, early-development software with unstable APIs, configuration and schema. Completion therefore describes the project’s scope, not compatibility or deployment guarantees.

Behavioral tests cover authentication, account lifecycle, grants, discovery and protocol errors. They do not constitute an independent security audit or OAuth2/OIDC certification.

The supported deployment model is a single node without high availability. HTTPS, trusted proxy settings, backups and request rate limiting remain deployment responsibilities; no request limiter is built in. SAML, SCIM, LDAP, social login and identity-provider federation are outside scope, as are OAuth2 implicit and password grants.

Resources

Continue with the OAuth2 flow guide and the deployment security guidance. They explain integration behavior and the controls an operator must supply.