anderseknert edited a comment on pull request #5734:
URL: https://github.com/apache/apisix/pull/5734#issuecomment-989932907


   > Ok, In that case, I would keeping the current way of combining URLs, which 
seems to provide better flexibility. XD
   
   I'm not sure that it's more flexible. It seems that currently all the fields 
are required to build the URL:
   
   ```lua
   required = {"host", "package", "decision"}
   ```
   But while not super common, it is perfectly legitimate to query OPA for only 
a package, like:
   
   ```
   http://localhost:8181/v1/data/policy
   ```
   
   When OPA is queried on the package level, it will evaluate all the rules 
under that package and return the result. So a policy that looks like the below:
   
   ```rego
   package policy
   
   default allow = false
   
   allow {
       input.user.roles[_] == "admin"
   }
   
   reason = "User needs to be admin" {
       not allow
   }
   ```
   
   When queried at `http://localhost:8181/v1/data/policy`, would respond with 
the result from evaluating both rules:
   
   ```json
   {
       "allow": false,
       "reason": "User needs to be admin"
   }
   ```
   
   In this case, we don't query a rule (or decision as it's called in this 
code) directly, but rather all the rules in the package.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to