Skip to content

[M2.2d4c1] Authenticate scoped tokens with shared quotas - #60

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

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d4c1-api-token-auth

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

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.

  • M2.2d4c1 acceptance met
  • Real persistence and quota tests pass
  • Explicit permission plus live authority required
  • Spec/plan updated; HTTP guard integration remains tracked

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4b2-api-token-commands branch from e3017ab to b40ea4c Compare November 5, 2026 12:35
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2d4b2-api-token-commands to main November 5, 2026 12:35
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d4c1-api-token-auth branch from 116e039 to 5fb43ba Compare November 5, 2026 12:35
@samuelmbabhazi
samuelmbabhazi merged commit 1050efd into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2d4c1-api-token-auth branch November 5, 2026 12:36
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
The global identity guard now accepts Bearer credentials only on
explicitly opted-in routes. GET /auth/session allows profile.read and
returns account metadata with the token expiry, without issuing session
cookies. MFA and other unmarked routes remain session-only.

Malformed or duplicate Authorization headers fail closed and never fall
back to a valid cookie. API quotas run before token authentication,
including an IP charge for malformed credentials. Session/anonymous
mutation Origin and CSRF requirements remain enforced; explicitly
permitted bearer requests rely on their header credential. Session-only
principal access also checks the principal kind.

Validation: four real HTTP/PostgreSQL acceptance tests pass for profile
access, default denial, duplicate headers, cookie fallback prevention,
invalidation and quota headers. All 96 unit tests, API
lint/typecheck/build pass. A guard test covers bearer mutation behavior
and continued CSRF requirements for sessions. OpenAPI and client
regenerated.

Security: no dependency added. Quota responses share one helper; bearer
principals contain no raw token or password hash. Tenant resource
resolution remains M2.3; the current opt-in supports account-level
access only. Stacked on #60; no merge requested.

- [x] M2.2d4c2a acceptance met
- [x] HTTP/database and guard tests pass
- [x] Generated contract current
- [x] Default-deny behavior and secret boundaries covered
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