Skip to main content

Identity primitives for Flametrench: users, credentials (Argon2id-pinned passwords, passkeys, OIDC), and user-bound sessions with rotation on refresh.

Project description

flametrench-identity

CI

Python SDK for the Flametrench identity specification: users, credentials (Argon2id-pinned passwords, passkeys, OIDC), user-bound sessions with rotation on refresh, and v0.2 multi-factor authentication (ADR 0008, ADR 0010) — TOTP (RFC 6238), recovery codes, and WebAuthn assertion verification across ES256 / RS256 / EdDSA.

Status: v0.2.0 (stable). Includes the production-ready PostgresIdentityStore alongside the in-memory reference store. Per ADR 0014 the User entity carries an optional display_name with a partial-update update_user operation; per ADR 0015 list_users provides cursor-paginated user enumeration with a credential-identifier substring filter; per ADR 0013 the Postgres adapter cooperates with adopter-side outer transactions via savepoints when nested (psycopg3 connection.transaction() handles this automatically).

The same fixture corpus that gates @flametrench/identity (Node), flametrench/identity (PHP), and dev.flametrench:identity (Java) runs here. The cross-language Argon2id parity test is mechanical interop verification — a PHC hash produced by any of the four SDKs verifies identically here.

from flametrench_identity import InMemoryIdentityStore

store = InMemoryIdentityStore()
user = store.create_user()
cred = store.create_password_credential(
    user.id, "alice@example.com", "correcthorsebatterystaple"
)
verified = store.verify_password("alice@example.com", "correcthorsebatterystaple")
assert verified.usr_id == user.id

session_with_token = store.create_session(user.id, cred.id, ttl_seconds=3600)
# Carry session_with_token.token in Authorization: Bearer; only the SHA-256
# hash is ever persisted server-side.

Installation

pip install flametrench-identity

Requires Python 3.11+. Dependencies:

  • flametrench-ids — for usr_/cred_/ses_ id generation.
  • argon2-cffi — the canonical Python binding to libargon2. Pinned to the spec floor (m=19456 KiB, t=2, p=1).

Spec invariants enforced

  • Argon2id at the OWASP floorm=19456 KiB, t=2, p=1. Hashes produced here verify under Node's argon2 and PHP's password_verify(PASSWORD_ARGON2ID) and vice versa.
  • Cascade on revoke — revoking a user revokes all their active credentials AND terminates all their active sessions. Suspending preserves credentials but terminates sessions.
  • Rotation revokes the oldrotate_password etc. mark the old credential revoked, link the new with replaces=old.id, and terminate every session bound to the old credential.
  • Tokens are not session idscreate_session returns (session, token). Only the SHA-256 hash of the token is persisted; verify_session_token is constant-time.
  • Generic auth errorsverify_password raises InvalidCredentialError for both unknown identifier and bad password. The message intentionally doesn't disclose which arm failed.

Cross-language Argon2id parity

pytest tests/test_conformance.py -v

Runs the spec's identity/argon2id.json fixture. The fixture's PHC hash was generated by Node's argon2 package; this harness verifies it via argon2-cffi. Both bindings wrap the reference Argon2 C library and produce identical output.

License

Apache-2.0. See LICENSE and NOTICE.

Copyright 2026 NDC Digital, LLC.

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

flametrench_identity-0.3.0.tar.gz (59.2 kB view details)

Uploaded Source

Built Distribution

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

flametrench_identity-0.3.0-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file flametrench_identity-0.3.0.tar.gz.

File metadata

  • Download URL: flametrench_identity-0.3.0.tar.gz
  • Upload date:
  • Size: 59.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flametrench_identity-0.3.0.tar.gz
Algorithm Hash digest
SHA256 35cf5e1dc97f16f99cee8139de69f46ea03d5e760f99a850929c4a1d9331155a
MD5 b76443b9969d2a3aa2913f7b496995cc
BLAKE2b-256 ed9493b73e46d83672c8fec297776f978bb6a1f1171f9dcb5cb02939baf5b368

See more details on using hashes here.

Provenance

The following attestation bundles were made for flametrench_identity-0.3.0.tar.gz:

Publisher: publish.yml on flametrench/identity-python

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

File details

Details for the file flametrench_identity-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flametrench_identity-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18eeb3844b81407e24d11c0865c10148ad9af78d384173edccd009857d0ef64d
MD5 8a6f38529d322ca1db5891dd9d5862e5
BLAKE2b-256 059827f97ab17d360e621bd176cffd33decf1a69df8c5234c3a20a80f92365a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for flametrench_identity-0.3.0-py3-none-any.whl:

Publisher: publish.yml on flametrench/identity-python

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