feat: allow configuration of preferred username claim (#47)

This commit is contained in:
Sambhav Saggi
2022-08-23 18:18:42 -04:00
parent 47db5cb504
commit 332f62d76e
2 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -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)
+5
View File
@@ -217,6 +217,11 @@ public class OidConfig
}
set => _canonicalLinks = value;
}
/// <summary>
/// Gets or sets the default username claim when creating new accounts.
/// </summary>
public string DefaultUsernameClaim { get; set; }
}
/// <summary>