Previously the shared account's libraries were chosen independently of its members, so a group could see a library that one of its members was blocked from - joining a group became a way to gain access. That was especially sharp with auto-created groups, where no admin is in the loop. A shared account is now granted exactly the libraries every member can already reach. If one member is blocked from a library, no group containing them can see it. The account is therefore always a subset of what each member could reach alone, which is what makes creating groups at the login screen safe to leave on by default. Details: - "Enable all folders" is expanded to concrete library ids before intersecting, since it cannot otherwise be compared with an explicit list. Shared accounts are always given an explicit list, never the all-folders permission, so newly added libraries do not silently widen an existing group. - Explicitly blocked folders are subtracted even for members who otherwise have access to everything. - Fails closed: an unresolvable member contributes no access rather than being treated as unrestricted. - Recomputed when membership changes, and re-applied to every group at startup so narrowing a member's own access narrows their groups. Drops the now-meaningless EnableAllFolders/EnabledFolders provisioning inputs and the DynamicGroupsEnableAllFolders setting. Adds 8 tests covering the intersection rules.
30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Jellyfin.Plugin.WatchedTogether.Services;
|
|
|
|
/// <summary>
|
|
/// Computes and applies the library access a shared account should have.
|
|
/// </summary>
|
|
public interface ILibraryAccessService
|
|
{
|
|
/// <summary>
|
|
/// Computes the set of libraries every one of the given members can reach.
|
|
/// </summary>
|
|
/// <param name="memberIds">The members to intersect.</param>
|
|
/// <returns>
|
|
/// The library identifiers common to all members. An empty set means the members have no
|
|
/// library in common, and the shared account should see nothing.
|
|
/// </returns>
|
|
IReadOnlyList<Guid> ComputeIntersection(IReadOnlyList<Guid> memberIds);
|
|
|
|
/// <summary>
|
|
/// Recomputes the intersection for a group and writes it to its shared account.
|
|
/// </summary>
|
|
/// <param name="sharedUserId">The shared account to update.</param>
|
|
/// <param name="memberIds">The group's members.</param>
|
|
/// <returns>The libraries granted to the shared account.</returns>
|
|
Task<IReadOnlyList<Guid>> ApplyIntersectionAsync(Guid sharedUserId, IReadOnlyList<Guid> memberIds);
|
|
}
|