feat(auth-local): add local accounts and server-side sessions #57

Merged
crapougnax merged 1 commit from feat/56-auth-local into develop 2026-11-16 10:10:38 +00:00
Member

Closes #56

What

New package @quatrain/auth-local (version 1.0.0-beta.1), an adapter of @quatrain/auth for an application that keeps its users itself. It is also what gives an application session to a user signed in with @quatrain/auth-oidc-client.

  • Passwords: scrypt (N = 2^15, r = 8, p = 3 by default), self-describing hash string, transparent rehash when the cost changes, constant-time comparison.
  • Sessions: opaque 256-bit token, only its SHA-256 digest is stored; absolute lifetime (30 days) and idle delay (7 days); revocable alone or per account; a new password or a disabled account closes every session.
  • External identities: one account per (issuer, subject), created at first sign-in or refused (create: false); never matched to an existing account by e-mail, linking is explicit.
  • No account enumeration: unknown login, wrong password and disabled account give the same error after the same hashing work.
  • Storage: LocalAuthStoreInterface, with PostgresLocalAuthStore (bound parameters only, DDL in sql/auth_local.sql, tables auth_account, auth_identity, auth_session) and MemoryLocalAuthStore.

Out of scope

Password recovery, multi-factor authentication, rate limiting of sign-in attempts (left to the application, said in the HOWTO).

Tests

35 tests. The same contract suite runs on the memory store and on PostgreSQL; the PostgreSQL half needs AUTH_LOCAL_TEST_URL and is skipped in CI. Run locally against PostgreSQL 17: all pass.

To decide at review

  • The package name.
  • The table names (auth_*), fixed for now.

🤖 Generated with Claude Code

Closes #56 ## What New package `@quatrain/auth-local` (version `1.0.0-beta.1`), an adapter of `@quatrain/auth` for an application that keeps its users itself. It is also what gives an application session to a user signed in with `@quatrain/auth-oidc-client`. - **Passwords**: scrypt (N = 2^15, r = 8, p = 3 by default), self-describing hash string, transparent rehash when the cost changes, constant-time comparison. - **Sessions**: opaque 256-bit token, only its SHA-256 digest is stored; absolute lifetime (30 days) and idle delay (7 days); revocable alone or per account; a new password or a disabled account closes every session. - **External identities**: one account per (`issuer`, `subject`), created at first sign-in or refused (`create: false`); never matched to an existing account by e-mail, linking is explicit. - **No account enumeration**: unknown login, wrong password and disabled account give the same error after the same hashing work. - **Storage**: `LocalAuthStoreInterface`, with `PostgresLocalAuthStore` (bound parameters only, DDL in `sql/auth_local.sql`, tables `auth_account`, `auth_identity`, `auth_session`) and `MemoryLocalAuthStore`. ## Out of scope Password recovery, multi-factor authentication, rate limiting of sign-in attempts (left to the application, said in the HOWTO). ## Tests 35 tests. The same contract suite runs on the memory store and on PostgreSQL; the PostgreSQL half needs `AUTH_LOCAL_TEST_URL` and is skipped in CI. Run locally against PostgreSQL 17: all pass. ## To decide at review - The package name. - The table names (`auth_*`), fixed for now. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(auth-local): add local accounts and server-side sessions (#56)
Some checks failed
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (pull_request) Failing after 5m25s
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (push) Failing after 5m19s
Quatrain Core CI / Publish Changed Packages to npm (push) Has been skipped
Quatrain Core CI / Publish Changed Packages to npm (pull_request) Has been skipped
022db94ce2
New package @quatrain/auth-local, an adapter of @quatrain/auth for an
application that keeps its users itself:

- password accounts hashed with scrypt, in a self-describing hash string,
  rehashed at sign-in when the cost changes;
- opaque session tokens stored as SHA-256 digests, with an absolute
  lifetime and an idle delay, revocable alone or per account;
- accounts opened from an external identity (issuer, subject), never
  matched to an existing account by e-mail address;
- a storage interface with a PostgreSQL store (DDL shipped) and an
  in-memory store.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
crapougnax merged commit a672616b50 into develop 2026-11-16 10:10:38 +00:00
crapougnax deleted branch feat/56-auth-local 2026-11-16 10:10:38 +00:00
Sign in to join this conversation.
No description provided.