GMG-Christine
07/26/2023, 11:24 AMvroldanbet
07/26/2023, 12:23 PMdefinition user {}
definition document {
relation parent_document: document#primary
relation viewer: user
relation primary: user:*
permission view = viewer & parent_document
}
the document has a relation to another document that is tagged as a "primary" document. That document has a "primary" relation which is a wildcard we can intersect with.
- if the parent_document
does not exist, the document won't show up in the LookupResources call
- if the parent_document
exists and has the "primary" flag enabled, it will show up in LookupResources callGMG-Christine
07/26/2023, 1:26 PMvroldanbet
07/26/2023, 6:11 PMLookupResources
to a subset of the graph. This feature request is described in https://github.com/authzed/spicedb/issues/1317
If you were OK with filtering on the client side the children of a specific document, I think you can implement this trivially by using recursion:
definition user {}
definition document {
relation parent: document
relation viewer: user
permission view = viewer + parent->view
}
GMG-Christine
07/27/2023, 6:46 AMvroldanbet
07/27/2023, 9:43 AM