fix(judging): relax per-action signing; accept publish statement server-side#177
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
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_STATEMENTSallowlist (server/api/auth/statements.js). The server'svalidateStatementrejected 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 session — except publishing results, which keeps a deliberate fresh signature (it's irreversible + public).
getAuth), no popup.signPaymentAction).signPublishAction, renamed fromsignWinnerAction).'Publish results on Stadium'toVALID_STATEMENTSso the one remaining fresh-signed action is accepted. New assertion instatements.test.jsdocuments the client↔server statement contract.mark-paid/award-prize/confirm-paymentSIWS actions fromsiwsUtils.ts.Test plan
cd server && npm test→ 397 passed (incl. the publish-statement assertion).cd client && npm run build && npm run lint→ clean.🤖 Generated with Claude Code