mirror of
https://github.com/9p4/jellyfin-plugin-sso.git
synced 2026-09-19 13:12:19 +00:00
feat: allow linking to work with new paths
This commit is contained in:
@@ -288,12 +288,21 @@ public class SSOController : ControllerBase
|
||||
|
||||
if (config.Enabled)
|
||||
{
|
||||
bool newPath = config.NewPath;
|
||||
if (!isLinking)
|
||||
{
|
||||
newPath = Request.Path.Value.Contains("/start/", StringComparison.InvariantCultureIgnoreCase);
|
||||
config.NewPath = newPath;
|
||||
}
|
||||
|
||||
string redirectUri = GetRequestBase(config.SchemeOverride) + $"/sso/OID/{(newPath ? "redirect" : "r")}/" + provider;
|
||||
|
||||
var options = new OidcClientOptions
|
||||
{
|
||||
Authority = config.OidEndpoint?.Trim(),
|
||||
ClientId = config.OidClientId?.Trim(),
|
||||
ClientSecret = config.OidSecret?.Trim(),
|
||||
RedirectUri = GetRequestBase(config.SchemeOverride) + $"/sso/OID/{(Request.Path.Value.Contains("/start/", StringComparison.InvariantCultureIgnoreCase) ? "redirect" : "r")}/" + provider,
|
||||
RedirectUri = redirectUri,
|
||||
Scope = string.Join(" ", config.OidScopes.Prepend("openid profile")),
|
||||
};
|
||||
options.Policy.Discovery.ValidateEndpoints = false; // For Google and other providers with different endpoints
|
||||
@@ -514,6 +523,14 @@ public class SSOController : ControllerBase
|
||||
|
||||
if (config.Enabled)
|
||||
{
|
||||
bool newPath = config.NewPath;
|
||||
if (!isLinking)
|
||||
{
|
||||
newPath = Request.Path.Value.Contains("/start/", StringComparison.InvariantCultureIgnoreCase);
|
||||
config.NewPath = newPath;
|
||||
}
|
||||
|
||||
string redirectUri = GetRequestBase(config.SchemeOverride) + $"/sso/SAML/{(newPath ? "post" : "p")}/" + provider;
|
||||
string relayState = null;
|
||||
if (isLinking)
|
||||
{
|
||||
@@ -522,7 +539,7 @@ public class SSOController : ControllerBase
|
||||
|
||||
var request = new AuthRequest(
|
||||
config.SamlClientId.Trim(),
|
||||
GetRequestBase(config.SchemeOverride) + $"/sso/SAML/{(Request.Path.Value.Contains("/start/", StringComparison.InvariantCultureIgnoreCase) ? "post" : "p")}/" + provider);
|
||||
redirectUri);
|
||||
|
||||
return Redirect(request.GetRedirectUrl(config.SamlEndpoint.Trim(), relayState));
|
||||
}
|
||||
|
||||
@@ -131,6 +131,11 @@ public class SamlConfig
|
||||
/// </summary>
|
||||
public string SchemeOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the new, more descriptive paths are to be used.
|
||||
/// </summary>
|
||||
public bool NewPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a mapping of canonical names from the provider to jellyfin user ids.
|
||||
/// </summary>
|
||||
@@ -260,6 +265,11 @@ public class OidConfig
|
||||
/// </summary>
|
||||
public string SchemeOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the new, more descriptive paths are to be used.
|
||||
/// </summary>
|
||||
public bool NewPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a mapping of canonical names from the provider to jellyfin user ids.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user