Adding Advanced Authz message filters #2268
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims at adding advanced authz messages filetering based on the JMESPath syntax.
Introduction
Today Authz filtering on messages only has 3 filters :
AcceptedMessageKeysFilter
AcceptedMessagesFilter
AllowAllMessagesFilter
We propose to add a Fourth type called
JMESPathFilter
:This filter is able to include any condition in the filtering process. For instance, the following filter will match with
{"msg":{"foo":"bar"}}
but not with{"msg":{"foo":"not-bar"}}
:This allows for deeper message matching that is central to a better and more secure Authz experience, both for developers and and-users.
Core logic addition
Here's how the matching works :
map
message.false
is returned, the match fails and the whole authorization is denied.Why JMESPath
After experimenting with multiple matching logic engines for JSON (JQ, JSONPath, JMESPath), we decided to go ahead with
JMESPath
for the following reasons:escrow_nft.token_id == '1654' && escrow_nft.offered_amount == "uatom"
New Dependencies
We add the direct
github.com/jmespath/go-jmespath
dependency that resolves JMESPath matching.NOTES: