I want to disable the JWT claims mapping in ASP.NET Core (not sure why it's there in the first place...) since the new names are much longer than the original ones (for example, instead of a simple oid claim, I need to access the http://schemas.microsoft.com/identity/claims/objectidentifier one).
According to the docs, this can be done by calling JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear() as early as possible in the Program.cs file.
However, no matter where I call this method, the claims are still mapped and I still can't access the oid claim.
What am I missing? Why doesn't the mapping get disabled?
Thanks!
You can set MapInboundClaims in your JwtBearerOptions to false.
So, the resulting code in your Program.cs should look something like this:
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
//other code
options.MapInboundClaims = false;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With