Browse Source
Add `UniqueName` claim to the iidentity.
pull/11039/head
maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
2 changed files with
7 additions and
0 deletions
-
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs
-
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpUserClaimsFactory.cs
|
|
|
@ -5,6 +5,7 @@ using IdentityModel; |
|
|
|
using IdentityServer4.Services; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Microsoft.IdentityModel.JsonWebTokens; |
|
|
|
using Volo.Abp.Security.Claims; |
|
|
|
|
|
|
|
namespace Volo.Abp.IdentityServer |
|
|
|
@ -20,6 +21,7 @@ namespace Volo.Abp.IdentityServer |
|
|
|
AbpClaimTypes.ImpersonatorUserId, |
|
|
|
AbpClaimTypes.Name, |
|
|
|
AbpClaimTypes.SurName, |
|
|
|
JwtRegisteredClaimNames.UniqueName, |
|
|
|
JwtClaimTypes.PreferredUserName, |
|
|
|
JwtClaimTypes.GivenName, |
|
|
|
JwtClaimTypes.FamilyName, |
|
|
|
|
|
|
|
@ -5,6 +5,7 @@ using System.Security.Principal; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using IdentityModel; |
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
using Microsoft.IdentityModel.JsonWebTokens; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using IdentityUser = Volo.Abp.Identity.IdentityUser; |
|
|
|
|
|
|
|
@ -41,6 +42,10 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity |
|
|
|
{ |
|
|
|
identity.RemoveClaim(usernameClaim); |
|
|
|
identity.AddIfNotContains(new Claim(JwtClaimTypes.PreferredUserName, username)); |
|
|
|
|
|
|
|
//https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/1627
|
|
|
|
//https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/05e02b5e0383be40e45c667c12f6667d38e33fcc/src/System.IdentityModel.Tokens.Jwt/ClaimTypeMapping.cs#L52
|
|
|
|
identity.AddIfNotContains(new Claim(JwtRegisteredClaimNames.UniqueName, username)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!identity.HasClaim(x => x.Type == JwtClaimTypes.Name)) |
|
|
|
|