var ManagerAccess = context.Principal.FindFirst(ClaimTypes.System).Value;
Here I want to execute like this:
(claimstypes.ManagerAccess).value;
Is this possible?
var ManagerAccess = context.Principal.FindFirst(ClaimTypes.System).Value;
Here I want to execute like this:
(claimstypes.ManagerAccess).value;
Is this possible?
To add custom claim type, you could use IClaimsTransformation
public class CustomClaimsTransformer : IClaimsTransformation
{
public Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
{
((ClaimsIdentity)principal.Identity).AddClaim(new Claim("ManagerAccess", "MyValue"));
return Task.FromResult(principal);
}
}
Register in startup.cs
services.AddScoped<IClaimsTransformation, CustomClaimsTransformer>();
Check you claims:
var ManagerAccess = context.Principal.FindFirst("ManagerAccess").Value;
For more solutions, refer to Implementing custom claim with extended MVC Core Identity user