In ASP.Net core lets you use an implementation of IClaimsTransformer.
You register it like this:
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)
{
// you cannot modify claim.Type or claim.Value here
}
}
}
However ClaimsIdentity.Claims
is read only property. Also Claim.Type
, Claim.Value
are readonly properties.
That means in the implementation of IClaimsTransformer
you can only add new claims. You cannot remove or modify existing claims.
So whats the real use of IClaimsTransformer?