Repository navigation
fix(audiobooks): scope Audiobookshelf collections, playlists and session detail to the profile - #2799
Conversation
…ion detail to the profile Collection entries took their libraryId from the server's first audiobook library, because collectionBooks resolved the default library without the caller's access filter. resolveDefaultLibrary now requires the filter. Collection, playlist and library filter responses discarded the error from access resolution, and an unresolved filter means no restriction. Handlers now resolve access once, before any read or write, and refuse the request with 403 (logged at Warn) when it fails; the filter is passed to the render helpers. resolveLibrary returns the filter it authorized the library with, so library handlers no longer resolve it twice. Playlist creation no longer commits before the access check. Listening-session detail now requires the same account and profile, like the session list and sync routes already do. Closes #2795 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 8
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
#1247 C2 is Not run, not failed or blocked, so this PR does not unblock a recorded result. The changed ABS handlers alter the permissions and response data that C2 covers; the case should be validated after merge. Collection and playlist responses still include stubs for out-of-scope member IDs, so this change does not clear the whole profile-access criterion. For this major change, the PR should explain why the permissions and returned data change; the Approach section already gives the intended rationale. C2 has no prior run, so plan its first validation after merge. Suggested fix: -Validation tasks: unblocks #1247 C2
+Validation tasks: changes #1247 C2Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
…-gaps # Conflicts: # internal/audiobooks/abs/listening_stats_handler_test.go
|
Review summary (reviewed head No defects found. I merged What I checked
Tests. All three changed tests fail on the base for the reasons the PR gives:
Cross-provider review. One read-only gpt-6.1-sol round on Validated features. No passed case on the v1.0 board is reachable from this diff. #1247 C2 (Audiobookshelf restrictions match native enforcement) hasn't been run, so User manual. Unaffected. The Audiobookshelf beta page covers sign-in and choosing a profile. It says nothing about which collections, playlists, or sessions a profile sees. Apple/Android. Not applicable. These routes serve third-party Audiobookshelf apps. Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
|
Problem
Closes #2795
Related issue: N/A
Validation tasks: unblocks #1247 C2
Several Audiobookshelf-compatible endpoints returned data outside the signed-in profile's scope. Collection entries carried the server's first audiobook library as
libraryId, even for a profile that can't see that library. When access resolution failed, collection, playlist and library filter responses fell back to an empty access filter, which means no restriction. And a profile could read another profile's listening session on the same account by its ID. This affects Audiobookshelf apps on accounts with more than one profile, a beta surface.Approach
resolveDefaultLibrarynow requires the caller's access filter, so no caller can fall back to the server-wide first library.resolveLibraryreturns the filter it authorized the library with. Library detail, items, authors, series, search and personalized shelves use that filter instead of resolving it a second time, so library filter data can't run with a different or empty scope.GET /me/listening-sessions/{sid}requires the same account and profile (sameABSPrincipal), matching the session list and the sync routes.Native API, web, Apple, Android and Jellyfin surfaces are unaffected.
login.gois left to #2793, which fixes its own discarded access error.Validation
mainand pass here: collectionlibraryIdfollows a profile restricted to the second library; collection, library collection list, playlist and playlist creation return 403 with no catalog data and no write when the access resolver errors; another profile on the same account gets 404 for a session.go test ./internal/audiobooks/...,go build ./...,gofmt,go vet,make lint-changed,make lint-router-recovery, and the local-path, bidi, size-ratchet and route-inventory checks pass.make test-goon a fresh database: the failures are in packages that don't importinternal/audiobooks/abs(DB-backed suites run while other jobs shared the database) plus the knownTestRecordOutcomeClearsTheParkedRetry.mainand by the tests above.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-2795/
Risks
While access resolution fails, collection and playlist calls, including removals and renames, now return 403 instead of succeeding with unscoped data. Deleting a whole collection or playlist still works, since it reads no catalog data. ABS clients already get 403 from library and item routes in the same condition.
Follow-ups
libraryItemin playlists. Whether to hide them is a product decision, noted in [bug] Audiobookshelf collections, playlists and session detail ignore the profile's library scope #2795.Checklist
AI Disclosure
libraryItem) are outside this issue. A multi-agent code review of the final diff found the second access lookup in library detail, now removed, and the rest was answered above. A background gpt-6.1-sol adversarial review of this PR at 616ccfd reported no findings. It reviewed the source only; it could not run the tests in its read-only sandbox.🤖 Generated with Claude Code