Update for Jellyfin 10.9

This commit is contained in:
Ersei Saggi
2024-05-13 09:17:42 -04:00
parent 19a6b49afa
commit 2e8c19d631
7 changed files with 100 additions and 91 deletions

View File

@@ -10,6 +10,7 @@ using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using Jellyfin.Plugin.SSO_Auth.Config; using Jellyfin.Plugin.SSO_Auth.Config;
using Jellyfin.Plugin.SSO_Auth.Helpers; using Jellyfin.Plugin.SSO_Auth.Helpers;
using MediaBrowser.Common.Api;
using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
@@ -327,7 +328,7 @@ public class SSOController : ControllerBase
/// </summary> /// </summary>
/// <param name="provider">The name of the provider to add.</param> /// <param name="provider">The name of the provider to add.</param>
/// <param name="config">The OID configuration (deserialized from a JSON post).</param> /// <param name="config">The OID configuration (deserialized from a JSON post).</param>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpPost("OID/Add/{provider}")] [HttpPost("OID/Add/{provider}")]
public void OidAdd(string provider, [FromBody] OidConfig config) public void OidAdd(string provider, [FromBody] OidConfig config)
{ {
@@ -340,7 +341,7 @@ public class SSOController : ControllerBase
/// Deletes an OpenID provider. /// Deletes an OpenID provider.
/// </summary> /// </summary>
/// <param name="provider">Name of provider to delete.</param> /// <param name="provider">Name of provider to delete.</param>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpGet("OID/Del/{provider}")] [HttpGet("OID/Del/{provider}")]
public void OidDel(string provider) public void OidDel(string provider)
{ {
@@ -353,7 +354,7 @@ public class SSOController : ControllerBase
/// Lists the OpenID providers configured. Requires administrator privileges. /// Lists the OpenID providers configured. Requires administrator privileges.
/// </summary> /// </summary>
/// <returns>The list of OpenID configurations.</returns> /// <returns>The list of OpenID configurations.</returns>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpGet("OID/Get")] [HttpGet("OID/Get")]
public ActionResult OidProviders() public ActionResult OidProviders()
{ {
@@ -384,7 +385,7 @@ public class SSOController : ControllerBase
/// This is a debug endpoint to list all running OpenID flows. Requires administrator privileges. /// This is a debug endpoint to list all running OpenID flows. Requires administrator privileges.
/// </summary> /// </summary>
/// <returns>The list of OpenID flows in progress.</returns> /// <returns>The list of OpenID flows in progress.</returns>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpGet("OID/States")] [HttpGet("OID/States")]
public ActionResult OidStates() public ActionResult OidStates()
{ {
@@ -557,7 +558,7 @@ public class SSOController : ControllerBase
/// <param name="provider">The provider name to add.</param> /// <param name="provider">The provider name to add.</param>
/// <param name="newConfig">The SAML configuration object (deserialized) from JSON.</param> /// <param name="newConfig">The SAML configuration object (deserialized) from JSON.</param>
/// <returns>The success result.</returns> /// <returns>The success result.</returns>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpPost("SAML/Add/{provider}")] [HttpPost("SAML/Add/{provider}")]
public OkResult SamlAdd(string provider, [FromBody] SamlConfig newConfig) public OkResult SamlAdd(string provider, [FromBody] SamlConfig newConfig)
{ {
@@ -572,7 +573,7 @@ public class SSOController : ControllerBase
/// </summary> /// </summary>
/// <param name="provider">The ID of the provider to delete.</param> /// <param name="provider">The ID of the provider to delete.</param>
/// <returns>The success result.</returns> /// <returns>The success result.</returns>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpGet("SAML/Del/{provider}")] [HttpGet("SAML/Del/{provider}")]
public OkResult SamlDel(string provider) public OkResult SamlDel(string provider)
{ {
@@ -586,7 +587,7 @@ public class SSOController : ControllerBase
/// Returns a list of all SAML providers configured. Requires administrator privileges. /// Returns a list of all SAML providers configured. Requires administrator privileges.
/// </summary> /// </summary>
/// <returns>A list of all of the Saml providers available.</returns> /// <returns>A list of all of the Saml providers available.</returns>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpGet("SAML/Get")] [HttpGet("SAML/Get")]
public ActionResult SamlProviders() public ActionResult SamlProviders()
{ {
@@ -699,7 +700,7 @@ public class SSOController : ControllerBase
/// <param name="username">The username to switch to the new provider.</param> /// <param name="username">The username to switch to the new provider.</param>
/// <param name="provider">The new provider to switch to.</param> /// <param name="provider">The new provider to switch to.</param>
/// <returns>Whether this API endpoint succeeded.</returns> /// <returns>Whether this API endpoint succeeded.</returns>
[Authorize(Policy = "RequiresElevation")] [Authorize(Policy = Policies.RequiresElevation)]
[HttpPost("Unregister/{username}")] [HttpPost("Unregister/{username}")]
public ActionResult Unregister(string username, [FromBody] string provider) public ActionResult Unregister(string username, [FromBody] string provider)
{ {
@@ -791,7 +792,7 @@ public class SSOController : ControllerBase
/// <param name="jellyfinUserId">The user ID within jellyfin to link to the provider.</param> /// <param name="jellyfinUserId">The user ID within jellyfin to link to the provider.</param>
/// <param name="authResponse">The client information to authenticate the user with.</param> /// <param name="authResponse">The client information to authenticate the user with.</param>
/// <returns>Whether this API endpoint succeeded.</returns> /// <returns>Whether this API endpoint succeeded.</returns>
[Authorize(Policy = "DefaultAuthorization")] [Authorize]
[HttpPost("{mode}/Link/{provider}/{jellyfinUserId}")] [HttpPost("{mode}/Link/{provider}/{jellyfinUserId}")]
[Consumes(MediaTypeNames.Application.Json)] [Consumes(MediaTypeNames.Application.Json)]
[Produces(MediaTypeNames.Application.Json)] [Produces(MediaTypeNames.Application.Json)]
@@ -821,7 +822,7 @@ public class SSOController : ControllerBase
/// <param name="jellyfinUserId">The user ID within jellyfin to unlink from the provider.</param> /// <param name="jellyfinUserId">The user ID within jellyfin to unlink from the provider.</param>
/// <param name="canonicalName">The user ID within jellyfin to unlink.</param> /// <param name="canonicalName">The user ID within jellyfin to unlink.</param>
/// <returns>Whether this API endpoint succeeded.</returns> /// <returns>Whether this API endpoint succeeded.</returns>
[Authorize(Policy = "DefaultAuthorization")] [Authorize]
[HttpDelete("{mode}/Link/{provider}/{jellyfinUserId}/{canonicalName}")] [HttpDelete("{mode}/Link/{provider}/{jellyfinUserId}/{canonicalName}")]
[Consumes(MediaTypeNames.Application.Json)] [Consumes(MediaTypeNames.Application.Json)]
[Produces(MediaTypeNames.Application.Json)] [Produces(MediaTypeNames.Application.Json)]
@@ -851,7 +852,7 @@ public class SSOController : ControllerBase
/// </summary> /// </summary>
/// <param name="jellyfinUserId">The user ID within jellyfin for which to return the links.</param> /// <param name="jellyfinUserId">The user ID within jellyfin for which to return the links.</param>
/// <returns>A dictionary of provider : link mappings.</returns> /// <returns>A dictionary of provider : link mappings.</returns>
[Authorize(Policy = "DefaultAuthorization")] [Authorize]
[HttpGet("saml/links/{jellyfinUserId}")] [HttpGet("saml/links/{jellyfinUserId}")]
[Produces(MediaTypeNames.Application.Json)] [Produces(MediaTypeNames.Application.Json)]
public async Task<ActionResult<SerializableDictionary<string, IEnumerable<string>>>> GetSamlLinksByUser(Guid jellyfinUserId) public async Task<ActionResult<SerializableDictionary<string, IEnumerable<string>>>> GetSamlLinksByUser(Guid jellyfinUserId)
@@ -879,7 +880,7 @@ public class SSOController : ControllerBase
/// </summary> /// </summary>
/// <param name="jellyfinUserId">The user ID within jellyfin for which to return the links.</param> /// <param name="jellyfinUserId">The user ID within jellyfin for which to return the links.</param>
/// <returns>A dictionary of provider : link mappings.</returns> /// <returns>A dictionary of provider : link mappings.</returns>
[Authorize(Policy = "DefaultAuthorization")] [Authorize]
[HttpGet("oid/links/{jellyfinUserId}")] [HttpGet("oid/links/{jellyfinUserId}")]
[Produces(MediaTypeNames.Application.Json)] [Produces(MediaTypeNames.Application.Json)]
public async Task<ActionResult<SerializableDictionary<string, IEnumerable<string>>>> GetOidLinksByUser(Guid jellyfinUserId) public async Task<ActionResult<SerializableDictionary<string, IEnumerable<string>>>> GetOidLinksByUser(Guid jellyfinUserId)

View File

@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.SSO_Auth</RootNamespace> <RootNamespace>Jellyfin.Plugin.SSO_Auth</RootNamespace>
<AssemblyVersion>3.5.2.3</AssemblyVersion> <AssemblyVersion>3.5.2.4</AssemblyVersion>
<FileVersion>3.5.2.3</FileVersion> <FileVersion>3.5.2.4</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
@@ -29,16 +29,16 @@
<ItemGroup> <ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" /> <FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.0.0" /> <PackageReference Include="IdentityModel.OidcClient" Version="5.2.1" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" /> <PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" /> <PackageReference Include="Jellyfin.Model" Version="10.*-*" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="6.0.0" /> <PackageReference Include="System.Security.Cryptography.Xml" Version="6.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.376" PrivateAssets="All" /> <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" /> <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup> </ItemGroup>

View File

@@ -36,8 +36,8 @@ public class SSOViewsController : ControllerBase
_sessionManager = sessionManager; _sessionManager = sessionManager;
_userManager = userManager; _userManager = userManager;
_authContext = authContext; _authContext = authContext;
_logger = logger; // _logger = logger;
_logger.LogInformation("SSO Views Controller initialized"); // _logger.LogInformation("SSO Views Controller initialized");
} }
private ActionResult ServeView(string viewName) private ActionResult ServeView(string viewName)
@@ -66,7 +66,7 @@ public class SSOViewsController : ControllerBase
if (stream == null) if (stream == null)
{ {
_logger.LogError("Failed to get resource {Resource}", view.EmbeddedResourcePath); // _logger.LogError("Failed to get resource {Resource}", view.EmbeddedResourcePath);
return NotFound(); return NotFound();
} }
#nullable disable #nullable disable
@@ -83,4 +83,4 @@ public class SSOViewsController : ControllerBase
{ {
return ServeView(viewName); return ServeView(viewName);
} }
} }

View File

@@ -1,9 +1,9 @@
name: "SSO Authentication" name: "SSO Authentication"
guid: "505ce9d1-d916-42fa-86ca-673ef241d7df" guid: "505ce9d1-d916-42fa-86ca-673ef241d7df"
imageUrl: "https://raw.githubusercontent.com/9p4/jellyfin-plugin-sso/main/img/logo.png" imageUrl: "https://raw.githubusercontent.com/9p4/jellyfin-plugin-sso/main/img/logo.png"
version: "3.5.2.3" version: "3.5.2.4"
targetAbi: "10.8.0.0" targetAbi: "10.9.0.0"
framework: "net6.0" framework: "net8.0"
owner: "9p4" owner: "9p4"
overview: "Authenticate users against an SSO provider." overview: "Authenticate users against an SSO provider."
description: | description: |
@@ -15,6 +15,7 @@ artifacts:
- "IdentityModel.OidcClient.dll" - "IdentityModel.OidcClient.dll"
- "IdentityModel.dll" - "IdentityModel.dll"
changelog: | changelog: |
3.5.2.4: Updates for Jellyfin 10.9
3.5.2.3: Improve OpenID discovery policy security rules, fix iOS login bugs related to cache 3.5.2.3: Improve OpenID discovery policy security rules, fix iOS login bugs related to cache
3.5.2.2: Fix linking page when using new paths 3.5.2.2: Fix linking page when using new paths
3.5.2.1: Hotfix for SAML null checks 3.5.2.1: Hotfix for SAML null checks

6
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707205916, "lastModified": 1715499532,
"narHash": "sha256-fmRJilYGlB7VCt3XsdYxrA0u8e/K84O5xYucerUY0iM=", "narHash": "sha256-9UJLb8rdi2VokYcfOBQHUzP3iNxOPNWcbK++ENElpk0=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8cc79aa39bbc6eaedaf286ae655b224c71e02907", "rev": "af8b9db5c00f1a8e4b83578acc578ff7d823b786",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -5,6 +5,6 @@
let pkgs = nixpkgs.legacyPackages.x86_64-linux; let pkgs = nixpkgs.legacyPackages.x86_64-linux;
in { in {
devShell.x86_64-linux = devShell.x86_64-linux =
pkgs.mkShell { buildInputs = [ pkgs.nodePackages.prettier pkgs.dotnet-sdk ]; }; pkgs.mkShell { buildInputs = [ pkgs.nodePackages.prettier pkgs.dotnet-sdk_8 ]; };
}; };
} }

View File

@@ -1,68 +1,75 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for Jellyfin.Server" Description="Code analysis rules for Jellyfin.Server.csproj" ToolsVersion="14.0"> <RuleSet Name="Rules for Jellyfin.Server"
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> Description="Code analysis rules for Jellyfin.Server.csproj" ToolsVersion="14.0">
<!-- disable warning SA1202: 'public' members must come before 'private' members --> <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1202" Action="Info" /> <!-- disable warning SA1202: 'public' members must come before 'private' members -->
<!-- disable warning SA1204: Static members must appear before non-static members --> <Rule Id="SA1202" Action="Info" />
<Rule Id="SA1204" Action="Info" /> <!-- disable warning SA1204: Static members must appear before non-static members -->
<!-- disable warning SA1404: Code analysis suppression should have justification --> <Rule Id="SA1204" Action="Info" />
<Rule Id="SA1404" Action="Info" /> <!-- disable warning SA1404: Code analysis suppression should have justification -->
<Rule Id="SA1404" Action="Info" />
<!-- disable warning SA1009: Closing parenthesis should be followed by a space. --> <!-- disable warning SA1009: Closing parenthesis should be followed by a space. -->
<Rule Id="SA1009" Action="None" /> <Rule Id="SA1009" Action="None" />
<!-- disable warning SA1101: Prefix local calls with 'this.' --> <!-- disable warning SA1101: Prefix local calls with 'this.' -->
<Rule Id="SA1101" Action="None" /> <Rule Id="SA1101" Action="None" />
<!-- disable warning SA1108: Block statements should not contain embedded comments --> <!-- disable warning SA1108: Block statements should not contain embedded comments -->
<Rule Id="SA1108" Action="None" /> <Rule Id="SA1108" Action="None" />
<!-- disable warning SA1128:: Put constructor initializers on their own line --> <!-- disable warning SA1128:: Put constructor initializers on their own line -->
<Rule Id="SA1128" Action="None" /> <Rule Id="SA1128" Action="None" />
<!-- disable warning SA1130: Use lambda syntax --> <!-- disable warning SA1130: Use lambda syntax -->
<Rule Id="SA1130" Action="None" /> <Rule Id="SA1130" Action="None" />
<!-- disable warning SA1200: 'using' directive must appear within a namespace declaration --> <!-- disable warning SA1200: 'using' directive must appear within a namespace declaration -->
<Rule Id="SA1200" Action="None" /> <Rule Id="SA1200" Action="None" />
<!-- disable warning SA1309: Fields must not begin with an underscore --> <!-- disable warning SA1309: Fields must not begin with an underscore -->
<Rule Id="SA1309" Action="None" /> <Rule Id="SA1309" Action="None" />
<!-- disable warning SA1413: Use trailing comma in multi-line initializers --> <!-- disable warning SA1402: File may only contain a single type -->
<Rule Id="SA1413" Action="None" /> <Rule Id="SA1402" Action="None" />
<!-- disable warning SA1512: Single-line comments must not be followed by blank line --> <!-- disable warning SA1413: Use trailing comma in multi-line initializers -->
<Rule Id="SA1512" Action="None" /> <Rule Id="SA1413" Action="None" />
<!-- disable warning SA1515: Single-line comment should be preceded by blank line --> <!-- disable warning SA1512: Single-line comments must not be followed by blank line -->
<Rule Id="SA1515" Action="None" /> <Rule Id="SA1512" Action="None" />
<!-- disable warning SA1600: Elements should be documented --> <!-- disable warning SA1515: Single-line comment should be preceded by blank line -->
<Rule Id="SA1600" Action="None" /> <Rule Id="SA1515" Action="None" />
<!-- disable warning SA1633: The file header is missing or not located at the top of the file --> <!-- disable warning SA1600: Elements should be documented -->
<Rule Id="SA1633" Action="None" /> <Rule Id="SA1600" Action="None" />
</Rules> <!-- disable warning SA1633: The file header is missing or not located at the top of the
file -->
<Rule Id="SA1633" Action="None" />
<!-- disable warning SA1649: File name should match first type name -->
<Rule Id="SA1649" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design"> <Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design">
<!-- disable warning CA1031: Do not catch general exception types --> <!-- disable warning CA1031: Do not catch general exception types -->
<Rule Id="CA1031" Action="Info" /> <Rule Id="CA1031" Action="Info" />
<!-- disable warning CA1032: Implement standard exception constructors --> <!-- disable warning CA1032: Implement standard exception constructors -->
<Rule Id="CA1032" Action="Info" /> <Rule Id="CA1032" Action="Info" />
<!-- disable warning CA1062: Validate arguments of public methods --> <!-- disable warning CA1062: Validate arguments of public methods -->
<Rule Id="CA1062" Action="Info" /> <Rule Id="CA1062" Action="Info" />
<!-- disable warning CA1716: Identifiers should not match keywords --> <!-- disable warning CA1716: Identifiers should not match keywords -->
<Rule Id="CA1716" Action="Info" /> <Rule Id="CA1716" Action="Info" />
<!-- disable warning CA1720: Identifiers should not contain type names --> <!-- disable warning CA1720: Identifiers should not contain type names -->
<Rule Id="CA1720" Action="Info" /> <Rule Id="CA1720" Action="Info" />
<!-- disable warning CA1812: internal class that is apparently never instantiated. <!-- disable warning CA1812: internal class that is apparently never instantiated.
If so, remove the code from the assembly. If so, remove the code from the assembly.
If this class is intended to contain only static members, make it static --> If this class is intended to contain only static members, make it static -->
<Rule Id="CA1812" Action="Info" /> <Rule Id="CA1812" Action="Info" />
<!-- disable warning CA1822: Member does not access instance data and can be marked as static --> <!-- disable warning CA1822: Member does not access instance data and can be marked as
<Rule Id="CA1822" Action="Info" /> static -->
<!-- disable warning CA2000: Dispose objects before losing scope --> <Rule Id="CA1822" Action="Info" />
<Rule Id="CA2000" Action="Info" /> <!-- disable warning CA2000: Dispose objects before losing scope -->
<Rule Id="CA2000" Action="Info" />
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri --> <!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
<Rule Id="CA1054" Action="None" /> <Rule Id="CA1054" Action="None" />
<!-- disable warning CA1055: URI return values should not be strings --> <!-- disable warning CA1055: URI return values should not be strings -->
<Rule Id="CA1055" Action="None" /> <Rule Id="CA1055" Action="None" />
<!-- disable warning CA1056: URI properties should not be strings --> <!-- disable warning CA1056: URI properties should not be strings -->
<Rule Id="CA1056" Action="None" /> <Rule Id="CA1056" Action="None" />
<!-- disable warning CA1303: Do not pass literals as localized parameters --> <!-- disable warning CA1303: Do not pass literals as localized parameters -->
<Rule Id="CA1303" Action="None" /> <Rule Id="CA1303" Action="None" />
<!-- disable warning CA1308: Normalize strings to uppercase --> <!-- disable warning CA1308: Normalize strings to uppercase -->
<Rule Id="CA1308" Action="None" /> <Rule Id="CA1308" Action="None" />
</Rules> </Rules>
</RuleSet> </RuleSet>