-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
While creating JWT for a user in my authentication service I use System.Security.Claims.ClaimTypes
static class with defined string constants for various claims. So, ClaimTypes.Role == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
:
var claims = new List<Claim>
{
new Claim("ID", user.Id.ToString()),
new Claim(ClaimTypes.Name, user.Username)
};
claims.AddRange(user.Roles.Select(role => new Claim(ClaimTypes.Role, role)));
Then, when for some Route in RouteClaimsRequirement I write: "http://schemas.microsoft.com/ws/2008/06/identity/claims/role" : "Admin"
"RouteClaimsRequirement": {
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role": "Admin"
}
Such Route just disappears somewhere in the guts of middleware (I didn't manage to track down where this happens) and a request results in 404 because a route is not found:
Error Code: UnableToFindDownstreamRouteError Message: Unable to find downstream route for path: /api/entities/, verb: POST errors found in ResponderMiddleware. Setting error response for request path:/api/entities/, request method: POST
When I use my own claim type like "Role", this works fine. So I assume there are some issues with (de)serialization of a string containing colons or slashes, basically as any URL.
Specifications
- Version: 12.0.1 - 19.0.2