Skip to content

[M2.2d4a] Define closed API token scope policy - #57

Merged
samuelmbabhazi merged 2 commits into
mainfrom
feat/m2.2d4a-api-token-policy
Nov 5, 2026
Merged

samuelmbabhazi merged 2 commits into
mainfrom
feat/m2.2d4a-api-token-policy

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

API tokens now have a pure scope policy shared with the upcoming authorization matrix. Permissions form a closed vocabulary; wildcard and secret-value-read scopes are rejected. A token cannot span multiple organizations. Tenant scopes require an organization and can narrow to a project/environment without crossing that hierarchy. Profile read is the only account-level scope.

Input scopes are bounded, copied, frozen and deduplicated before authorization. Labels reject control/format characters and are limited to 64 code points. Token expiry ranges from one minute to ninety days. The active-token cap is 50. Scope matching explicitly requires an additional live owner-permission check; this PR alone grants no API access.

Validation: tests were written before implementation. Domain lint/typecheck/build and all 25 domain tests pass. The new policy has 100% statement, branch and function coverage; the full domain package remains above its 90% target. Tests cover unknown/wildcard scopes, malformed hierarchy, cross-tenant/resource attempts, input mutation, label injection and exact expiry boundaries.

Security: pure functions, no framework, I/O or dependency added. Plan/spec updated; persistence and HTTP authentication remain M2.2d4b/c. Stacked on #56; no merge requested.

  • M2.2d4a criteria met
  • Domain tests and coverage target pass
  • Default-deny scope rules and owner-policy intersection documented
  • No state mutation, new shell invocation or secret exposure path

@samuelmbabhazi samuelmbabhazi mentioned this pull request Nov 4, 2026
4 tasks done
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2d3-mfa-http to main November 5, 2026 12:33
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4a-api-token-policy branch from 4a25173 to 9bc5d8e Compare November 5, 2026 12:34
@samuelmbabhazi
samuelmbabhazi merged commit e354d41 into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2d4a-api-token-policy branch November 5, 2026 12:34
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
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.

- [x] M2.2d4b1 acceptance covered
- [x] Real database tests and API checks pass
- [x] Plan/spec updated and later integration tracked
- [x] No new shell invocation or plaintext secret storage
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