Server: authenticated join-by-code is structurally unusable — /code lookup omits id, accept requires it #234

Closed
opened 2026-11-20 05:15:25 +01:00 by amiryahaya · 1 comment
Owner

Found while making the iOS suite honest (#233, dual-pass review finding).

The gap: the join flow for users who enter a short code is:

  1. GET /api/invitations/code/{code} (INV-06, PII-free preview) returns {tenant_name, role, short_code, expires_at} — no invitation id (deliberate: GetInvitationByToken.cs comment).
  2. POST /api/invitations/{id:guid}/accept (AcceptInvitation.cs) requires the GUID id.

So a short-code user can look up a preview but can never accept: the client cannot know the id. The iOS client now fails loudly (clear error, no garbage URL — JoinTenantViewModel guard) instead of hitting a malformed route, but the flow itself has no server-side path.

Also affected: AuthRepositoryImpl.acceptInvitationAsExistingUser posts /invitations/token/{token}/accept — no such server route exists (server has /{id:guid}/accept and /token/{token}/accept-with-wallet). Same contract-drift class.

Possible resolutions (server-side decision needed):

  • return the invitation id from /code/{code} when the caller is authenticated (id is not PII for an already-authed member), or
  • add POST /api/invitations/code/{code}/accept (server resolves code → id internally, taking the token proof from the body like AcceptInvitation already does), or
  • route the client through the token-based accept (/token/{token}/accept-with-wallet pattern) after registration.

Related drift of the same class (separate ticket-worthy): GET /api/invitations + /sent response envelopes (items paged shape, missing tenant_name) vs ReceivedInvitationsResponse/SentInvitationsResponse client models — the received-list decode would fail against the real server today.

Relates to #233, #223.

Found while making the iOS suite honest (#233, dual-pass review finding). **The gap:** the join flow for users who enter a short code is: 1. `GET /api/invitations/code/{code}` (INV-06, PII-free preview) returns `{tenant_name, role, short_code, expires_at}` — **no invitation `id`** (deliberate: GetInvitationByToken.cs comment). 2. `POST /api/invitations/{id:guid}/accept` (AcceptInvitation.cs) **requires the GUID id**. So a short-code user can look up a preview but can never accept: the client cannot know the id. The iOS client now fails loudly (clear error, no garbage URL — JoinTenantViewModel guard) instead of hitting a malformed route, but the flow itself has no server-side path. **Also affected:** `AuthRepositoryImpl.acceptInvitationAsExistingUser` posts `/invitations/token/{token}/accept` — no such server route exists (server has `/{id:guid}/accept` and `/token/{token}/accept-with-wallet`). Same contract-drift class. **Possible resolutions (server-side decision needed):** - return the invitation id from `/code/{code}` when the caller is authenticated (id is not PII for an already-authed member), or - add `POST /api/invitations/code/{code}/accept` (server resolves code → id internally, taking the token proof from the body like AcceptInvitation already does), or - route the client through the token-based accept (`/token/{token}/accept-with-wallet` pattern) after registration. **Related drift of the same class (separate ticket-worthy):** `GET /api/invitations` + `/sent` response envelopes (`items` paged shape, missing `tenant_name`) vs `ReceivedInvitationsResponse`/`SentInvitationsResponse` client models — the received-list decode would fail against the real server today. Relates to #233, #223.
Author
Owner

RESOLVED via PR #238 (merged ef58f83) — authenticated join-by-code works end-to-end.

  • New POST /api/invitations/code/{code}/accept (authenticated, "auth" rate-limit partition) delegating to InvitationAcceptanceService with token: code — the service's existing ShortCode matching. 7 integration tests (targeted email-match accept, open-invite accept, wrong-email 403, already-member 409, expired 410, unknown 404, unauthenticated 401, Guid-as-code 404 non-interference).
  • Open-invite policy: code = capability for authenticated members (2^40 space, rate-limited surfaces); rule 6b full-token proof preserved on the id-route. Rule 5's null-email bypass closed unless token-proofed (review finding — benefits both routes). Authz matrix row added (SEC-03).
  • iOS accept moved to the code-keyed endpoint; JoinTenantViewModelTests re-keyed (21/21). Server suite 1110/0 locally (via xunit.v3 self-exec mode — local dotnet test runner has a broken testhost cache).

Follow-up #236 remains open (dual-signature blob order + /invitations list envelope drift — same contract-drift class, separate work).

**RESOLVED via PR #238 (merged ef58f83) — authenticated join-by-code works end-to-end.** - New `POST /api/invitations/code/{code}/accept` (authenticated, "auth" rate-limit partition) delegating to InvitationAcceptanceService with `token: code` — the service's existing ShortCode matching. 7 integration tests (targeted email-match accept, open-invite accept, wrong-email 403, already-member 409, expired 410, unknown 404, unauthenticated 401, Guid-as-code 404 non-interference). - Open-invite policy: **code = capability** for authenticated members (2^40 space, rate-limited surfaces); rule 6b full-token proof preserved on the id-route. Rule 5's null-email bypass closed unless token-proofed (review finding — benefits both routes). Authz matrix row added (SEC-03). - iOS accept moved to the code-keyed endpoint; JoinTenantViewModelTests re-keyed (21/21). Server suite 1110/0 locally (via xunit.v3 self-exec mode — local `dotnet test` runner has a broken testhost cache). **Follow-up #236 remains open** (dual-signature blob order + /invitations list envelope drift — same contract-drift class, separate work).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/failsulit#234
No description provided.