feat: get filtered policy matching function support for consistency
timabilov opened this issue · comments
To mimic matchers behaviour for matching pattern function now we can filter by functions for each index.
Maybe not ideal performant solution, but the only one to keep consistency at least
e.get_filtered_policy(1, partial(keymatch_fn, "domain.*")),
p, admin, domain.*, data1, read
p, user, domain.1, data2, read
p, user, domain.1, data2, write
g, alice, user, *
g, bob, admin, domain.3
@ffyuanda @Zxilly @techoner @elfisworking
@timabilov looks like a good enhancement without breaking anything.
You commented on #920
Also its sad that matchers internals is not quite flexible to reuse them for filtering policies. I think that will be fair and more consistent rather than actual implementation. Because matcher is source of truth.
I agree with you, that it would be great to reuse the internals of matchers
.
Maybe we can refactor the code to make it reusable.
e.g. a call to get_filtered_policy
could look something like that:
e.get_filtered_policy('keyMatch2("domain.*", p.dom)'),
I'm not sure if these changes would be worthwhile, so perhaps someone else could give their opinion.
For now i use that temporary solution, so for me thats is fine solution
BTW Also do not know much about evaluators, but still because it is some evaluator there, it may be worse performance wise (relating to above impl).
But anyways, for consistency, maybe, i will take a look later when available, maybe it is not hard to implement that.
e.get_filtered_policy('keyMatch2("domain.*", p.dom)'),