-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Policy-based authorization, How to configure the policy name for the ReRoute #265
Comments
@yiluomyt thanks for your interest in the project!! :) You have access to the ReRoute on the ctx object. ctx.DownstreamReRoute this should give you information that you can use to decide which policy to use. You would need a mapping between policies and ReRoutes somewhere if you used a dictionary something like this //somewhere when application starts
var reRouteToPolicy = new Dictionary<string, string>();
reRouteToPolicy.Add("ReRoute.Key from configuration.json", "policyName");
//below is pseudo code I would recommend putting into ioc
services.Add(reRouteToPolicy);
//then in middleware
var policies = context.HttpContext.RequestServices.GetService<Dictionary<string, string>>();
var policyForReRoute = policies[ctx.DownstreamReRoute.Key];
//use policy I hope that helps! |
It worked! Thanks for your help. |
Hi , how can I configure DownstramReRote.Key? "GlobalConfiguration": { Best Wishes, |
@miemengniao what does your middleware look like? |
downstream key is simply a key for rereoute and it works if it hits a reroute with a key, it took me a while to find it in the docs |
I am new to Ocelot. I have a question. The following is the scenario. I call an authentication web api from Ocelot using the configuration.json as below.
That authentication web api project has the following code
In the ocelot API project, I have the following in startup
Here is the authorization handler in the ocelot api project
So basically, during authentication I set the claim "OfficeUser" as "true" and try to use that in the authorizationhandler of ocelot api project to evaluate to success or failure. It is not working. I don't get the claims in the httpContext.User object. Is my approach here totally wrong? Or is it that I am missing something? Please help. |
Expected Behavior / New Feature
I would like to override the AuthorisationMiddleware to use the policy-based authorization.
Actual Behavior / Motivation for New Feautre
According to the document, now I try this way to achieve.
But how can I configure different policies for different reroutes?
Thank you
Specifications
The text was updated successfully, but these errors were encountered: