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 all 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 identify the user.
/// </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 @@ -6,6 +6,7 @@

using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -40,6 +41,8 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
}

[Theory]
[InlineData(ClaimTypes.NameIdentifier, "johm.demo.smith@superoffice.com")]
[InlineData(ClaimTypes.Email, "johm.demo.smith@superoffice.com")]
[InlineData(SuperOfficeAuthenticationConstants.PrincipalNames.BusinessId, "4")]
[InlineData(SuperOfficeAuthenticationConstants.PrincipalNames.CategoryId, "4")]
[InlineData(SuperOfficeAuthenticationConstants.PrincipalNames.ContactId, "2")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"ContactId": 2,
"CountryId": 826,
"DatabaseContextIdentifier": "Cust12345",
"EMailAddress": "johm.demo.smith@superoffice.com",
"FunctionRights": [ "allow-bulk-export" ],
"GroupId": 2,
"HomeCountryId": 826,
Expand Down