Skip to content

[M2.2d4b1] Persist revocable API tokens - #58

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d4b1-api-token-store
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d4b1-api-token-store

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

User-owned API tokens now have hash-only persistence, an owner-filtered store and database constraints for expiry, scope count and lifecycle timestamps. Authentication can atomically refuse expired, revoked, disabled-account or stale-security-version credentials while advancing last-use monotonically.

Lists use an exclusive UUID cursor and return at most 100 records. Revocation is conditional and owner-bound. The store participates in the existing identity transaction; commands and audit wiring follow in M2.2d4b2. Project ownership and live tenant RBAC remain explicitly tracked under M2.3.

Validation: failing integration tests preceded implementation. All three new real-PostgreSQL tests pass (cross-owner isolation, duplicate hashes, constraints, concurrent revocation, expiry equality, password/MFA version invalidation and rollback). API lint, typecheck and all 94 unit tests pass. Prisma client regenerated; no dependency added.

Security: only purpose-bound hashes are persisted; no HTTP credential exposure path is introduced. Internal records carry hashes and must be explicitly serialized at the HTTP boundary. Stacked on #57; do not merge automatically.

  • M2.2d4b1 acceptance covered
  • Real database tests and API checks pass
  • Plan/spec updated and later integration tracked
  • No new shell invocation or plaintext secret storage

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4a-api-token-policy branch from 4a25173 to 9bc5d8e Compare November 5, 2026 12:34
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2d4a-api-token-policy to main November 5, 2026 12:34
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4b1-api-token-store branch from b058ebd to 404a8b5 Compare November 5, 2026 12:34
@samuelmbabhazi
samuelmbabhazi merged commit a8c7f3d into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2d4b1-api-token-store branch November 5, 2026 12:35
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
API token creation and revocation now require password reauthentication
and the active MFA factor. Commands recheck the account/security version
under the user lock, enforce the 50-active-token cap across concurrent
requests, and commit proof consumption, credential changes and audit
events atomically.

Creation checks each requested scope against an owner-authority port.
Its initial adapter permits only account-level profile read and denies
all tenant capabilities until the M2.3 live RBAC integration. Lists
serialize explicit public metadata, including
expired/revoked/invalidated state, without hashes or internal security
versions. Revocation is owner-bound and safely repeatable.

Validation: all four real-PostgreSQL command tests pass, covering
concurrent creation at the cap, cross-owner access, stale
reauthentication, password/MFA proof, and audit failure after
creation/revocation. New command/authority coverage: 100%
statements/functions/lines and 96.96% branches (above the application
target). API lint/typecheck and 94 unit tests pass.

Security: no dependency, shell invocation or new HTTP surface. Secrets
use Secret wrappers and are absent from lists/audits. Role mutations
must serialize on the affected user lock, documented in the port.
Stacked on #58; no merge requested.

- [x] M2.2d4b2 acceptance met
- [x] Real database, concurrent and rollback tests pass
- [x] Audit events emitted for credential mutations
- [x] Spec/plan updated; live tenant adapter tracked under M2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant