Identity primitives for Flametrench: users, credentials (Argon2id-pinned passwords, passkeys, OIDC), and user-bound sessions with rotation on refresh.
Project description
flametrench-identity
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 floor —
m=19456 KiB, t=2, p=1. Hashes produced here verify under Node'sargon2and PHP'spassword_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 old —
rotate_passwordetc. mark the old credentialrevoked, link the new withreplaces=old.id, and terminate every session bound to the old credential. - Tokens are not session ids —
create_sessionreturns(session, token). Only the SHA-256 hash of the token is persisted;verify_session_tokenis constant-time. - Generic auth errors —
verify_passwordraisesInvalidCredentialErrorfor 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35cf5e1dc97f16f99cee8139de69f46ea03d5e760f99a850929c4a1d9331155a
|
|
| MD5 |
b76443b9969d2a3aa2913f7b496995cc
|
|
| BLAKE2b-256 |
ed9493b73e46d83672c8fec297776f978bb6a1f1171f9dcb5cb02939baf5b368
|
Provenance
The following attestation bundles were made for flametrench_identity-0.3.0.tar.gz:
Publisher:
publish.yml on flametrench/identity-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flametrench_identity-0.3.0.tar.gz -
Subject digest:
35cf5e1dc97f16f99cee8139de69f46ea03d5e760f99a850929c4a1d9331155a - Sigstore transparency entry: 1749364901
- Sigstore integration time:
-
Permalink:
flametrench/identity-python@67bd59255ca9d2d4db84df7838fcbf55c91d0a80 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/flametrench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67bd59255ca9d2d4db84df7838fcbf55c91d0a80 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flametrench_identity-0.3.0-py3-none-any.whl.
File metadata
- Download URL: flametrench_identity-0.3.0-py3-none-any.whl
- Upload date:
- Size: 47.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18eeb3844b81407e24d11c0865c10148ad9af78d384173edccd009857d0ef64d
|
|
| MD5 |
8a6f38529d322ca1db5891dd9d5862e5
|
|
| BLAKE2b-256 |
059827f97ab17d360e621bd176cffd33decf1a69df8c5234c3a20a80f92365a8
|
Provenance
The following attestation bundles were made for flametrench_identity-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on flametrench/identity-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flametrench_identity-0.3.0-py3-none-any.whl -
Subject digest:
18eeb3844b81407e24d11c0865c10148ad9af78d384173edccd009857d0ef64d - Sigstore transparency entry: 1749365025
- Sigstore integration time:
-
Permalink:
flametrench/identity-python@67bd59255ca9d2d4db84df7838fcbf55c91d0a80 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/flametrench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67bd59255ca9d2d4db84df7838fcbf55c91d0a80 -
Trigger Event:
workflow_dispatch
-
Statement type: