Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuperOffice provider should support ClaimTypes.NameIdentifier and ClaimTypes.Email #465

Merged
merged 5 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public static class ClaimNames
/// </summary>
public const string PrimaryEmail = "http://schemes.superoffice.net/identity/so_primary_email_address";

/// <summary>
/// Subject Identifier used to uniquely identity user.
AnthonyYates marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public const string SubjectIdentifier = "sub";

/// <summary>
/// Identifier used to exchange for a system user ticket.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public class SuperOfficeAuthenticationHandler : OAuthHandler<SuperOfficeAuthenti
contextIdentifier = claim.Value;
}

if (claim.Type == SuperOfficeAuthenticationConstants.ClaimNames.SubjectIdentifier)
{
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, claim.Value));
continue;
}

if (Options.IncludeIdTokenAsClaims)
{
// May be possible same claim names from UserInformationEndpoint and IdToken.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public SuperOfficeAuthenticationOptions()
Scope.Add("openid");

ClaimActions.MapJsonKey(ClaimTypes.Name, PrincipalNames.FullName);
ClaimActions.MapJsonKey(ClaimTypes.Email, PrincipalNames.EmailAddress);

ClaimActions.MapJsonKey(ClaimNames.AssociateId, PrincipalNames.AssociateId);
ClaimActions.MapJsonKey(ClaimNames.Email, PrincipalNames.EmailAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
}

[Theory]
[InlineData(System.Security.Claims.ClaimTypes.NameIdentifier, "johm.demo.smith@superoffice.com")]
martincostello marked this conversation as resolved.
Show resolved Hide resolved
[InlineData(SuperOfficeAuthenticationConstants.PrincipalNames.BusinessId, "4")]
[InlineData(SuperOfficeAuthenticationConstants.PrincipalNames.CategoryId, "4")]
[InlineData(SuperOfficeAuthenticationConstants.PrincipalNames.ContactId, "2")]
Expand Down