Persist the signed download token in files.token#18
Merged
Conversation
The api's dropbox.List builds download URLs but has no sign_key, so it
could only emit the bare fn — which /files/{fn} rejects in parseToken
(no HMAC), giving a dead link. Store the full signed token at upload
time so dropbox.List can rebuild the working URL as base_url + token.
- schema/03_token.sql migration + schema.sql add `token text not null
default ''` (default keeps the migration safe for existing rows; they
self-expire within the 7-day max TTL).
- uploadHandler computes the token once, writes it, and reuses it for
the response downloadUrl.
Co-Authored-By: Claude Opus 4.7 <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
fn-{hmac}) in a newfiles.tokencolumn at upload time, so the api'sdropbox.Listcan rebuild working download URLs without holdingsign_key.Why
PR #17 made the HMAC signature mandatory:
GET /files/{token}runsparseTokenfirst and 404s anything without a valid tag. Butdropbox.List(in apiserver) builds itsdownloadUrlfrom the barefn— it has nosign_key, so every link it returns is a dead/files/{fn}that fails the HMAC check. Persisting the token dropbox already computes is the simplest fix; the alternative (sharingsign_keywith the api) couples key rotation across services.How
schema/03_token.sql+schema.sql: addtoken text not null default ''. The default keeps the migration safe for existing rows — they carry an empty token until they self-expire (≤7-day max TTL), which is no worse than today (links are already broken).uploadHandlercomputes the token once, writes it to the new column, and reuses it for the responsedownloadUrl(previously recomputed inline).Schema migration
(dropbox's
schema/*.sqlmigrator is not run at startup — apply out-of-band, same as other columns.)Deploy ordering
token.tokenfordropbox.List.Test plan
go test ./...passesTestUpload_Successnow asserts the token indownloadUrlis persisted verbatim tofiles.token.🤖 Generated with Claude Code