Skip to content

Turnstile as the only gate, fail-closed secret, and a repo-wide cleanup - #102

Open
Maharsh17 wants to merge 1 commit into
mainfrom
cleanup/turnstile-only-and-audit
Open

Maharsh17 wants to merge 1 commit into
mainfrom
cleanup/turnstile-only-and-audit

Conversation

@Maharsh17

Copy link
Copy Markdown
Member

Summary

Takes the findings from a repo audit (over-engineering + "run it like a big-company service") and applies the ones we agreed on.

Access

  • Removes the HTTP Basic login that was written but never wired (app/auth.py, scripts/create_researcher.py, the researcher / workspace_member tables and helpers, argon2-cffi). The tables are dropped on startup; prod held one bootstrap row.
  • Per-browser boards are unchanged: every browser still gets its own isolated workspace via X-Board-Id.
  • SESSION_SECRET is required. The API refuses to start without it instead of silently signing Turnstile cookies with a public default.
  • README and docs now describe Turnstile (a bot check, not a login) as the only gate. /api/me/ removed from the API reference (it never existed).

Cleanup

  • scripts/export_csv.py deleted (it crashed on every run with a bad kwarg; Export in the UI covers it), along with the db_path parameter only it used.
  • SQLite-era ? placeholder shim removed; queries use psycopg %s directly.
  • axios replaced with a small fetch wrapper keeping the api.get / api.post shape (new api.test.js); requests replaced with httpx (already a dependency).
  • GOAL_TIMELINE/ROLLUP/RUBRIC_ENABLED (set nowhere) folded into GOAL_BATTERY_ENABLED.
  • requirements.txt, the unused MAX_STUDENT_IDS, the ngrok header, stale SQLite wording, and the old luc-dashboard name removed.

Operations

  • /healthz now checks the DB and a daemon heartbeat (stamped every 10s on every tick) and returns 503 when it is older than 120s.
  • postgres:18 pinned in compose (prod already runs 18.4 from latest) and CI; Node 22 (20 is EOL) in the image, dev compose and CI; the image installs with npm ci.
  • make install sets up the engine submodule.
  • Goal evidence panel split out of CohortDashboard.jsx into GoalEvidence.jsx (2935 -> 1772 lines).

Test plan

  • Backend: 265 passed against a throwaway postgres:18; ruff check + format clean
  • Frontend: 52 passed (incl. new api tests), prettier clean, vite build OK
  • Docker image builds (Node 22, npm ci)
  • E2E with the built image: API exits with SESSION_SECRET is not set when missing; with api + daemon running /healthz = 200 and reports the heartbeat age; /api/* without the cookie = 403 turnstile_required; SPA = 200; a stale heartbeat gives 503; researcher / workspace_member are gone

🤖 Generated with Claude Code

Access
- Remove the unwired HTTP Basic login: app/auth.py, scripts/create_researcher.py,
  the researcher/workspace_member tables (dropped on startup) and their db helpers,
  and argon2-cffi. Per-browser boards (X-Board-Id -> workspace) are unchanged.
- SESSION_SECRET is now required: the API refuses to start without it instead of
  falling back to a guessable key that would make the Turnstile cookie forgeable.
- Docs describe Turnstile (a bot check, not a login) as the only gate.

Cleanup
- Delete scripts/export_csv.py (crashed on a bad kwarg; the Export button covers
  it) and the db_path parameter only it used.
- Drop the SQLite-era `?` placeholder shim (_ph, _TxnConn, _WriteTxn); queries use
  psycopg's %s directly and write_txn() is a pooled connection.
- Frontend: axios -> a small fetch wrapper with the same api.get/post shape, plus
  a test for it. Drop the ngrok header.
- Daemon: requests -> httpx (already a dependency).
- Fold GOAL_TIMELINE/ROLLUP/RUBRIC_ENABLED (never set anywhere) into
  GOAL_BATTERY_ENABLED, which the rollup and rubric reuse.
- Remove requirements.txt, the unused MAX_STUDENT_IDS, stale SQLite wording and
  the old luc-dashboard name.

Operations
- /healthz checks the database and a daemon heartbeat (stamped every 10s on every
  tick) and returns 503 once it is older than 120s.
- Pin postgres:18 in compose (matches prod) and CI; Node 22 in the image, dev
  compose and CI; the image installs with npm ci from the lockfile.
- make install initializes and installs the engine submodule.
- Split the goal evidence panel out of CohortDashboard.jsx into GoalEvidence.jsx.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant