stale-engineer-10188
08/03/2022, 5:59 AMnarrow-van-43826
08/03/2022, 6:49 AMitems:*#view@user
, then use this set of IDs to filter in the application DB, or
• Query the application DB first, then (batch) query Keto.
Both approaches work, and which one you choose should depend on if you expect Keto or your DB query to filter out more, and then do the stricter filter first.
However, as you noted, this will not scale to very large lists, since we are always hitting two services. @steep-lamp-91158, @fast-lunch-54279 and I just talked about how to better solve this in the future, so we are still ideating, feel free to chime in. Some thoughts:
• Directly translating a check request to a (partial) SQL query as mentioned in the OPA article is infeasible to do in a generic way in Keto, especially with the advent of user-set rewrites (which uses recursive queries that are not possible to represent in plain SQL)
• We could expose "permission change stream" (including the "materialized" indirect tuples from subject set expansions and user-set rewrites) that would allow the application to mirror certain permission sets in their database to do an efficient JOIN
. E.g., in the application DB, you would have a table items_permissions
with columns "item_id", "user_id" and "relation", so that in order to get a list of items for a user you would do select * from items i join items_permissions p where (i.id = p.items_id and p.user_id = ? and p.relation = 'view')
As I said, we are still in the brainstorming phase here. Do you have any other ideas or use cases we should consider? Happy to chat 🙂.stale-engineer-10188
08/04/2022, 9:54 PM