Reputation: 187
I have Auth Service hosted on some url. All my microservices requested validation to auth on each requests. In StartUp.cs of each services I have
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = WebConfigurationManager.AppSettings["IdentityServerURL"],
ValidationMode = ValidationMode.ValidationEndpoint,
//ValidationMode = ValidationMode.Local,
RequiredScopes = new[] { "user-api" },
});
It works fine! And in my controller's method in this case I have as you can see
{role: consumer}
But if I change
ValidationMode = ValidationMode.Local,
My request doesn't pass Authorization because values of roles has prefixes
And according to this my request doesn't pass autorization. What should I do in case
ValidationMode = ValidationMode.Local
to have normal value of claims role?
Upvotes: 0
Views: 896
Reputation: 1018
Microsoft apply a claims mapping when the token is received. To remove this default mapping, add this to your Configuration method at startup:
JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();
For more information:
How to use InboundClaimTypeMap for claim mapping?
Update of System.IdentityModel.Tokens.Jwt causing breaking change in IdentityServer3 Client
Upvotes: 1