Skip to content

[M2.2d4b2] Add audited API token lifecycle commands - #59

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

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d4b2-api-token-commands

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

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.

  • M2.2d4b2 acceptance met
  • Real database, concurrent and rollback tests pass
  • Audit events emitted for credential mutations
  • Spec/plan updated; live tenant adapter tracked under M2.3

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4b1-api-token-store branch from b058ebd to 404a8b5 Compare November 5, 2026 12:34
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2d4b1-api-token-store to main November 5, 2026 12:34
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4b2-api-token-commands branch from e3017ab to b40ea4c Compare November 5, 2026 12:35
@samuelmbabhazi
samuelmbabhazi merged commit 8502a02 into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2d4b2-api-token-commands branch November 5, 2026 12:35
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
Bearer credential authentication now intersects token scopes with
current owner authority on every request. It re-reads token/account
state under the owner lock shared by revocation and security changes,
rejects invalid lifecycle state and records successful use
monotonically. Encrypted creation retries have a separate
ownership/version/liveness/authority revalidation path.

API traffic uses fixed one-minute quotas of 300 requests per token and
600 per IP, shared across instances. Password proof throttling keeps its
existing progressive delays. HTTP enforcement follows in M2.2d4c2a; the
tenant authority adapter remains fail-closed until M2.3.

Validation: throttle-policy test written red first; all 95 API unit
tests, lint and typecheck pass. Four real-PostgreSQL tests cover
scope/resource boundaries, live authority loss, malformed and
purpose-mismatched credentials, expiry, disablement, password-version
changes, revocation, shared quotas and exact window expiry.
Authentication coverage is 100% lines/functions, 96.42% statements and
96.29% branches.

Security: no dependency or new HTTP surface. Token subjects are hashed
before persistence. No raw secret is emitted to metadata/audit/logs.
Stacked on #59; no merge requested.

- [x] M2.2d4c1 acceptance met
- [x] Real persistence and quota tests pass
- [x] Explicit permission plus live authority required
- [x] Spec/plan updated; HTTP guard integration remains tracked
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