Add expiring share links with per-document revocation #5
Loading…
Reference in a new issue
No description provided.
Delete branch "d/share-links"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
SAS-style HMAC share links: pick 1h, 24h or 7d on the document page or via the share_document tool, anyone with the link can fetch the file until expiry, and a per-document generation in the cache database lets you kill all outstanding links at once.
🤖 Claude AI Code Review
Summary
Adds stateless HMAC share tokens with per-document generation-based revocation, exposed via a web menu, an anonymous
/share/*endpoint, and MCP tools. Design is clean and well-tested.Code Quality ⭐⭐⭐⭐☆
Solid crypto hygiene (FixedTimeEquals, constant 404 oracle, bounded expiry) and thorough tests including tamper/malformed cases.
Issues
🟡 ShareLinkBuilder.cs — no minimum length / entropy check on
SigningKey. A short or weak configured key silently weakens the HMAC. Consider rejecting keys below a sane length at startup, otherwise sharing may be effectively forgeable with a misconfigured secret.🟢 ShareGenerationStore.cs —
BumpAsynccan throw on a race (two concurrent bumps inserting the sameDocumentIdprimary key). Low impact since revocation is rarely concurrent, but a unique-constraint violation would surface as an unhandled exception. Consider catch-and-retry or upsert.🟢 Program.cs (share endpoint) — the
/share/*endpoint has no rate limiting. Since every failure returns 404 with a full HMAC verification per request, it's a mild DoS/oracle-timing surface. Not blocking given the constant-time compare, but worth noting for a public anonymous endpoint.The generation-check-after-signature ordering, the
ValueGeneratedNeveron Paperless-assigned IDs, and the disabled-when-unset behavior are all correct. The flagged items are hardening improvements, not blockers.📊 Tokens: 13619 input + 581 output | 💰 Cost: ~$0.0826
Generated by Claude Opus 4.8 via Gitea Actions