feat: allow linking to work with new paths

This commit is contained in:
Ersei Saggi
2024-01-11 09:56:45 -05:00
parent ebf7eef83e
commit 9321c25f20
2 changed files with 29 additions and 2 deletions
+19 -2
View File
@@ -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));
}
+10
View File
@@ -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>