feat(join): authenticated accept-by-code endpoint + iOS contract #238

Merged
amiryahaya merged 1 commit from feat/join-by-code-234 into main 2026-11-20 11:13:36 +01:00
Owner

Resolves #234 — authenticated join-by-code is now usable end-to-end.

Server

New POST /api/invitations/code/{code}/accept (authenticated, "auth" rate-limit partition): delegates to InvitationAcceptanceService.AcceptAsync(token: code) — the service already matches ShortCode == token for the registration flow. Targeted invitations enforce email/user match inside the service; for open invitations the code is the capability secret (2^40, rate-limited surfaces). Rule 6b (full-token proof on the id-route) is preserved — restructured around a single hasValidTokenProof computation, and the rule-5 email bypass is closed unless token-proofed (dual-pass review finding: a null-email account could previously claim an email-targeted invite).

Authz matrix row added (SEC-03 coverage test).

iOS

JoinTenantViewModel authenticated accept posts to the code-keyed endpoint (the entered code — no invitation-id dependency); slice-3 nil-id guard removed as obsolete; stubs re-keyed.

Tests

  • Server: 7 new integration tests (targeted email-match accept, open-invite accept, wrong-email 403, already-member 409, expired 410, unknown 404, unauthenticated 401) + Guid-as-code non-interference guard. Full server suite: 1110 tests, 0 failures (local run via xunit.v3 self-executing mode; local dotnet test runner is broken — missing prerelease testhost in the NuGet cache).
  • iOS: JoinTenantViewModelTests 21/21 (accept tests re-keyed, id-guard test replaced by a code-keyed assertion).

Review

Dual-pass: reviewer found the rule-5 null-email bypass (fixed: closed unless token-proofed) + full-token alias doc + Guid-as-code guard test + #236 follow-up already filed. Coverage: project gate covers FailSulit.Api — the new endpoint is exercised by the 7 new integration tests.

Resolves #234 — authenticated join-by-code is now usable end-to-end. ## Server New `POST /api/invitations/code/{code}/accept` (authenticated, "auth" rate-limit partition): delegates to `InvitationAcceptanceService.AcceptAsync(token: code)` — the service already matches `ShortCode == token` for the registration flow. Targeted invitations enforce email/user match inside the service; for open invitations the code is the capability secret (2^40, rate-limited surfaces). Rule 6b (full-token proof on the id-route) is preserved — restructured around a single `hasValidTokenProof` computation, and the rule-5 email bypass is closed unless token-proofed (dual-pass review finding: a null-email account could previously claim an email-targeted invite). Authz matrix row added (SEC-03 coverage test). ## iOS JoinTenantViewModel authenticated accept posts to the code-keyed endpoint (the entered code — no invitation-id dependency); slice-3 nil-id guard removed as obsolete; stubs re-keyed. ## Tests - Server: 7 new integration tests (targeted email-match accept, open-invite accept, wrong-email 403, already-member 409, expired 410, unknown 404, unauthenticated 401) + Guid-as-code non-interference guard. **Full server suite: 1110 tests, 0 failures** (local run via xunit.v3 self-executing mode; local `dotnet test` runner is broken — missing prerelease testhost in the NuGet cache). - iOS: JoinTenantViewModelTests 21/21 (accept tests re-keyed, id-guard test replaced by a code-keyed assertion). ## Review Dual-pass: reviewer found the rule-5 null-email bypass (fixed: closed unless token-proofed) + full-token alias doc + Guid-as-code guard test + #236 follow-up already filed. Coverage: project gate covers FailSulit.Api — the new endpoint is exercised by the 7 new integration tests.
feat(join): authenticated accept-by-code endpoint + iOS contract (#234)
All checks were successful
Security CI / security-scan (pull_request) Successful in 7m34s
API CI / build-and-test (pull_request) Successful in 9m20s
API CI / migrations (pull_request) Successful in 9m30s
ced22bdee8
... plus dual-pass fixes: rule 5/6b restructured around a single
hasValidTokenProof computation (token possession supersedes the email
match AND satisfies the id-route proof; the null-email bypass is closed
unless token-proofed), authz matrix row for the new route, Guid-as-code
non-interference guard test, full-token alias documented, stale docs
cleaned. Server suite 1110/0 (40 pre-existing skips); local gate run via
dotnet exec (xunit.v3 self-executing mode).
Sign in to join this conversation.
No description provided.