Repository navigation
feat(collections): limit shared personal collections to what their owner can access - #1873
Conversation
…ibraries A shared personal collection is limited to what its owner can access. The owner's hidden libraries are a browsing preference, not access, so they must not shrink what the collection shows other profiles. ContentAccessOnly leaves them out of both the legacy resolver and the policy-backed viewer resolver. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…m its owner catalog.IntersectAccess limits a viewer's filter to an owner's libraries and maturity limits, keeping the viewer's identity, hidden libraries and presentation. usercollections.OwnerAccess resolves the owner's content access on every call, with no PIN check and no cross-request cache. catalog.PersonalCollectionFilter short-circuits a profile's own collections and fails closed when another owner cannot be resolved. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ner can access A profile reading another profile's shared collection now sees only the titles both can access, on every read path: listing and detail counts, item pages, the catalog user_collection source and cursor, home rows, and the library Collections tab. Own collections skip the owner lookup; a listing resolves each other owner once, pinned by a DB budget test. If an owner cannot be resolved, listings drop that collection and reads of it fail rather than falling back to the viewer's access. Refs #1615. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The catalog filters and facet search for a user_collection source build their values from the collection's members, so they must follow the same owner-and-viewer limit as the item reads. No test exercised that path, and dropping the limit there went unnoticed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
GET /api/v1/collections/{id}/items returned every stored member ID, so a
profile reading another profile's shared collection saw IDs of titles
outside its own access and outside the owner's. The bridge list now keeps
only the members the reader can access, limited to the owner's access for
another profile's collection, the same rule as every other read. Hidden
members stay stored.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The order editor built its list from the counted collection listing, which leaves out a shared collection whose owner's access cannot be resolved. The store still orders that row, so a client submitting the list it was given got 422. Ordering reads no members, so the editor now lists the profile's collections straight from the store. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…sect as lists IntersectAccess intersects the owner's and viewer's allowed library lists, so a title in two libraries, one allowed to each profile, is hidden from a shared collection although both can open it. Document the limit and pin that it fails closed, so a later per-title check changes the test on purpose. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e47c1f1de2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| } | ||
| // Another profile's collection shows only what its owner can access too. | ||
| filter, err = catalog.PersonalCollectionFilter(ctx, f.CollectionOwners, filter, userID, profileID, collection.CreatorProfileID) |
There was a problem hiding this comment.
Preserve owner library limits in home collection rails
When both profiles are library-restricted and the owner has a narrower or different allowlist, the home-section path still exposes manual collection members from libraries the owner cannot access. loadResolvedHomeSections passes the viewer's original non-nil libraryIDs; after this line intersects filter with the owner's access, the sorted branch's collectionRailQueryAccess and the unsorted branch's fetchItemsByContentIDs prefer that original slice and effectively replace the narrowed allowlist. Intersect the section library scope with the owner-scoped filter before either manual branch; the new tests currently pass nil for libraryIDs, so they do not cover this production path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1ed894a and ee3a0cc. Home rows now intersect the section library scope with the owner-narrowed allowlist before both manual branches, and an empty scope stays non-nil so it still denies (that also closes a sorted-rail hole for a profile allowed no library). Review found the smart path could widen too when a query's libraries share none with the allowlist; the executor now adds 1 = 0 in that case, and a disjoint section scope returns an empty row. The DB test now drives the production home path with non-nil viewer libraryIDs, sorted and unsorted manual collections, and smart collections outside the allowed libraries; it fails without the fix.
|
The recorded Server cases S2–S4 need re-validation after merge. This is a major behavior change: collection counts and personal-collection member/catalog reads now apply the owner’s access filter, so a stricter owner can reduce the displayed members and counts. The recorded build 927/1012 scenarios used an unrestricted owner for the shared collection and do not cover that result. The PR explains the intended policy; it should also make clear that these prior results need re-validation after merge. The owner-access portions of #193 S7 and Web #195 W7 are partly unblocked: their member/count data can now be checked. The full cases remain blocked because this PR does not add the all-profiles sharing switch, owner-only edits/reordering, or the Web “Your collections”/“Shared with me” UI. S6 remains partial: this changes the order-editor read path, not the cross-profile reorder mutation behind #1616. Suggested Validation tasks line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Validation line updated to |
…s libraries The home page passes the viewer's allowed libraries as the row's library scope, and the manual collection lookups prefer that scope over the owner-narrowed access filter. A library-restricted viewer therefore saw members from libraries the owner cannot access. Limit the scope to the narrowed filter before the manual lookups. collectionRailQueryAccess also turned an empty library scope into nil, which is unrestricted, so a sorted collection row showed every member to a viewer allowed no library. Keep the empty scope non-nil. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…wed list When a query's own library_ids shared no library with the reader's allowed libraries, the empty intersection dropped the library predicate and the query ran across every library. A shared smart collection scoped to a library its owner cannot access then showed the viewer titles from every library on the home row, catalog source, items page and counts. Deny the query instead whenever a non-nil allowed list leaves no library. Section rows had the same hole one level up: a section scope disjoint from the query's libraries cleared def.LibraryIDs, which reads as every library. Return an empty row instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…cess # Conflicts: # internal/catalog/query_executor.go # internal/catalog/query_executor_access_test.go
…'s access Build on the collections revamp so personal BoxSets follow Silo-Server#1873: a collection another profile shares shows each viewer only the titles its owner can access too. The Jellyfin catalog resolver gets the same owner access as the native routes, and BoxSet counts use the revamp's owner-scoped count, now shared from the catalog package. A collection whose owner cannot be resolved is left out of listings and Ids re-hydration, and its detail route errors, as on the native routes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Related issue: #1615
Validation tasks: changes #193 S2, S3, S4; partly unblocks #193 S7, #195 W7
When a profile shares a personal collection with another profile on the same login, the viewer sees every member it can access itself, whatever the owner's limits are. A PG profile's smart collection, shared with an unrestricted profile, lists titles rated above PG. A manual collection keeps showing titles from a library its owner has since lost. #1615 says a shared collection carries its owner's restrictions: each viewer sees only the titles both the owner and the viewer can access. This change applies that rule everywhere a personal collection's members or count are read. Who can see a collection still comes from today's per-profile sharing lists. Showing shared collections to every profile on the login, owner-only ordering and removing personal collection groups are later #1615 changes.
It also closes a gap in the
/api/v1bridge.GET /api/v1/collections/{id}/itemsreturned every stored member ID of a visible collection, including titles neither the owner nor the viewer can access. It now returns only the members the reader can access, with the owner's limit applied to another profile's collection.The recorded #193 S2 and S3 results should still hold. Their shared collection had an unrestricted owner and a PG viewer, and the owner's limit leaves that case unchanged. A restricted owner, the case this changes, was not covered. S7 also needs the rest of #1615.
#193 S2, S3 and S4 were recorded with an unrestricted owner. Counts and members of another profile's shared collection now also depend on the owner's access, so a stricter owner shows fewer titles than those runs did. All three need a re-test after merge.
Approach
On each read of another profile's collection, the server resolves the owner's access with the same resolver the request gates use, without the owner's PIN. It combines that with the viewer's access. Allowed libraries intersect, the stricter rating ceiling and the smaller advisory-age limit apply, and if either side requires an advisory age, unadvised titles are hidden. Everything else stays the viewer's, including the viewer's hidden libraries, the unrated-title policy and presentation settings.
Per the maintainer's decision on Personal collections: owner-only management and a single share-with-all-profiles switch #1615, libraries the owner hides from its own browsing don't count as a limit.
access.ResolveInputgainsContentAccessOnly, which both the policy resolver and the legacy resolver honor.Also per that decision, smart rules on watch state, favorites and watchlist, and display filters, still use the viewer's own data. A shared collection never reveals the owner's activity.
The limit applies to:
item_countin the collection list and detail/api/v2item pagesuser_collectionsource, which serves the collection page, its filters and its facetsManual members the owner can't access are hidden, not deleted, and they come back when the owner's access does.
A profile reading its own collection needs no extra lookup. A listing resolves each other owner once per request. Nothing is cached between requests, so a change to an owner's access applies on every node at the next read.
It fails closed. If an owner can't be resolved, listings and the library tab leave that collection out and log a warning. Detail, item pages and the catalog source answer 500, and the collection's home row comes back empty. The server never falls back to the viewer's access alone.
The order editor now reads collections directly from the store instead of from the counted listing. That way a failed owner lookup can't drop a collection from the order and cause a 422 on the client's submitted order.
Library limits intersect as lists, not title by title. Take a title linked into two libraries, where the owner may open only one and the viewer only the other. The shared collection hides that title, even though each profile can open it on its own. This errs toward hiding. A per-title check would need a second library condition on every catalog read path. A DB test records this behavior.
Validation
Go build,
gofmt,go vet ./...andmake lint-changedagainst the base branch: clean.make test-go: pass.DB-backed tests on a freshly migrated PostgreSQL database, for the changed packages and their dependents (access, policy, usercollections, sections, catalog, api, handlers, apiv2, userstore, jellycompat, recommendations): pass, except three that fail the same way on the base branch.
TestAdminSubtitleListPageDBandTestCatalogTransferPersistsJobsAndSignedLinkfail on timezone comparisons, andTestOrphanCleanupAfterPlexTableDropPostgresfails on a fixture that leavesusers.roleempty.The new DB tests use the production policy resolver and real profiles. They run manual, smart and display-filtered collections through every surface listed above, with these owner and viewer setups:
They fail if the owner's limit is removed from the item path or the filters path, or if
ContentAccessOnlyis ignored. They also pass under-race.make test-db-pins: every pin passes. That includes a new one checking that a listing resolves each other owner once and that a profile's own collections need no owner lookup.Contract and generated artifacts:
verify-apiv2-openapi,verify-apiv2-contract(no difference from the base),verify-apiv2-fixtures,TestCommittedArtifactMatchesRouter,verify-route-inventory,verify-migration-ledger,verify-scenario-catalogs,verify-offline-routes,verify-settings-bindings,verify-playback-fixturesandverify-local-pathsall pass.Not run: the web checks, because no web files change, and
verify-apiv2-web-types, because the contract doesn't change. Nobody has walked Collections — Server #193 S2, S3, S4 or S7 on a running server.Risks
/api/v2's schema doesn't change, so shipped Apple and Android builds need no update. Viewers of a shared collection can now see fewer members and a smalleritem_count./api/v1,GET /collections/{id}/itemsnow leaves out members the reader can't access, including for the owner, as/api/v2item pages already do. This is a bridge security fix under the v1 freeze.item_countin the list and detail is still the stored count, with neither the owner's nor the viewer's limit applied. Item pages and catalog reads on that store apply both. This predates the change.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Limit shared personal collections to what their owner can access
usercollections.OwnerAccessadapter that resolves the collection owner's content access (allowed libraries and maturity limits, skipping PIN and hidden-library preferences) on each call, and wires it into collection, catalog, section, library, and items handlers.narrowLibraryScopeandapplySectionLibraryScopeToQuery, so disjoint scopes return no items instead of widening access.access.ResolveInputgains aContentAccessOnlyflag so owner lookups ignore UI-hidden libraries;access.Resolver.Resolveandpolicy.ViewerResolver.ResolveFactshonor it.ownerScopedCollectionCountsandFetcher.fetchUserCollectionin fetcher.go.Macroscope summarized a21f7a7.