A shared account previously inherited its members' library access but none of their content restrictions, so a child could log into "alice+kid" with their own password and get around their own rating cap. The shared account now gets the strictest member's parental rating, unrated-item block, blocked tags and allowed tags, recomputed at creation, on membership change and at startup. An admin can raise the rating cap on a slider between the strictest and the loosest member; unrated and tag rules stay strictest-wins. What makes raising the cap safe is the unlock rule: after a member's password matches, both users' live policies are compared and the login is refused if the account is looser than the member on any field. So raising the cap above the child's rating means the child's password no longer opens the account, while the parent's still does. The same rule bounds the slider - past the loosest member nobody could unlock the account - so a chosen cap is clamped back into range whenever applied. Allowed tags need care: Jellyfin reads an empty list as "no whitelist", so an empty intersection of members' whitelists is written as a sentinel tag no item carries. Access schedules and channels are not inherited yet. The shared account is never an administrator. Groups created at the login screen always inherit and are restricted before the first session exists. The dashboard shows each member's cap, who a chosen cap shuts out, and the restrictions in effect, and gains a per-group edit form for the sync options. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
42 lines
2.0 KiB
C#
42 lines
2.0 KiB
C#
using System;
|
|
using Jellyfin.Plugin.WatchedTogether.Auth;
|
|
using Jellyfin.Plugin.WatchedTogether.Services;
|
|
using MediaBrowser.Controller;
|
|
using MediaBrowser.Controller.Authentication;
|
|
using MediaBrowser.Controller.Plugins;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Jellyfin.Plugin.WatchedTogether;
|
|
|
|
/// <summary>
|
|
/// Registers the plugin's services with the host.
|
|
/// </summary>
|
|
public class ServiceRegistrator : IPluginServiceRegistrator
|
|
{
|
|
/// <inheritdoc />
|
|
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
|
{
|
|
serviceCollection.AddSingleton<IGroupService, GroupService>();
|
|
serviceCollection.AddSingleton<ILibraryAccessService, LibraryAccessService>();
|
|
serviceCollection.AddSingleton<IRestrictionService, RestrictionService>();
|
|
serviceCollection.AddSingleton<IProvisioningService, ProvisioningService>();
|
|
serviceCollection.AddSingleton<IDynamicGroupService, DynamicGroupService>();
|
|
|
|
// The auth provider takes these lazily so the container can build it while IUserManager is
|
|
// still under construction; see SharedAccountAuthenticationProvider's constructor remarks.
|
|
// Microsoft's container has no built-in Lazy<T> support, so the factories are explicit.
|
|
serviceCollection.AddSingleton(
|
|
provider => new Lazy<IGroupService>(provider.GetRequiredService<IGroupService>));
|
|
serviceCollection.AddSingleton(
|
|
provider => new Lazy<IDynamicGroupService>(provider.GetRequiredService<IDynamicGroupService>));
|
|
serviceCollection.AddSingleton(
|
|
provider => new Lazy<IRestrictionService>(provider.GetRequiredService<IRestrictionService>));
|
|
|
|
// Discovered by Jellyfin and matched to shared accounts via User.AuthenticationProviderId.
|
|
serviceCollection.AddSingleton<IAuthenticationProvider, SharedAccountAuthenticationProvider>();
|
|
|
|
serviceCollection.AddHostedService<WatchedStateSyncService>();
|
|
serviceCollection.AddHostedService<UserLifecycleService>();
|
|
}
|
|
}
|