diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml index 1395b38..ba99431 100644 --- a/.github/workflows/build-dotnet.yml +++ b/.github/workflows/build-dotnet.yml @@ -15,7 +15,7 @@ jobs: - name: "Setup .NET Core" uses: actions/setup-dotnet@v1 with: - dotnet-version: "5.0.x" + dotnet-version: "8.0.x" - name: "Install dependencies" run: dotnet restore diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c6ee551..6696a94 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,7 +25,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 8.0.x - name: Initialize CodeQL uses: github/codeql-action/init@v1 diff --git a/.gitignore b/.gitignore index 03c9b93..c43d422 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ bin/ obj/ +.idea/ +*.DotSettings.user .vs/ diff --git a/Jellyfin.Plugin.Keycloak/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.Keycloak/Configuration/PluginConfiguration.cs index 12a92e3..bc018d6 100644 --- a/Jellyfin.Plugin.Keycloak/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.Keycloak/Configuration/PluginConfiguration.cs @@ -1,25 +1,94 @@ using MediaBrowser.Model.Plugins; -namespace Jellyfin.Plugin.Keycloak.Configuration +namespace Jellyfin.Plugin.Keycloak.Configuration; + +/// +/// The main plugin. +/// +public class PluginConfiguration : BasePluginConfiguration { - - public class PluginConfiguration : BasePluginConfiguration + /// + /// Initializes a new instance of the class. + /// + public PluginConfiguration() { - public bool CreateUser { get; set; } - public string AuthServerUrl { get; set; } - public string Realm { get; set; } - public string Resource { get; set; } - public string ClientSecret { get; set; } - - - public PluginConfiguration() - { - // set default options here - CreateUser = true; - AuthServerUrl = ""; - Realm = ""; - Resource = ""; - ClientSecret = ""; - } + // set default options here + this.Enabled = false; + this.CreateUser = true; + this.Enable2Fa = false; + this.AuthServerUrl = string.Empty; + this.Realm = "master"; + this.ClientId = string.Empty; + this.ClientSecret = string.Empty; + this.OAuthScope = string.Empty; + this.RolesTokenAttribute = string.Empty; + this.UsernameTokenAttribute = "preferred_username"; + this.EnableAllFolders = false; + this.EnabledFolders = System.Array.Empty(); } + + /// + /// Gets or sets a value indicating whether Keycloak authentication is enabled. + /// + public bool Enabled { get; set; } + + /// + /// Gets or sets a value indicating whether creation of new users that dont exist in Jellyfin is enabled. + /// + public bool CreateUser { get; set; } + + /// + /// Gets or sets a value indicating whether 2-factor authentication (Password+TOTP). + /// + public bool Enable2Fa { get; set; } + + /// + /// Gets or sets Keycloak server URL. + /// + public string AuthServerUrl { get; set; } + + /// + /// Gets or sets Keycloak server realm. + /// + public string Realm { get; set; } + + /// + /// Gets or sets Keycloak client ID. + /// + public string ClientId { get; set; } + + /// + /// Gets or sets Keycloak client secret. + /// + public string ClientSecret { get; set; } + + /// + /// Gets or sets Keycloak OAuth scope. + /// + public string OAuthScope { get; set; } + + /// + /// Gets or sets Keycloak username token attribute. + /// + public string UsernameTokenAttribute { get; set; } + + /// + /// Gets or sets Keycloak roles token attribute. + /// + public string RolesTokenAttribute { get; set; } + + /// + /// Gets or sets a value indicating whether users without a role are allowed to log in. + /// + public bool AllowUsersWithoutRole { get; set; } + + /// + /// Gets or sets a value indicating whether to enable access to all library folders. + /// + public bool EnableAllFolders { get; set; } + + /// + /// Gets or sets a list of folder Ids which are enabled for access by default. + /// + public string[] EnabledFolders { get; set; } } diff --git a/Jellyfin.Plugin.Keycloak/Configuration/configPage.html b/Jellyfin.Plugin.Keycloak/Configuration/configPage.html index c23d4e7..c11d588 100644 --- a/Jellyfin.Plugin.Keycloak/Configuration/configPage.html +++ b/Jellyfin.Plugin.Keycloak/Configuration/configPage.html @@ -8,33 +8,75 @@ + Keycloak Authentication - - Create User if doesn't exist + + Enable Keycloak authentication + + + + Create Keycloak user if it does not exist + + + + + + Enable Two-factor authentication + + You need to add the TOTP (6 digits) to the password when logging in + - Auth Server URL + Keycloak server URL - Base Keycloak auth URI - Realm + Keycloak Realm - Keycloak Realm - Resource/Client - - Keycloak Resource/Client + Client ID + Client Secret - Client Secret + + OAuth Scope + + + + Roles token attribute + + Access token attribute with the list of roles. Seperate keys with a '.' if the role list is part of a nested object. + + + Username token attribute + + Access token attribute with the username + + + + + Allow users without a role to log in + + + + + + Enable access to all libraries + + + + Enable access to certain libraries by default + Add library access to certain users by giving them the 'lib-<ID>' role + + + Save @@ -46,23 +88,41 @@