ThreeMammals/Ocelot

Ocelot doesn't handle correctly RouteClaimsRequirement with a key as an Url

Open

#679 aberto em 7 de nov. de 2018

Ver no GitHub
 (19 comments) (9 reactions) (0 assignees)C# (1.617 forks)batch import
AuthorizationSpring'26buggood first issuehelp wantedmedium effortproposal

Métricas do repositório

Stars
 (8.137 stars)
Métricas de merge de PR
 (Mesclagem média 10d 13h) (4 fundiu PRs em 30d)

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

Guia do colaborador