09 · Family payment portal
A read-only “which payments are due next” page for family helping to pay, at family.<domain> (override with FAMILY_HOST). Family never get the plan password; the plan cookie is ignored on that host.
What family see
- The next payment: amount, what it’s for (type label: Deposit / Instalment / Final balance / Refund), supplier, due date or days overdue.
- Totals: due in the next 30 days, still to pay, overdue, paid so far.
- Everything coming up after that.
- The last five payments made.
Never shown: references, notes, invoice links, the budget, guests, or anything else. Payments with Show on family portal unticked are left out entirely. The couple can check with Payments → Family view (GET /api/family/preview), which uses the same query and template.
Isolation and page safety
- The family host is matched first and serves only
GET /./api,/mcp,/mediaand the app bundle 404 there. - Server-rendered with no JavaScript, a
default-src 'none'Content-Security-Policy,no-storeandnoindex.
Two locks
- Cloudflare Access (
worker/src/access.js). The Worker re-checks theCf-Access-Jwt-Assertiontoken (orCF_Authorizationcookie) itself: RS256 signature against the team’s certs (cached 10 minutes, refreshed on an unknown key id), issuer, audience,exp/nbf. Fails closed: untilCF_ACCESS_TEAM_DOMAINandCF_ACCESS_AUDare set the page shows “Almost ready” (503) with no data. - The family list in D1 (
worker/src/family-access.js). The signed-in email must be one of the couple, or on the list right now. Otherwise: 403 “Not on the list”.
Managing who gets in (Payments → Family access)
“Who can open the read-only family payment portal”. Family sign in with a code emailed to the address on the list.
- Add: email address + “Who is it? (optional)” label → Add (“Added to the family list”). Remove → “Remove from the family list?”.
- Empty list: “No family added yet — only you two can open the family portal.”
- D1 is the source of truth: table
family_members(id,emailunique and lower-cased,label,created_at), at most 50 addresses. - The couple’s own addresses are not stored there. They come from the email settings (the couple’s addresses, plus
ACCESS_ALLOWED_EMAILS) and are always allowed. - Routes:
GET/POST /api/family/members,DELETE /api/family/members/:id,POST /api/family/sync. Not available over MCP.
Sync to Cloudflare
After every add or remove the Worker reads the reusable “Family” Access policy and writes back its include list as one email rule per address, couple first then family (PUT /accounts/{account_id}/access/policies/{policy_id}). * It keeps the policy’s name, Allow action and other settings. * It refuses to send if the list would be empty, if the couple’s addresses are unknown, or if the policy isn’t an Allow policy. It never sends “Everyone”.
| Card status | Meaning |
|---|---|
| Live in Cloudflare | Synced |
| Saved, but not yet live in Cloudflare | Sync failed; shows the last attempt and Sync now (“Send the current list to Cloudflare again”) |
| Saved here — sync not set up | The three sync secrets aren’t set; the Worker’s own list check still applies |
Sync status is stored in settings.family_sync_status with counts only; emails in logs are masked.
Removing someone stops new sign-in codes (once synced), and the list check blocks them on their next request. Their existing Access session isn’t revoked (up to a month) but no longer opens the page.
Worker settings
| Variable | Value |
|---|---|
CF_ACCESS_TEAM_DOMAIN |
<team>.cloudflareaccess.com |
CF_ACCESS_AUD |
the Access application’s AUD tag |
CF_API_TOKEN |
sync: account-scoped token with only Access: Apps and Policies → Edit |
CF_ACCOUNT_ID |
sync: the account id |
CF_ACCESS_FAMILY_POLICY_ID |
sync: id of the “Family” policy |
FAMILY_HOST |
optional, default family.<SITE_DOMAIN> |
Setup order: login method (one-time PIN) → reusable “Family” policy (Allow, include the couple’s emails; never Everyone) → self-hosted Access app on the family host (1-month session) → set AUD + team domain → migrations 0009/0010 → deploy → add the custom domain last.