Skip to content

fix(judging): relax per-action signing; accept publish statement server-side#177

Merged
sacha-l merged 1 commit into
developfrom
fix/relax-admin-signing
Jun 14, 2026
Merged

fix(judging): relax per-action signing; accept publish statement server-side#177
sacha-l merged 1 commit into
developfrom
fix/relax-admin-signing

Conversation

@sacha-l

@sacha-l sacha-l commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes the "couldn't update results: invalid statement in SIWS message" error admins hit on award/publish, and relaxes the over-eager per-action signing.

Root cause (regression from #173)

The client signs award/publish/mark-paid with new SIWS statements (e.g. "Publish results on Stadium"), but those were never added to the server's VALID_STATEMENTS allowlist (server/api/auth/statements.js). The server's validateStatement rejected them → 403. The mock tester couldn't catch it (mock mode short-circuits the API, so the real server validator is never exercised).

New model: sign once, then ride the session — except publish

Per request: an admin signs once to open the session (the "LOAD ADMIN DATA" step already mints a 15-min cached bearer), then every action rides that sessionexcept publishing results, which keeps a deliberate fresh signature (it's irreversible + public).

  • Award prize, mark paid → cached session (getAuth), no popup.
  • m2 confirm-payment → cached bearer (reverted; removed signPaymentAction).
  • Publish results → fresh signature (signPublishAction, renamed from signWinnerAction).
  • Server: added 'Publish results on Stadium' to VALID_STATEMENTS so the one remaining fresh-signed action is accepted. New assertion in statements.test.js documents the client↔server statement contract.
  • Dropped the now-unused mark-paid/award-prize/confirm-payment SIWS actions from siwsUtils.ts.

Test plan

  • cd server && npm test397 passed (incl. the publish-statement assertion).
  • cd client && npm run build && npm run lint → clean.
  • Post-deploy on prod: as admin, open program → LOAD ADMIN DATA (one sign) → award a prize (no popup) → mark paid (no popup) → Publish results (fresh signature) → succeeds (no "invalid statement").

🤖 Generated with Claude Code

…ver-side

Two issues from the must-sign work (#173):
1. REGRESSION: the client signs award/publish/mark-paid with new SIWS statements
   that were never added to the server's VALID_STATEMENTS allowlist, so the server
   rejected them with 'Invalid statement in SIWS message' — admins couldn't award
   prizes or publish. (Mock tests couldn't catch it: mock mode never hits the real
   server validator.)
2. The per-action signing was too much friction.

New model: sign once to open the admin session (the LOAD ADMIN DATA step mints a
cached bearer), then every action rides it — EXCEPT publishing results, which
keeps a deliberate fresh signature (irreversible + public).

- ProgramJudgingSection: award + mark-paid now use the cached session (getAuth);
  only publish uses a fresh signature (signPublishAction prop, was signWinnerAction).
- m2 confirm-payment (AdminPage M1/M2 handlers + WinnersTable) reverts to the cached
  bearer; removed the signPaymentAction prop.
- siwsUtils: drop the unused mark-paid/award-prize/confirm-payment actions, keep
  publish-results.
- server/api/auth/statements.js: add 'Publish results on Stadium' to VALID_STATEMENTS
  so the one remaining fresh-signed action is accepted. Covered by statements.test.js.

Server suite green (397); client build + lint clean.
@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stadium Ready Ready Preview, Comment Jun 14, 2026 11:41am

@sacha-l sacha-l marked this pull request as ready for review June 14, 2026 12:10
@sacha-l sacha-l merged commit cfc5a74 into develop Jun 14, 2026
2 checks passed
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