Providing two claims of the same type, turns claim into array
- [x] I read and understood how to enable logging
Issue / Steps to reproduce the problem
name claim is not standard when I ask fro userinfo from clinet
{
"sub": "10",
"name": [ "user.name", "User Name" ],
"AspNet.Identity.SecurityStamp": "240dc561-37ff-4eb9-a58a-f760d1b9abaa",
"role": [ "CSM_User", "dev", "admin", "SuperAdmin", "Admin", "LdapUser", "TranslationAdmin" ],
"UnitCode": "3120002566",
"JobTitle": "Kidemli Yazilim Uzmani",
"JobPhone": "0212 999 9349",
"given_name": "User",
"family_name": "Name",
"birthdate": "03/06/1978",
"email": "[email protected]",
"gender": "male"
}
name claim mest be a string
http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
Relevant parts of the log file
<log goes here>
Well - you give us the wrong data. If there are two claims of the same type, they become an array.
Yes but it must create just one name claim. it must be a restriction I think
Why can't the user have two names? Or two emails? There is a reason we do certain things.
I am investigating on this issue but as I see Application user has name claim and UserName field and Get user claim method return user name as name claim
In this code :
public async Task GetProfileDataAsync(ProfileDataRequestContext context)
{
string sub = context.Subject.GetSubjectId();
ApplicationUser user = await _userManager.FindByIdAsync(sub);
ClaimsPrincipal principal = await _claimsFactory.CreateAsync(user);
List<Claim> cs = principal.Claims.ToList();
context.IssuedClaims = cs;
}
_claimsFactory.CreateAsync change UserName to name claim
dear @brockallen
this is a rule
http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
Where does it say you can't have more than one?
you right but dotnet security team believes that it cannot be more than one :)
I don't follow.
this behavior is by design. closing.
I think this behavior does lead to issues.
We've had to interact with other OpenID Connect providers who expect name to be a String as per the standard. In our case adding Windows login to User who has a name set, will also automatically return the Windows username along with the existing name claim.
i.e.
name: ['WindowsLogon', 'Firstname Surname']
Does anyone know where this automatic inclusion of claims takes place, is there some-point I could intercept or config I could change?
Having now seen this issue https://github.com/aspnet/Identity/issues/1394 I think its the problem of ASP.NET Core Identity not Identity Server.
Also adding for future readers adding this line into Startup.cs below AddIdentityServer() and above AddMvc resolved everything
services.AddIdentityServerUserClaimsPrincipalFactory<ApplicationUser, IdentityRole>();
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.