Proposal - Filter conditions as OPA Rego expressions #185
Replies: 3 comments 6 replies
-
Your assessment of the problem is spot on: Praxis is currently not nearly expressive enough in its filter invocation conditionals.
The underlying need is valid, but it's not clear to me that OPA Rego is the right solution for Praxis. Rego presents some significant challenges:
To be clear: I'm not definitively saying no. We should discuss this further. Please do, however, consider the above concerns and let me know your thoughts on them? 🤔 I want to brainstorm with you a bit, take a look at the problem from another angle. We currently lack the ability to express:
These have strong potential value, especially the combinators. For example we could add OR conditions: conditions:
- any:
- when:
path_prefix: "/api"
- when:
methods: ["POST"]Or nested NOT conditions: conditions:
- not:
when:
path_prefix: "/health"
methods: ["GET"]This would be a more natural extension of the existing conditional surface, requires zero dependencies, and keeps it all in the nanosecond operational space. Would this be adequate for our practical needs? LMKWYT 🤔 |
Beta Was this translation helpful? Give feedback.
-
|
The idea appealing. It allows for greater expressivity. When I read this proposal I thought hmm Lua, but that can be a security issue. A constrained vocabulary for defining behavoir is less risky. While the proposal is a great idea, the choice of any C++/C FFI call is "problematic" for Rust. Avoiding any FFI calls to any c/c++ code is .... preferable. Exceptions in C++ code are a pain and bad code causing a SEGV for instance won't be "caught" by default the Rust main. There is cxx which seems to cater for "wrapping" c++ exceptions. These concerns aside, increasing request / response latency or at least exec cpu/mem usage has been ... "problematic" for other proxies. While a workaround for related performance issues and attack surfaces can be implemented, it's probably a feature that can be refined and optimised for a subsequent release with detailed consideration for policies. |
Beta Was this translation helpful? Give feedback.
-
|
@mariusdanciu, @twghu and myself all seem to generally agree on the problem identified here and that we are inclined to solve it. We don't have alignment yet on how to solve the gap, but we have a path forward via prototyping, testing and benchmarking that I'm confident will get us there. So given the strong signal here I'm going to signoff on this discussion and say this is ready to move to a full-on proposal. Thank you for your efforts here @mariusdanciu! Please feel free to create an epic to track this (or I can if you prefer), and go to a proposal using that issue number. 🖖 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem description
Currently Praxis provide a simple but powerful enough mechanism to express when a Filter is invoked for request and response paths via the Conditions enum:
However admins would sometimes need a more flexible mechanism to allow them to express more complex logic (conjunctions, disjunctions, negations etc) for deciding when a filter should be used.
Proposal
The Condition enum support a 3-rd type of predicate "Rego" such as:
Conceptual example
Of course we would want to cache the "compiled" rego script and not parse it on each request. However this is an optimization detail out of the scope of this proposal. This also depends on what rego rust crate will be used (Regorus might be a good choice). But each crate uses it own API and ideally the Praxis structures should be decoupled from the underlying rego crates, so further abstraction would be needed.
Beta Was this translation helpful? Give feedback.
All reactions