-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add OPAPathSelector to customize path selection #23
Comments
So the "other method" for doing this right now is by hitting a single opaPath and then doing the routing in rego, which was the approach we were originally thinking people would adopt as it centralizes the logic into rego instead of being split across the application/rego divide. What are your thoughts on that approach vs in-code? Do you have an example of where you would require or prefer in-code? |
Adding
For example, when using this library in an API Gateway (e.g., Spring Cloud Gateway), which supports various types of Authentication objects, we might want to select a specific policy based on attributes of each authentication object. That said, I agree that if the approach is to keep routing in rego to avoid splitting decision logic, it would be preferable to continue doing so. |
Routing in Rego when possible has the benefit of OPA reusing the same prepared query across all requests. But I agree that there are cases where you might have have a few entirely different queries, and having a distinct path to represent might be a better option. So I think this sound like a good addition. |
Expected behaviour
Enable clients to choose path based on incoming HTTP request.
Actual behaviour
Currently
opaPath
can only be set by constructor. This means that the sameopaPath
will be used for all HTTPrequests. However, to better structure the policies, it would be beneficial to be able to set the
opaPath
based onthe incoming HTTP request attributes (
Authentication
orRequestAuthorizationContext
objects).How to improve
OPAPathSelector
interface in the library:OPAAuthorizationManager
constructor(s) and be called in the opaRequest method:OPAAutoConfiguration
and defaultOPAAuthorizationManager
bean will be updated (depends on Add OPAAutoConfiguration to define common beans #22):OPAPathSelector
:The text was updated successfully, but these errors were encountered: