fix(convex): stop leaking song file paths and gate library queries #99

Merged
joshuafhiggins merged 2 commits from t3/auth-song-queries into main 2026-11-16 21:53:43 -05:00
Owner

getSong was public and returned the full song document, including absolute server file paths, to anyone who could reach Convex. The streaming routes also called it without the listener's token, so the Next proxy was the only auth layer. Most browse and search queries had no auth either.

Changes

  • getSong stays public so share links and link previews keep working, but no longer returns files.
  • New getSongSource query returns file paths and requires auth. The play, HLS, and segment routes call it with the listener's token through lib/server-song.ts. Mobile sends the auth cookies, so it works the same way.
  • The HLS segment route now resolves the source on every request, so a cached job no longer skips the auth check.
  • Library browse, search, recently added, album/playlist summaries and tracks, and song-ID queries now require a session. Reactive queries return empty results when signed out, and imperative lookups throw.
  • These stay public on purpose: browseAlbumDetail, browseArtistDetail, and browsePlaylistDetail for /album, /artist, and /playlist share links, plus get{Album,Artist,Playlist}Cover, which now return only the cover path.
  • proxy.ts: replaced the stale /artists/:id public route with /library/artists/:id. Its metadata now uses the public browseArtistDetail query.

Verification

  • Web and mobile typecheck and web lint pass.
  • I haven't run it against a live backend, since that needs this Convex code deployed.

🤖 Generated with Claude Code (Claude Opus 5.5)

`getSong` was public and returned the full song document, including absolute server file paths, to anyone who could reach Convex. The streaming routes also called it without the listener's token, so the Next proxy was the only auth layer. Most browse and search queries had no auth either. **Changes** - `getSong` stays public so share links and link previews keep working, but no longer returns `files`. - New `getSongSource` query returns file paths and requires auth. The play, HLS, and segment routes call it with the listener's token through `lib/server-song.ts`. Mobile sends the auth cookies, so it works the same way. - The HLS segment route now resolves the source on every request, so a cached job no longer skips the auth check. - Library browse, search, recently added, album/playlist summaries and tracks, and song-ID queries now require a session. Reactive queries return empty results when signed out, and imperative lookups throw. - These stay public on purpose: `browseAlbumDetail`, `browseArtistDetail`, and `browsePlaylistDetail` for `/album`, `/artist`, and `/playlist` share links, plus `get{Album,Artist,Playlist}Cover`, which now return only the cover path. - `proxy.ts`: replaced the stale `/artists/:id` public route with `/library/artists/:id`. Its metadata now uses the public `browseArtistDetail` query. **Verification** - Web and mobile typecheck and web lint pass. - I haven't run it against a live backend, since that needs this Convex code deployed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) (Claude Opus 5.5)
joshuafhiggins added 1 commit 2026-11-16 14:10:52 -05:00
getSong stays public for share-link previews but no longer returns
files. Streaming routes load paths through getSongSource, which
requires auth and runs with the listener's token. Library browse,
search, and song-ID queries now require a session; album, artist,
and playlist detail plus cover lookups stay public for share links.
Fixes the stale /artists/:id public route in proxy.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joshuafhiggins added 1 commit 2026-11-16 21:53:38 -05:00
# Conflicts:
#	apps/web/app/api/song/[id]/play/route.ts
#	apps/web/lib/server-hls.ts
#	packages/convex/convex/library.ts
#	packages/convex/convex/playlists.ts
joshuafhiggins merged commit 5c94c45b69 into main 2026-11-16 21:53:43 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joshuafhiggins/otunes#99