Repository navigation
[M2.2d4c1] Authenticate scoped tokens with shared quotas - #60
Merged
Merged
Conversation
4 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2d4b2-api-token-commands
branch
from
November 5, 2026 12:35
e3017ab to
b40ea4c
Compare
samuelmbabhazi
changed the base branch from
feat/m2.2d4b2-api-token-commands
to
main
November 5, 2026 12:35
samuelmbabhazi
force-pushed
the
feat/m2.2d4c1-api-token-auth
branch
from
November 5, 2026 12:35
116e039 to
5fb43ba
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.