Repository navigation
[M2.3d4b] Membership mutation HTTP endpoints with fresh proof and encrypted retries - #114
Merged
Merged
Conversation
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
…cceptance (#115) ## 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 #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.
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.
What changed
M2.3d4b: HTTP endpoints for organization membership changes, on top of the existing audited
MembershipCommands(M2.3c4b).RequireTenant('member.manage', 'organization'), no bearer opt-in, Origin and CSRF required, and the password-attempt rate limit applies.POST /organizations/{organizationId}/members(201): email, role, password and optional TOTP or recovery code.POST /organizations/{organizationId}/members/{membershipId}/role(200).POST /organizations/{organizationId}/members/{membershipId}/remove(200).{ membership, session? }:membershipis null after a removal;sessionappears only when the caller changed their own role, with the rotated credentials set only in cookies;member.manage.BrowserHeaders()is extracted for session-only OpenAPI headers.membershipDtois an explicit mapper.openapi.jsonand the api-client types are regenerated.How it was tested
/delete, a non-UUID membership id).membership-http.integration.spec.ts:member.manageis rejected; DTO validation;Security considerations