diff --git a/SSO-Auth/Api/SSOController.cs b/SSO-Auth/Api/SSOController.cs
index 614e5b7..7a8b6bc 100644
--- a/SSO-Auth/Api/SSOController.cs
+++ b/SSO-Auth/Api/SSOController.cs
@@ -311,7 +311,7 @@ public class SSOController : ControllerBase
{
if (kvp.Value.State.State.Equals(response.Data) && kvp.Value.Valid)
{
- var authenticationResult = await Authenticate(kvp.Value.Username, kvp.Value.Admin, config.EnableAuthorization, config.EnableAllFolders, kvp.Value.Folders.ToArray(), response)
+ var authenticationResult = await Authenticate(kvp.Value.Username, kvp.Value.Admin, config.EnableAuthorization, config.EnableAllFolders, kvp.Value.Folders.ToArray(), response, config.DefaultProvider)
.ConfigureAwait(false);
return Ok(authenticationResult);
}
@@ -484,11 +484,12 @@ public class SSOController : ControllerBase
}
}
- var authenticationResult = await Authenticate(samlResponse.GetNameID(), isAdmin, config.EnableAuthorization, config.EnableAllFolders, folders.ToArray(), response)
+ var authenticationResult = await Authenticate(samlResponse.GetNameID(), isAdmin, config.EnableAuthorization, config.EnableAllFolders, folders.ToArray(), response, config.DefaultProvider)
.ConfigureAwait(false);
return Ok(authenticationResult);
}
}
+
return Problem("Something went wrong");
}
@@ -517,7 +518,8 @@ public class SSOController : ControllerBase
/// Determines whether all folders are enabled.
/// Determines which folders should be enabled for this client.
/// The client information to authenticate the user with.
- private async Task Authenticate(string username, bool isAdmin, bool enableAuthorization, bool enableAllFolders, string[] enabledFolders, AuthResponse authResponse)
+ /// The default provider of the user to be set after logging in.
+ private async Task Authenticate(string username, bool isAdmin, bool enableAuthorization, bool enableAllFolders, string[] enabledFolders, AuthResponse authResponse, string defaultProvider)
{
User user = null;
user = _userManager.GetUserByName(username);
@@ -549,14 +551,13 @@ public class SSOController : ControllerBase
authRequest.DeviceId = authResponse.DeviceID;
authRequest.DeviceName = authResponse.DeviceName;
_logger.LogInformation("Auth request created...");
- if (config.DefaultProvider != "")
- {
- User user = null;
- user = _userManager.GetUserByName(kvp.Value.Username);
- user.AuthenticationProviderId = config.DefaultProvider;
- await _userManager.UpdateUserAsync(user).ConfigureAwait(false);
- _logger.LogInformation("Set default login provider to " + config.DefaultProvider);
+ if (!String.IsNullOrEmpty(defaultProvider))
+ {
+ user.AuthenticationProviderId = defaultProvider;
+ await _userManager.UpdateUserAsync(user).ConfigureAwait(false);
+ _logger.LogInformation("Set default login provider to " + defaultProvider);
}
+
return await _sessionManager.AuthenticateDirect(authRequest).ConfigureAwait(false);
}
diff --git a/SSO-Auth/Config/PluginConfiguration.cs b/SSO-Auth/Config/PluginConfiguration.cs
index 0260bed..41e442f 100644
--- a/SSO-Auth/Config/PluginConfiguration.cs
+++ b/SSO-Auth/Config/PluginConfiguration.cs
@@ -96,7 +96,7 @@ public class SamlConfig
public List FolderRoleMapping { get; set; }
///
- /// The default provider the user gets set to after logging in with SSO
+ /// Gets or sets the default provider the user after logging in with SSO.
///
public string DefaultProvider { get; set; }
}
@@ -170,7 +170,7 @@ public class OIDConfig
public string RoleClaim { get; set; }
///
- /// The default provider the user gets set to after logging in with SSO
+ /// Gets or sets the default provider the user after logging in with SSO.
///
public string DefaultProvider { get; set; }
}
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..739753e
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,10 @@
+rm -rf SSO-Auth/bin
+docker run --rm -v /blyatflix/home/SSO/jellyfin-plugin-sso:/app -w /app mcr.microsoft.com/dotnet/sdk:6.0 dotnet publish .
+rm -rf /blyatflix/apps/jellyfin/config/data/plugins/sso
+docker restart jellyfin
+mkdir /blyatflix/apps/jellyfin/config/data/plugins/sso
+cp SSO-Auth/bin/Debug/net6.0/publish/SSO-Auth.dll /blyatflix/apps/jellyfin/config/data/plugins/sso/
+cp SSO-Auth/bin/Debug/net6.0/publish/IdentityModel.dll /blyatflix/apps/jellyfin/config/data/plugins/sso/
+cp SSO-Auth/bin/Debug/net6.0/publish/IdentityModel.OidcClient.dll /blyatflix/apps/jellyfin/config/data/plugins/sso/
+chown -R 1000:1000 /blyatflix/apps/jellyfin/config/data/plugins/sso
+docker restart jellyfin