-
Notifications
You must be signed in to change notification settings - Fork 14
Description
First of all, thanks for contributing this client to the OPA and Python ecosystems!
While browsing the source code of the check_permission function today, I noticed that it fetches the the policy identified by the policy_name argument for each request, and parses its AST JSON for the package path + rules, to use to build the actual policy query. This is extra roundtrip to OPA is quite inefficient and should normally not be needed, as the query path should either be known by the client beforehand (either via configuration, hard coded, or whatever makes the most sense), or it could query / for the default decision.
The query_rule function on the other hand looks like a fairly idiomatic approach. I would suggest making that the first and most prominent example under the Policy Evaluation section of the docs, and if not remove the check_permission example, at least include a disclaimer about the other method being the preferred one.