Plain Postgres, with the server verifying Apple and Google sign-in itself
Context and problem
The plan used Supabase for sign-in and Postgres: its auth for Apple and Google, and row-level security (RLS) to decide who may read and write each row. Work had started on both: a server spike that accepted Supabase tokens (#25) and a full Supabase schema with RLS policies and pgTAP tests (#26). Halfway through day 1, Eduardo asked why. The Rust server was already the single gatekeeper for every move.
Options considered
- Supabase, as planned. Hosted sign-in and Postgres, with RLS policies on every table and SECURITY DEFINER functions for invites.
- Plain Postgres, with the server doing sign-in. The server verifies Apple and Google identity tokens, issues its own tokens, and is the only client of the database.
Decision
We chose option 2. With the server as the one gatekeeper, RLS would have been a second set of rules to keep in sync with the server’s. So:
- The server verifies Apple and Google identity tokens against their published keys, then issues its own short-lived access tokens (15 minutes) and rotating refresh tokens, stored only as hashes (#31, #34).
- Tables, invites, groups and saved games live in plain Postgres, through sqlx migrations compiled into the binary (#41).
- The finished, reviewed Supabase PR (#26) was closed. Its table design, invite-code design, deletion rules and security checklist carried over into the server.
Consequences
Good
- One place decides who may do what. The rules the closed Supabase design enforced (invite limits, rate limits, who may revoke) are now the server’s, listed in docs/server.md.
- The whole stack runs locally with no Docker:
bin/setup, thenbin/dev, with a dev sign-in for playing with yourself in two windows. - Tests run offline, with local key pairs and local stand-ins for Apple’s and Google’s servers.
- The change was cheap because it came on day 1.
Bad
- We own the sign-in code: key caching, token issuing, refresh-token reuse detection, account deletion and Apple token revocation. Every pull request that touched sign-in got a security review, and every review found something.
- An access token issued before logout or deletion still opens a WebSocket until it expires, up to 15 minutes.
- We host and run Postgres ourselves; hosting the server and its database is still open (#50).
- Finished, reviewed Supabase work was thrown away, apart from what carried over.
More information
- The closing note on #26 records the choice, made 18 November 2026.
- Diary: Day 1, “What went wrong”; Day 2, “Playing online”.
- The server’s sign-in, schema and the sqlx connection findings: docs/server.md; local setup: docs/development.md.