C# 从ClaimsPrincipal中删除重复的索赔

C# 从ClaimsPrincipal中删除重复的索赔,c#,asp.net-core,asp.net-core-identity,C#,Asp.net Core,Asp.net Core Identity,假设我有以下设置: 角色:[Role1,Role2] 角色声明:[{Role1,ClaimType1,ClaimValue1},{Role2,ClaimType1,ClaimValue1}] 基本上有两个角色,两个角色都有角色声明ClaimType1=ClaimValue1 然后我有一个用户被分配到这两个角色。如果我查看此用户的声明身份,我将看到 [ ClaimType1 = ClaimValue1 ClaimType1 = ClaimValue1 ] 我认为幕后asp.net

假设我有以下设置:

角色:
[Role1,Role2]

角色声明:
[{Role1,ClaimType1,ClaimValue1},{Role2,ClaimType1,ClaimValue1}]

基本上有两个角色,两个角色都有角色声明
ClaimType1=ClaimValue1

然后我有一个用户被分配到这两个角色。如果我查看此用户的声明身份,我将看到

[
    ClaimType1 = ClaimValue1
    ClaimType1 = ClaimValue1
]
我认为幕后asp.net identity只调用
SignInManager.CreateUserPrincipalSync
,它迭代所有角色并添加从
RoleManager.GetClaimsAsync
返回的所有声明

在生成用户主体时或在生成用户主体之后忽略重复声明(具有相同类型+值的声明)的最简单方法是什么