Repository navigation
fix: [Timetraked] Harden SQL API, AI proxy and sign-in flow - #284
Merged
Merged
Conversation
Deploying timetrackerpro with
|
| Latest commit: |
37875ab
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d5de3685.timetrackerpro.pages.dev |
| Branch Preview URL: | https://fix-security-ux-audit.timetrackerpro.pages.dev |
Security - Self-hosted SQL API binds to 127.0.0.1 by default, limits CORS to SQL_ALLOWED_ORIGINS, supports a SQL_API_TOKEN bearer token (required off loopback), returns generic errors, and verifies database TLS certificates (DB_SSL_CA) - ai-proxy requires a signed-in user (anon key rejected), rate-limits per user, streams and caps request bodies at 256 KB, forwards only allowlisted fields, sends the Gemini key as a header, and allows the Tauri origins - Remove the service-worker cache of Supabase responses and purge it on startup and sign-out - Tighten the web CSP (no inline scripts) and add public/_headers with frame-ancestors, HSTS, nosniff, Referrer-Policy, Permissions-Policy and COOP - Update react-router-dom, express and mysql2; override body-parser and qs - URL-encode client map/email links; extend the CSV formula guard to tab and carriage return Sign-out and local data - Sign Out asks "Keep a copy" or "Remove from this device" - Copy account data to the device before Supabase ends the session (it previously failed with "User not authenticated"), capped at 5 s - "Remove" clears localStorage data, saved summaries and desktop/iOS disk backups (new backup_clear Tauri command); backups stay paused until a clean guest-mode reload, fail closed on errors, and resume if Supabase fails to sign out Sign-in and UX - Accounts are invite-only: no in-app sign-up or password reset - "Use on device" no longer submits the sign-in form; autofill attributes, show/hide password and readable, linked error messages - AI summaries require sign-in; readable proxy errors - Inline hint replaces the invoice alert(); autofill tokens on client and task forms Build and docs - Remove stale bun.lock and package-lock.json so Cloudflare Pages installs with pnpm; ignore supabase/.temp - Update CHANGELOG, README, README-EXT, AGENTS, SQL_BACKEND and CI_CD docs
AdamJ
force-pushed
the
fix/security-ux-audit
branch
from
November 14, 2026 02:04
dbc968c to
37875ab
Compare
5 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes from a security and UX audit of the web app, the
ai-proxyEdge Function, the self-hosted SQL server and the sign-in flow. Highlights: the SQL API is no longer open to the network or to other websites,ai-proxynow requires a signed-in user (accounts are invite-only), sign-out asks whether to keep data on the device, and the guest button (now "Use on device") no longer signs the user in.Type of Change
bun.lock/package-lock.json(Cloudflare Pages was installing with bun from an outdatedbun.lock)Related Issue
None. Findings come from the audit report.
Changes Made
Security
server/app.ts,server/index.ts,server/db.ts: bind to127.0.0.1by default; CORS limited toSQL_ALLOWED_ORIGINS; optional bearer tokenSQL_API_TOKEN, required to listen on any other host; generic error responses; database TLS certificates verified, with a newDB_SSL_CAoption. Client sendsVITE_SQL_API_TOKEN(src/services/sqlApiService.ts).supabase/functions/ai-proxy/index.ts: requires a signed-in user (token checked against/auth/v1/user, so the anon key gets401); 10 requests a minute per user; body read in chunks and capped at 256 KB; onlysystemInstruction/contents/generationConfigforwarded; key sent asx-goog-api-keyheader; Tauri origins allowed. Already deployed.vite.config.ts,clearLocalData.ts,main.tsx,AuthContext.tsx: removed the service-worker cache of Supabase responses and delete any old cache on startup and sign-out.SignOutDialog.tsx(new),UserMenu.tsx,TimeTrackingContext.tsx: sign-out offers "Keep a copy" or "Remove from this device"; the choice survives a failed sign-out, which shows a toast.index.html,public/_headers(new): CSP drops'unsafe-inline'scripts and the stale Gemini host; Cloudflare Pages gets CSP withframe-ancestors 'none', HSTS (max-age=300to start),nosniff,Referrer-Policy,Permissions-Policyand COOP.package.json,pnpm-workspace.yaml:react-router-dom6.30.6,express5.3.0,mysql23.24.6; overrides forbody-parserandqs. Audit goes from 10 production advisories to 3; the rest needreact-router7 andzod4.exportUtils.ts: CSV formula guard also covers a leading tab or carriage return.UX
AuthDialog.tsx: guest button istype="button"and renamed "Use on device"; autofill attributes, show/hide password, readable errors linked to the fields; invite-only note removed. No in-app sign-up or password reset (passwords are managed in the Supabase dashboard); unusedsignUpremoved fromAuthContext.Report.tsx,useReportSummary.ts: Generate disabled for guests with a sign-in hint; proxy errors shown as readable messages.ExportDialog.tsx: nativealert()replaced by an inline hint.ClientSheet.tsx,NewTaskForm.tsx:section-clientautofill tokens; task titleautocomplete="off".ClientManagement.tsx: Maps and email links URL-encoded.Tests:
server/app.test.ts,AuthDialog.test.tsx,clearLocalData.test.ts(new); new cases inuseReportSummary.test.tsandexportUtils.test.ts.Docs:
CHANGELOG.md,README.md,README-EXT.md,AGENTS.md,docs/SQL_BACKEND.md,.env.example.Checklist
Documentation
README.mdCHANGELOG.mdupdated accordinglyGeneral
mainpnpm test,pnpm lint, andpnpm buildpnpm test: 43 files, 495 tests pass.pnpm buildpasses.pnpm lintreports no new errors in changed files, but the repo has existing lint errors, so the command doesn't pass overall. Not manually tested in the browser.Notes for Reviewers
127.0.0.1. To listen on any other host, setSQL_API_TOKENon the server and the same value asVITE_SQL_API_TOKENon the frontend. The frontend token is bundled into the client, so this suits personal setups only.🤖 Generated with Claude Code