Skip to content

[M2.3d4c] Role-binding mutation HTTP endpoints and privilege-change acceptance - #115

Merged
samuelmbabhazi merged 7 commits into
mainfrom
feat/m2.3d4c-binding-http
Nov 5, 2026
Merged

samuelmbabhazi merged 7 commits into
mainfrom
feat/m2.3d4c-binding-http

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

M2.3d4c: HTTP endpoints for project and environment role bindings, on top of the existing audited BindingCommands (M2.3c4c1).

  • Endpoints. All four are session-only: RequireTenant('member.manage', <exact scope>), no bearer opt-in, Origin and CSRF required, and the password-attempt rate limit applies.
    • POST /organizations/{o}/projects/{p}/bindings (200): email, role, password and optional TOTP or recovery code.
    • POST /organizations/{o}/projects/{p}/bindings/{membershipId}/remove (200).
    • POST /organizations/{o}/projects/{p}/environments/{e}/bindings (200).
    • POST .../environments/{e}/bindings/{membershipId}/remove (200).
  • Response. { binding, session? }. Only canonical path ids reach the command.
  • Retries. The replay route allowlist is rewritten as a small structured matcher and now covers these routes. Each replay rechecks live member.manage.
  • Generated code. openapi.json and the api-client types are regenerated. The SPEC is updated and M2.3d4c is ticked.

Fixes included:

  • membership-http.integration.spec.ts (from [M2.3d4b] Membership mutation HTTP endpoints with fresh proof and encrypted retries #114). The restricted Prisma client cannot see tenant rows outside a tenant transaction (row-level security), so counting memberships through it always returned 0, and findFirstOrThrow would have failed. Both specs now read tenant rows through the administrative login, like the other tenant tests.
  • Intermittent CA unit test. rejects malformed, forged and non-Ed25519 requests edited the base64 text of the PEM. When the signature's last byte was 0, the lenient decoder ignored the edit, so the forged CSR still verified (about 1 run in 256; it failed once in this gate). The test now flips one bit of the last DER byte. It passed 8 consecutive runs.

How it was tested

  • Unit tests for the replay route allowlist: the new routes are accepted; wrong scopes, /role on bindings, non-UUID or upper-case ids, /delete and extra segments are rejected.
  • New binding-http.integration.spec.ts:
    • a project grant takes effect after re-login; the subject's sessions end; replay and conflicting replay;
    • session, Origin, CSRF and password required; a bearer token with member.manage is rejected; DTO validation;
    • unknown addresses and organization owners answer 404 with no write;
    • an environment-only admin cannot override or remove a project admin, while the project admin can narrow the environment admin;
    • removal revokes access and replays;
    • rollback when the audit or retry write fails.
  • Not run locally: the integration tests (no Docker). They run in CI-1.
  • Local gate passes.

Security considerations

  • Privilege changes require fresh proof and are never reachable with API tokens.
  • Hidden, unknown and ineligible accounts give the same 404.
  • The SPEC 7 rule against overriding a project admin is enforced and tested over HTTP.

@samuelmbabhazi
samuelmbabhazi merged commit db146e2 into main Nov 5, 2026
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.3d4c-binding-http branch November 5, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant