RouteClaimsRequirement not enforced even when token is authenticated and contains required claim
#2293
Replies: 3 comments 9 replies
|
Hello, @Naihan ! Is this a question or a bug?
OK And what's inside of the
And where is located JWT setup? Where and how do you add JWT handler aka AddJwtBearer method? |
I have come across discussions or repo issues suggesting that claim names in the form of links are not supported in Ocelot. This could potentially pose an issue. I will look into related at a later time. TODO → Search for RouteClaimsRequirement |
|
hay @raman-m It might be a bug... the builder.Services.AddMicrosoftIdentityWebApiAuthentication(builder.Configuration, configSectionName: "AzureAd"); adds a Bearer scheme |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When using
RouteClaimsRequirementin Ocelot with Azure AD and a validated JWT token, Ocelot logs "No authorization needed for upstream path" and does not enforce the claim check, even though:AuthenticationOptionsandRouteClaimsRequirementExpected behavior, Ocelot should:
RouteClaimsRequirementc# code
ocelot.json
{ "Routes": [ { "DownstreamPathTemplate": "/data", "DownstreamScheme": "https", "DownstreamHostAndPorts": [ { "Host": "api.example.com", "Port": 443 } ], "UpstreamPathTemplate": "/data", "UpstreamHost": "grafana.example.com", "UpstreamHttpMethod": [ "GET", "POST", "PUT", "DELETE" ], "AuthenticationOptions": { "AuthenticationProviderKey": "Bearer" }, "RouteClaimsRequirement": { "http://schemas.microsoft.com/ws/2008/06/identity/claims/role": [ "non-exiting-role" ] } } ], "GlobalConfiguration": { "BaseUrl": "https://localhost:5000" }the jwt contains a claim :
logs show:
full log:
All reactions