- Document separated booking/payment state engine, 48-hour payment follow-up queue, and deliberate slot release in SRS.md and architecture.md. - Add ADR-0005 for server-side Google OAuth2 and Turso admin_allowlist. - Rewrite AGENTS.md as a local technical blueprint defining SQLModel + Repository layers, pytest-mock boundaries, and mutmut audits. Refs: #1, #3, #6
2.3 KiB
2.3 KiB
ADR 0005: Backend Google OAuth2 Authentication and Turso Administrator Allowlist
Status
Accepted (2026-10-18)
Context
armonia-dashboard is an operational control surface used by Jasmin and her assistant to acknowledge SPEI/cash payments, authorize delayed-payment exceptions, and release booking slots. Because armonia-dashboard is deployed as a static application on Cloudflare Pages, client-side route guards alone cannot protect administrative operations or keep OAuth secrets safe. Furthermore, if Jasmin rotates her assistant, revoking access must take effect immediately without rebuilding or redeploying containers.
Decision
- Backend-Driven Google OAuth2 Authorization Code Flow:
armonia-apihosts/auth/google/loginand/auth/google/callback, keepingGOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET, andSESSION_SECRET_KEYstrictly on the backend.- Upon callback,
armonia-apiexchanges the authorization code with Google, verifiesemail_verified == true, and checks the email against Turso'sadmin_allowlisttable. armonia-apiissues an HMAC-SHA256 signed session token (delivered viaHttpOnlycookie and usable as aBearertoken).
- Dedicated
admin_allowlistTable in Turso:- Stores
email PRIMARY KEY,full_name,role(OWNER,ASSISTANT,ADMIN),is_active,created_at, andlast_login_at. - Seeded idempotently on startup from
ADMIN_BOOTSTRAP_EMAILS. - Checked on every authenticated administrative request so setting
is_active = 0revokes access immediately.
- Stores
- Mandatory Audit Logging (
admin_audit_log):- Every administrative mutation records the authenticated administrator's email, action type, target entity ID, and timestamp in
admin_audit_logas well as on the booking/payment record (acknowledged_by,exception_authorized_by,released_by).
- Every administrative mutation records the authenticated administrator's email, action type, target entity ID, and timestamp in
Consequences
Positive
- Zero OAuth client secrets or session signing keys exposed in the frontend bundle.
- Instant administrator revocation or addition via Turso without container redeployment.
- Complete accountability for who acknowledged a payment, authorized a delayed payment, or released a slot.
Negative / Trade-offs
- Every protected administrative request performs a fast primary-key lookup against
admin_allowlistin Turso/SQLite.