From 2e8c19d63182b2c8c52ffeed729fe54e9aef4d9b Mon Sep 17 00:00:00 2001 From: Ersei Saggi Date: Mon, 13 May 2024 09:17:42 -0400 Subject: [PATCH] Update for Jellyfin 10.9 --- SSO-Auth/Api/SSOController.cs | 25 ++-- SSO-Auth/SSO-Auth.csproj | 14 +- SSO-Auth/{Api => Views}/SSOViewsController.cs | 8 +- build.yaml | 7 +- flake.lock | 6 +- flake.nix | 2 +- jellyfin.ruleset | 129 +++++++++--------- 7 files changed, 100 insertions(+), 91 deletions(-) rename SSO-Auth/{Api => Views}/SSOViewsController.cs (93%) diff --git a/SSO-Auth/Api/SSOController.cs b/SSO-Auth/Api/SSOController.cs index f4f6ba9..5c055bc 100644 --- a/SSO-Auth/Api/SSOController.cs +++ b/SSO-Auth/Api/SSOController.cs @@ -10,6 +10,7 @@ using Jellyfin.Data.Entities; using Jellyfin.Data.Enums; using Jellyfin.Plugin.SSO_Auth.Config; using Jellyfin.Plugin.SSO_Auth.Helpers; +using MediaBrowser.Common.Api; using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; @@ -327,7 +328,7 @@ public class SSOController : ControllerBase /// /// The name of the provider to add. /// The OID configuration (deserialized from a JSON post). - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpPost("OID/Add/{provider}")] public void OidAdd(string provider, [FromBody] OidConfig config) { @@ -340,7 +341,7 @@ public class SSOController : ControllerBase /// Deletes an OpenID provider. /// /// Name of provider to delete. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpGet("OID/Del/{provider}")] public void OidDel(string provider) { @@ -353,7 +354,7 @@ public class SSOController : ControllerBase /// Lists the OpenID providers configured. Requires administrator privileges. /// /// The list of OpenID configurations. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpGet("OID/Get")] 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. /// /// The list of OpenID flows in progress. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpGet("OID/States")] public ActionResult OidStates() { @@ -557,7 +558,7 @@ public class SSOController : ControllerBase /// The provider name to add. /// The SAML configuration object (deserialized) from JSON. /// The success result. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpPost("SAML/Add/{provider}")] public OkResult SamlAdd(string provider, [FromBody] SamlConfig newConfig) { @@ -572,7 +573,7 @@ public class SSOController : ControllerBase /// /// The ID of the provider to delete. /// The success result. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpGet("SAML/Del/{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. /// /// A list of all of the Saml providers available. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpGet("SAML/Get")] public ActionResult SamlProviders() { @@ -699,7 +700,7 @@ public class SSOController : ControllerBase /// The username to switch to the new provider. /// The new provider to switch to. /// Whether this API endpoint succeeded. - [Authorize(Policy = "RequiresElevation")] + [Authorize(Policy = Policies.RequiresElevation)] [HttpPost("Unregister/{username}")] public ActionResult Unregister(string username, [FromBody] string provider) { @@ -791,7 +792,7 @@ public class SSOController : ControllerBase /// The user ID within jellyfin to link to the provider. /// The client information to authenticate the user with. /// Whether this API endpoint succeeded. - [Authorize(Policy = "DefaultAuthorization")] + [Authorize] [HttpPost("{mode}/Link/{provider}/{jellyfinUserId}")] [Consumes(MediaTypeNames.Application.Json)] [Produces(MediaTypeNames.Application.Json)] @@ -821,7 +822,7 @@ public class SSOController : ControllerBase /// The user ID within jellyfin to unlink from the provider. /// The user ID within jellyfin to unlink. /// Whether this API endpoint succeeded. - [Authorize(Policy = "DefaultAuthorization")] + [Authorize] [HttpDelete("{mode}/Link/{provider}/{jellyfinUserId}/{canonicalName}")] [Consumes(MediaTypeNames.Application.Json)] [Produces(MediaTypeNames.Application.Json)] @@ -851,7 +852,7 @@ public class SSOController : ControllerBase /// /// The user ID within jellyfin for which to return the links. /// A dictionary of provider : link mappings. - [Authorize(Policy = "DefaultAuthorization")] + [Authorize] [HttpGet("saml/links/{jellyfinUserId}")] [Produces(MediaTypeNames.Application.Json)] public async Task>>> GetSamlLinksByUser(Guid jellyfinUserId) @@ -879,7 +880,7 @@ public class SSOController : ControllerBase /// /// The user ID within jellyfin for which to return the links. /// A dictionary of provider : link mappings. - [Authorize(Policy = "DefaultAuthorization")] + [Authorize] [HttpGet("oid/links/{jellyfinUserId}")] [Produces(MediaTypeNames.Application.Json)] public async Task>>> GetOidLinksByUser(Guid jellyfinUserId) diff --git a/SSO-Auth/SSO-Auth.csproj b/SSO-Auth/SSO-Auth.csproj index 52dc141..bd49837 100644 --- a/SSO-Auth/SSO-Auth.csproj +++ b/SSO-Auth/SSO-Auth.csproj @@ -1,10 +1,10 @@ - net6.0 + net8.0 Jellyfin.Plugin.SSO_Auth - 3.5.2.3 - 3.5.2.3 + 3.5.2.4 + 3.5.2.4 true false @@ -29,16 +29,16 @@ - + - - + + - + diff --git a/SSO-Auth/Api/SSOViewsController.cs b/SSO-Auth/Views/SSOViewsController.cs similarity index 93% rename from SSO-Auth/Api/SSOViewsController.cs rename to SSO-Auth/Views/SSOViewsController.cs index c710291..96b5e98 100644 --- a/SSO-Auth/Api/SSOViewsController.cs +++ b/SSO-Auth/Views/SSOViewsController.cs @@ -36,8 +36,8 @@ public class SSOViewsController : ControllerBase _sessionManager = sessionManager; _userManager = userManager; _authContext = authContext; - _logger = logger; - _logger.LogInformation("SSO Views Controller initialized"); + // _logger = logger; + // _logger.LogInformation("SSO Views Controller initialized"); } private ActionResult ServeView(string viewName) @@ -66,7 +66,7 @@ public class SSOViewsController : ControllerBase if (stream == null) { - _logger.LogError("Failed to get resource {Resource}", view.EmbeddedResourcePath); + // _logger.LogError("Failed to get resource {Resource}", view.EmbeddedResourcePath); return NotFound(); } #nullable disable @@ -83,4 +83,4 @@ public class SSOViewsController : ControllerBase { return ServeView(viewName); } -} \ No newline at end of file +} diff --git a/build.yaml b/build.yaml index 72fc0f4..c8f8a98 100644 --- a/build.yaml +++ b/build.yaml @@ -1,9 +1,9 @@ name: "SSO Authentication" guid: "505ce9d1-d916-42fa-86ca-673ef241d7df" imageUrl: "https://raw.githubusercontent.com/9p4/jellyfin-plugin-sso/main/img/logo.png" -version: "3.5.2.3" -targetAbi: "10.8.0.0" -framework: "net6.0" +version: "3.5.2.4" +targetAbi: "10.9.0.0" +framework: "net8.0" owner: "9p4" overview: "Authenticate users against an SSO provider." description: | @@ -15,6 +15,7 @@ artifacts: - "IdentityModel.OidcClient.dll" - "IdentityModel.dll" 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.2: Fix linking page when using new paths 3.5.2.1: Hotfix for SAML null checks diff --git a/flake.lock b/flake.lock index c9418e7..b80c063 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1707205916, - "narHash": "sha256-fmRJilYGlB7VCt3XsdYxrA0u8e/K84O5xYucerUY0iM=", + "lastModified": 1715499532, + "narHash": "sha256-9UJLb8rdi2VokYcfOBQHUzP3iNxOPNWcbK++ENElpk0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8cc79aa39bbc6eaedaf286ae655b224c71e02907", + "rev": "af8b9db5c00f1a8e4b83578acc578ff7d823b786", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8464d9d..97647ce 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,6 @@ let pkgs = nixpkgs.legacyPackages.x86_64-linux; in { devShell.x86_64-linux = - pkgs.mkShell { buildInputs = [ pkgs.nodePackages.prettier pkgs.dotnet-sdk ]; }; + pkgs.mkShell { buildInputs = [ pkgs.nodePackages.prettier pkgs.dotnet-sdk_8 ]; }; }; } diff --git a/jellyfin.ruleset b/jellyfin.ruleset index 45ab725..5855711 100644 --- a/jellyfin.ruleset +++ b/jellyfin.ruleset @@ -1,68 +1,75 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + +