Skip to main content

warden

Identity and audit for Python web applications: users, sign-in, invitations, OpenID Connect single sign-on, roles and permissions, API keys, and a tamper-evident audit trail with syslog forwarding.

Status: 0.2.0. The sign-in standard: four sign-in methods with an instance default and per-user overrides, a second factor always required for a password sign-in, the allowed second factors, set-up guides for single sign-on, and routes for all of it. Upgrading from 0.1.x needs a configuration change first. Before 1.0 a minor version may break the public API, and every break is named in the changelog with an upgrade note.

warden is built by Cognisn as the shared identity and audit foundation for its products. It is an embedded library, not a service: an application installs it, passes in its database connection pool and configuration, and mounts warden's FastAPI routers wherever it chooses. warden has no user interface; each application builds its own screens against warden's documented HTTP contract.

What it provides

Identity

  • User lifecycle: invite, activate, suspend and deactivate.
  • Four sign-in methods (password, password_and_sso, sso_only, passkey_only), an instance default and an override for each user. A change a user cannot make yet is pending until they hold the credential, with a set-up link mailed, resent or cancelled by an administrator, and single sign-on cannot be turned off while anyone needs it.
  • Password sign-in with Argon2id hashing, and a second factor always required: an authenticator app (TOTP), a security key or a passkey, as the administrator allows, with recovery codes the user can replace.
  • Administration and self-service routes over all of it: the instance sign-in settings, a user's method and pending change, the signed-in user's own method, and the session policy, each audited with the client address.
  • Password policies chosen by role or pinned per user: length, character class and passphrase rules, change-period tiers, history and a minimum age; watch lists of passwords that must not be used (a built-in common-password list, local lists, Have I Been Pwned imports and an optional range lookup), an optional recheck of passwords in use, and a forced change after sign-in when a password is expired or listed.
  • Live password feedback: a policy description a browser can evaluate, the evaluator itself shipped in the package as one script, a check route for each place a password is set, and a file of rule test cases that proves a client agrees with the server.
  • Passkeys and security keys (WebAuthn): as a second factor beside TOTP, or a passkey on its own, with a passkey_only sign-in method, an emailed registration link and passkey invitations.
  • Invitations and password reset by single-use, expiring emailed links.
  • OpenID Connect single sign-on: authorisation code with PKCE, pre-provisioned accounts only, numbered set-up steps for Microsoft Entra ID, Google, Okta and any other provider, and local password sign-in kept as the break-glass path.
  • Access tokens and rotating refresh tokens, with reuse detection and an absolute session lifespan.
  • API keys scoped to a subset of permissions.
  • Roles defined by the application as named sets of its own permissions, with FastAPI dependencies to enforce them.

Audit

  • One recording funnel for warden's own events and the application's.
  • A hash-chained, append-only audit trail, with a verification command.
  • Forwarding to a syslog collector (RFC 5424 over UDP, TCP or TLS) that never slows a request.
  • Filtering and export to CSV or NDJSON.
  • Configurable retention, with signed checkpoints that keep the chain verifiable across purges.
  • Signed anchors of the chain's head, which a SIEM keeps and verification checks the database against.

The audit half works on its own, so an application with its own authentication can still use it.

Requirements

  • Python 3.12 or later.
  • PostgreSQL. warden keeps its tables in a dedicated warden schema with its own migration history.
  • FastAPI and psycopg 3, installed with warden.
  • cognisn-konfig for configuration and secrets, installed with warden.

psycopg needs the PostgreSQL client library, libpq. Install the binary build alongside warden (psycopg[binary]) or provide a system libpq.

Installation

pip install cognisn-warden "psycopg[binary]"

The import name is warden. A pre-release, such as 0.1.0rc1, needs pip install --pre cognisn-warden or the exact version.

An application loads its WardenConfig through konfig, runs warden migrate against its database, passes warden its connection pool, and mounts warden's routers under prefixes it chooses. The client-behaviour guide describes what a client of those routes must do, and the HTTP contract documents every route.

Documentation

Sample console

examples/console is a small sample product that mounts warden's routers in FastAPI and exercises them from a plain HTML and JavaScript console: sign-in with a second factor, single sign-on with its set-up steps, the sign-in settings and each user's method, invitations and password reset (with an in-memory outbox), administration, API keys, and the audit trail with export, verification, anchors and syslog. It shows how a product integrates warden, using only warden's public surface. It is for local development only, not a deployment template, and it is not part of the published package.

Licence

Licensed under the Apache License, Version 2.0. Copyright 2026 Cognisn Pty Ltd. See NOTICE.

Metadata

Release files for cognisn-warden 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cognisn-warden 0.2.0
File Size Uploaded Provenance Actions
cognisn_warden-0.2.0.tar.gz 2.7 MB With provenance Details for cognisn_warden-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cognisn-warden 0.2.0
File Interpreter ABI Platform Actions
cognisn_warden-0.2.0-py3-none-any.whl Python 3 none any Details for cognisn_warden-0.2.0-py3-none-any.whl

Total release size: 5.1 MB

Release files / cognisn_warden-0.2.0.tar.gz

Download URL cognisn_warden-0.2.0.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
78b0384342497271fc8073964fd5450ea5bae1b06691dfa101015b4d95b02846
BLAKE2b-256 checksum
How to use checksums
fc44a2438c9787379524ae3674e3b3288c4e763a5647a4a60376a943a1214670
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Release files / cognisn_warden-0.2.0-py3-none-any.whl

Download URL cognisn_warden-0.2.0-py3-none-any.whl
Size 2.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
02422d74ff64e274e5c3f6d5ffa784bd3448a9c28e7d1a3d823a8ddf2aaff78b
BLAKE2b-256 checksum
How to use checksums
fd5ba3e553b035e6f577c1b158d0ea9ebaa82302223d616b0dea4d27b5f582c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Security for cognisn-warden 0.2.0

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.

Select from 2 files

Attestation for cognisn_warden-0.2.0.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 Nov 24, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page