feat: store and reuse the hosted-report writeToken on POST - #16
Open
serenakeyitan wants to merge 1 commit into
Open
feat: store and reuse the hosted-report writeToken on POST#16serenakeyitan wants to merge 1 commit into
serenakeyitan wants to merge 1 commit into
Conversation
The website API now binds report ids to their first publisher: the first POST for an id returns a one-time writeToken, and overwriting that id (same-day re-scan, latest-wins) requires it as a Bearer header — strangers can no longer rewrite a hosted report they didn't publish. Scanner side: save returned tokens to .production-scan/write-tokens.json, attach them when re-POSTing a claimed id, and recover from 401 by publishing under <id>-2 (same shape as the reserved-id 400 rule). Pairs with the website-side change in first-tree-website (src/pages/api/reports/index.ts — contract pair per Step 7). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
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
The website API now binds hosted-report ids to their first publisher (first-tree-website PR pairs with this one): the first POST for an id returns a one-time
writeToken, and every later POST of the same id — i.e. a same-day re-scan — must send it asAuthorization: Bearer <writeToken>or the API answers 401. This closes the hole where any anonymous caller could overwrite any hosted report.Scanner-side contract changes (Step 7 / Step 9.5 / checklist):
writeTokeninto.production-scan/write-tokens.json(created if missing). The token is shown exactly once.write-tokens.jsonholds a token for this id, attach the Bearer header.-2to the id and resubmit once (same recovery shape as the reserved-id 400 rule). Never re-send an identical 401 body..production-scan/stays gitignored; the tokens file is one more reason.Sequencing
Land soon after the website-side change deploys: until then, an old scanner doing a same-day rescan gets a 401 and falls back to the honest local-report path (no broken links, but the overwrite flow degrades).
Test plan
🤖 Generated with Claude Code