Repository navigation
fix: guard unauthenticated /api/v1/share POST and DELETE endpoints - #400
Merged
Merged
Conversation
) The POST /share (persists a share link + mints OSC delegate tokens) and DELETE /share/:id (revokes a share link) mutating endpoints were missing the requireApiKey preHandler that guards every other management-plane mutation. Add the existing, already-tested guard to both routes. The public GET /share/:id redemption endpoint stays unauthenticated so recipients can still open share links. Add src/api_share_auth_guard.test.ts asserting the two mutating routes return 401 when unauthenticated, the GET redemption route stays public, and an authenticated POST passes the guard. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
code-reviewer verdict: LGTM (self-authored PR — recorded as a marker since GitHub blocks state-bearing self-review). Zero Blocking, zero Warnings. The fix adds the existing |
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
requireApiKeypreHandler toPOST /api/v1/shareandDELETE /api/v1/share/:idinsrc/api_share.ts, closing an auth gap where any network-reachable client could mint OSC delegate tokens or revoke arbitrary share links even withAPI_KEYset (Security: guard unauthenticated /api/v1/share mutation endpoints (POST + DELETE) #399).GET /api/v1/share/:idredemption endpoint unauthenticated — recipients must be able to open share links without a key.src/api_share_auth_guard.test.tscovering: unauthenticated POST/DELETE rejected with 401, GET still public, authenticated POST passes the guard (mirrorssrc/api_auth_guard.test.ts).Test plan
npx jest src/api_share_auth_guard.test.ts src/api_rate_limit.test.ts src/api_auth_guard.test.ts— 18 passed)npm run typecheck)npm run lint)POST /api/v1/shareandDELETE /api/v1/share/:idreturn 401 without a Bearer token whenAPI_KEYis set;GET /api/v1/share/:idstill redeemsCloses #399
🤖 Generated with Claude Code