I was looking for this answer when I came across this documentation:
When you inspect the claims on the about page, you will notice two things: some claims have odd long type names and there are more claims than you probably need in your application.
The long claim names come from Microsoft’s JWT handler trying to map some claim types to .NET’s ClaimTypes
class types. You can turn off this behavior with the following line of code (in Startup
).
This also means that you need to adjust the configuration for anti-CSRF protection to the new unique sub claim type:
AntiForgeryConfig.UniqueClaimTypeIdentifier = Constants.ClaimTypes.Subject;
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
I added this code to the Startup.cs
of my client and it shortened the claimtypes.
Update:
For newer versions of IdentityModel
, the property is called DefaultInboundClaimTypeMap
:
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
Make sure you run this line before you set up your Identity configuration.