Repository navigation
fix(jellycompat): enforce account-level library restrictions - #72
Conversation
The compat AccessFilterFn re-implemented a subset of the access policy and never loaded users.library_ids, so admin-assigned account library restrictions did not apply to the Jellyfin-compat API: restricted users could list, browse, search, and play items from every enabled library. Replace the hand-rolled closure with the shared access.Resolver via a new jellycompat.NewScopeAccessFilter adapter so account restrictions, profile restrictions, user-disabled libraries, and rating/quality ceilings apply exactly as on the native API. PIN verification is skipped because compat login already verifies profile PINs. Also: fail closed (empty allowlist) when scope resolution errors instead of returning an unrestricted filter; treat an empty allowlist as restricted-to-nothing in ListUserLibraries instead of unrestricted; and hide user-disabled libraries from the compat views list.
Extract a folderListSource interface for the two FolderRepository methods directContentService uses (matching the existing browseSource/ itemAccessSource pattern) so ListUserLibraries is unit-testable, and add coverage for the restricted-allowlist path and the user-disabled library filtering in the views list.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR delegates Jellyfin compat library access filtering to the shared ChangesAccount-level library restrictions for Jellyfin compat layer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
* fix(jellycompat): enforce account-level library restrictions The compat AccessFilterFn re-implemented a subset of the access policy and never loaded users.library_ids, so admin-assigned account library restrictions did not apply to the Jellyfin-compat API: restricted users could list, browse, search, and play items from every enabled library. Replace the hand-rolled closure with the shared access.Resolver via a new jellycompat.NewScopeAccessFilter adapter so account restrictions, profile restrictions, user-disabled libraries, and rating/quality ceilings apply exactly as on the native API. PIN verification is skipped because compat login already verifies profile PINs. Also: fail closed (empty allowlist) when scope resolution errors instead of returning an unrestricted filter; treat an empty allowlist as restricted-to-nothing in ListUserLibraries instead of unrestricted; and hide user-disabled libraries from the compat views list. * test(jellycompat): cover library list filtering via folder source stub Extract a folderListSource interface for the two FolderRepository methods directContentService uses (matching the existing browseSource/ itemAccessSource pattern) so ListUserLibraries is unit-testable, and add coverage for the restricted-allowlist path and the user-disabled library filtering in the views list.
* fix(jellycompat): enforce account-level library restrictions The compat AccessFilterFn re-implemented a subset of the access policy and never loaded users.library_ids, so admin-assigned account library restrictions did not apply to the Jellyfin-compat API: restricted users could list, browse, search, and play items from every enabled library. Replace the hand-rolled closure with the shared access.Resolver via a new jellycompat.NewScopeAccessFilter adapter so account restrictions, profile restrictions, user-disabled libraries, and rating/quality ceilings apply exactly as on the native API. PIN verification is skipped because compat login already verifies profile PINs. Also: fail closed (empty allowlist) when scope resolution errors instead of returning an unrestricted filter; treat an empty allowlist as restricted-to-nothing in ListUserLibraries instead of unrestricted; and hide user-disabled libraries from the compat views list. * test(jellycompat): cover library list filtering via folder source stub Extract a folderListSource interface for the two FolderRepository methods directContentService uses (matching the existing browseSource/ itemAccessSource pattern) so ListUserLibraries is unit-testable, and add coverage for the restricted-allowlist path and the user-disabled library filtering in the views list.
Fixes #71.
Problem
The Jellyfin-compat API ignores account-level library restrictions (
users.library_ids).The compat
AccessFilterFnwired up incmd/silo/main.gowas a hand-rolled partialre-implementation of the access policy that only considered:
profile.library_restrictions_enabled+ allowed ids), anddisabled_library_idssetting.It never loaded the user row, so the admin-assigned per-account library allowlist —
the primary mechanism for restricting what a user can see — was silently dropped.
Every compat session (Infuse, Findroid, VidHub, jellyfin-web, …) could list, browse,
search, and play items from all enabled libraries, including libraries the admin
had explicitly not granted to that account. The native API applies these restrictions
correctly via
access.Resolver, so the two APIs disagreed about the same viewer.Additional smaller gaps in the same code path:
(
len > 0check), both in the filter construction and inListUserLibraries;MaxPlaybackQualityceilings (account and profile) were never propagatedto the compat filter;
mid-session) failed open, returning an unrestricted filter;
ListUserLibrariesnever appliedDisabledLibraryIDs, so an unrestricteduser's hidden libraries still appeared as compat views.
Fix
Replace the duplicated closure with the shared
access.Resolver— the samecomponent the native API and the requests entitlement path already use — via a
new
jellycompat.NewScopeAccessFilter(resolver)adapter:library_ids∩ profile restrictions ∩ user-disabled libraries nowapply to every compat surface that consumes the access filter (views,
virtual folders, browse, search, item detail, images, recommendations,
playback);
MaxContentRatingandMaxPlaybackQualityceilings propagate like on thenative API;
SkipPINVerification: true) because compatlogin already verifies profile PINs via the
password#pinconvention;ListUserLibrariesdistinguishes nil (unrestricted) from empty(restricted-to-nothing) allowlists and filters disabled libraries.
Anything to watch out for
users.max_playback_quality/ profile quality caps were only enforced onthe native API; compat clients (Infuse, Findroid, VidHub, …) saw and played
every file version. After this change a capped viewer loses access to
file versions above their ceiling on compat clients too — same behavior
as the native API. Deployments that relied (accidentally) on the compat
API ignoring quality caps will see capped users restricted there as well.
user store is unavailable or a session references a deleted profile, the
viewer gets an empty library allowlist for that request instead of an
unrestricted catalog.
compat API (previously: all libraries).
How it was tested
fail-closed on resolver error, empty-allowlist
ListUserLibraries;go build ./cmd/... ./internal/...,go vet, fullgo test ./internal/jellycompat/pass;(
library_idsexcluding one library) no longer sees the withheld libraryvia
/Users/{id}/Viewsor search on the compat API; toggling the libraryin the account's allowlist removes/restores it on the compat layer
immediately, and an unrestricted admin account still sees everything.
Implementation was AI-assisted (Claude); I've read the full diff, and the behavior was verified live before submitting.
Summary by CodeRabbit