diff --git a/SSO-Auth/Api/SSOController.cs b/SSO-Auth/Api/SSOController.cs index 0c203bc..4da3876 100644 --- a/SSO-Auth/Api/SSOController.cs +++ b/SSO-Auth/Api/SSOController.cs @@ -306,6 +306,26 @@ public class SSOController : ControllerBase return Ok(SSOPlugin.Instance.Configuration.OidConfigs); } + /// + /// Lists the OpenID providers names only. + /// + /// The list of OpenID configurations. + [HttpGet("OID/GetNames")] + public ActionResult OidProviderNames() + { + return Ok(SSOPlugin.Instance.Configuration.OidConfigs.Keys); + } + + /// + /// Lists the SAML providers names only. + /// + /// The list of OpenID configurations. + [HttpGet("SAML/GetNames")] + public ActionResult SamlProviderNames() + { + return Ok(SSOPlugin.Instance.Configuration.SamlConfigs.Keys); + } + /// /// This is a debug endpoint to list all running OpenID flows. Requires administrator privileges. /// diff --git a/SSO-Auth/Config/linking.html b/SSO-Auth/Config/linking.html new file mode 100644 index 0000000..46beed7 --- /dev/null +++ b/SSO-Auth/Config/linking.html @@ -0,0 +1,54 @@ + + + + SSO + + +
+
+
+
+

SSO Settings:

+ ${Help} +
+

+ Use the following buttons to link your jellyfin account to any one + of the SSO providers. Please note that deletion is currently only + available by API. +

+

+ See the + help page + and + roadmap + + for more information. +

+
+
+
+
+
+
+ + diff --git a/SSO-Auth/Config/linking.js b/SSO-Auth/Config/linking.js new file mode 100644 index 0000000..3ba677d --- /dev/null +++ b/SSO-Auth/Config/linking.js @@ -0,0 +1,46 @@ +const ssoConfigLinking = { + pluginUniqueId: "505ce9d1-d916-42fa-86ca-673ef241d7df", + loadProviders: (view) => { + const provider_list_id = "sso-provider-list"; + + var provider_list = view.querySelector("#" + provider_list_id); + provider_list.innerHTML = ""; + + fetch(new Request(ApiClient.getUrl("sso/OID/GetNames"))).then((resp) => { + resp.json().then((config_names) => { + ssoConfigLinking.loadProviderList(provider_list, config_names, "oid"); + }); + }); + fetch(new Request(ApiClient.getUrl("sso/SAML/GetNames"))).then((resp) => { + resp.json().then((config_names) => { + ssoConfigLinking.loadProviderList(provider_list, config_names, "saml"); + }); + }); + }, + loadProviderList: (element, providers, provider_mode) => { + providers.forEach((provider_name) => { + var provider_link = document.createElement("a"); + + provider_link.classList.add("raised"); + provider_link.classList.add("block"); + provider_link.classList.add("emby-button"); + + //const provider_name_css = ssoConfigLinking.safeCSSId(provider_name); + //provider_link.id = "sso-provider-" + provider_name_css; + //provider_link.classList.add("sso-provider-" + provider_name_css); + provider_link.classList.add("sso-provider"); + + provider_link.text = provider_name; + + provider_link.href = ApiClient.getUrl( + `/SSO/${provider_mode}/p/${provider_name}?isLinking=true` + ); + + element.appendChild(provider_link); + }); + }, +}; + +export default function (view) { + ssoConfigLinking.loadProviders(view); +} diff --git a/SSO-Auth/SSO-Auth.csproj b/SSO-Auth/SSO-Auth.csproj index 61ccb8e..2c0c1fd 100644 --- a/SSO-Auth/SSO-Auth.csproj +++ b/SSO-Auth/SSO-Auth.csproj @@ -13,9 +13,12 @@ + + + diff --git a/SSO-Auth/SSOPlugin.cs b/SSO-Auth/SSOPlugin.cs index ec554a8..aff3dfc 100644 --- a/SSO-Auth/SSOPlugin.cs +++ b/SSO-Auth/SSOPlugin.cs @@ -62,6 +62,16 @@ public class SSOPlugin : BasePlugin, IHasWebPages Name = Name + ".css", EmbeddedResourcePath = $"{GetType().Namespace}.Config.style.css" }, + new PluginPageInfo + { + Name = Name + "-linking", + EmbeddedResourcePath = $"{GetType().Namespace}.Config.linking.html" + }, + new PluginPageInfo + { + Name = Name + "-linking.js", + EmbeddedResourcePath = $"{GetType().Namespace}.Config.linking.js" + }, }; } }