In the ASP.Net core, you can use the implementation of IClaimsTransformer.
You register it as follows:
app.UseClaimsTransformation(o => o.Transformer = new MyClaimsTransformer());
Implementation
public class MyClaimsTransformer : IClaimsTransformer
{
public Task<ClaimsPrincipal> TransformAsync(ClaimsTransformationContext context)
{
var identity = context.Principal.Identity as ClaimsIdentity;
foreach (var claim in ci.Claims)
{
}
}
}
However ClaimsIdentity.Claims, the property is read-only. Also Claim.Type, Claim.Valueare readonly properties.
This means that during the implementation IClaimsTransformeryou can add only new claims. You cannot delete or modify existing claims.
So what is the real use of IClaims Transformer?
source
share