rouse-context/docs/design
Jason Monk 4c442a8f48 Fix #170: align /renew request/response shapes between client and relay
The Android RelayApiClient and the relay's POST /renew endpoint had drifted
apart on both request and response shapes: the client was sending
{ csrPem, authMethod, currentCertPem } while the relay required
{ csr, subdomain, firebase_token, signature }, and the client expected
{ certificatePem } in the response while the relay returned
{ server_cert, client_cert, relay_ca_cert }. Neither side had integration
coverage on the renew path, so /renew returned 422 unconditionally in
production and cert renewal was quietly broken until devices approached
expiry.

This change keeps the relay's response shape (it already matched
/register/certs) and aligns the client to the relay side, plus a small
relay-side simplification so both auth paths are body-driven:

Request (both paths):
  { csr, subdomain, signature, firebase_token? }

Path A ("mTLS-equivalent", cert still valid): omit firebase_token.
Path B (cert expired): include firebase_token.
The relay verifies the signature against the public key it registered
earlier, and additionally verifies firebase_token (+ UID match) on Path B.

Response (matches /register/certs):
  { server_cert, client_cert, relay_ca_cert }

Wire-contract tests pin both sides:
- relay/tests/api_renew_test.rs gains a Path A signature-only success case
  and a bad-signature-on-Path-A case; pre-existing tests were adjusted
  for the new "signature always required" rule.
- core/tunnel CertRenewalTest gains serializer tests that assert the
  snake_case field names on both the request and the response, so a
  future rename on either side fails loudly here first.

CertRenewalFlow now routes the signature through a CsrSigner (parallel to
the existing FirebaseRenewalCredentialsProvider) so both paths sign over
the freshly-generated CSR DER rather than accepting a pre-computed value,
and stores all three cert bundle fields (mirroring CertProvisioningFlow).
RenewalAuthProvider in :work gains a signCsr hook to match.

docs/design/relay-api.md is updated to the new shape; the old stale
"Path A uses TLS client cert" language no longer reflects reality and
would have slowly misled future work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 19:41:25 -04:00
..
android-app.md Fix #78: Remove unused NotificationSettings, NotificationModel, and NotificationModelTest 2026-04-12 12:59:49 -04:00
health-connect-expansion.md Add design specs for new integrations and overnight execution plan 2026-04-06 17:03:37 -04:00
notifications-integration.md Add design specs for new integrations and overnight execution plan 2026-04-06 17:03:37 -04:00
outreach-integration.md Add design specs for new integrations and overnight execution plan 2026-04-06 17:03:37 -04:00
overall.md Fix #79: Remove stale NotificationModel references from docs 2026-04-12 13:02:21 -04:00
per-integration-hostnames.md Add design doc for per-integration hostnames 2026-04-08 17:23:24 -04:00
relay-api.md Fix #170: align /renew request/response shapes between client and relay 2026-04-15 19:41:25 -04:00
relay.md Remove relay_host/relay_port from FCM payloads, add FCM base URL override 2026-04-05 15:46:05 -04:00
secret-prefix-bot-rejection.md Update README and add secret prefix bot rejection design doc 2026-04-08 10:59:23 -04:00
tunnel-client.md Remove relay_host/relay_port from FCM payloads, add FCM base URL override 2026-04-05 15:46:05 -04:00
ui.md Move authorized clients into per-integration manage screen 2026-04-04 16:11:23 -04:00
usage-integration.md Add design specs for new integrations and overnight execution plan 2026-04-06 17:03:37 -04:00