diff --git a/SSO-Auth/Api/SSOController.cs b/SSO-Auth/Api/SSOController.cs
index 85004c2..9896140 100644
--- a/SSO-Auth/Api/SSOController.cs
+++ b/SSO-Auth/Api/SSOController.cs
@@ -104,7 +104,7 @@ public class SSOController : ControllerBase
foreach (var claim in result.User.Claims)
{
- if (claim.Type == "preferred_username")
+ if (claim.Type == (config.DefaultUsernameClaim ?? "preferred_username"))
{
StateManager[state].Username = claim.Value;
if (config.Roles.Length == 0)
@@ -186,7 +186,7 @@ public class SSOController : ControllerBase
}
}
- // If the provider doesn't support preferred_username, then use sub
+ // If the provider doesn't support the preferred username claim, then use the sub claim
if (!StateManager[state].Valid)
{
foreach (var claim in result.User.Claims)
diff --git a/SSO-Auth/Config/PluginConfiguration.cs b/SSO-Auth/Config/PluginConfiguration.cs
index bf9a43b..f254806 100644
--- a/SSO-Auth/Config/PluginConfiguration.cs
+++ b/SSO-Auth/Config/PluginConfiguration.cs
@@ -217,6 +217,11 @@ public class OidConfig
}
set => _canonicalLinks = value;
}
+
+ ///
+ /// Gets or sets the default username claim when creating new accounts.
+ ///
+ public string DefaultUsernameClaim { get; set; }
}
///