RNDude
10/26/2021, 7:36 PMproduct:dep_depId#department@department:depId
product_list:depId#department@department:depId
ecordell
10/26/2021, 8:39 PMproduct:dep_depId#department@department:depId
Then you can use the LookupResources API (https://buf.build/authzed/api/docs/main/authzed.api.v1#LookupResources) to find all products in a specific department.


Though one of the nice things about SpiceDB is that you really only have to store the information that you need to authorize against - so you might be better off leaving some of that in your application’s database and only storing relationships you care about for Authz decisions. LookupResources
is more useful for “what are all of the products that user X can access” more than “what are all of the products in department Y” (though certainly those concerns can overlap depending on the application)ecordell
10/26/2021, 8:39 PMecordell
10/26/2021, 8:39 PMLookup
is fast (and we have some
plans (https://github.com/authzed/spicedb/issues/207) to make it even faster) but it always requires more computation than a simple Check
- so if your application allows for a list
permission against an entire set of objects, that will be faster to compute in general.RNDude
10/26/2021, 8:49 PMJoey
10/26/2021, 8:51 PMJoey
10/26/2021, 8:52 PMJoey
10/26/2021, 8:52 PMJoey
10/26/2021, 8:52 PMJoey
10/26/2021, 8:52 PMRNDude
10/26/2021, 8:57 PMRNDude
10/26/2021, 8:57 PMJoey
10/26/2021, 9:00 PMRNDude
10/26/2021, 9:00 PMRNDude
10/26/2021, 9:00 PMJoey
10/26/2021, 9:00 PMJoey
10/26/2021, 9:01 PMJoey
10/26/2021, 9:01 PMExpand
Joey
10/26/2021, 9:01 PMRNDude
10/26/2021, 9:01 PMRNDude
10/26/2021, 9:02 PMRNDude
10/26/2021, 10:04 PMJoey
10/26/2021, 10:05 PMpermission
expressionsJoey
10/26/2021, 10:05 PMRNDude
10/26/2021, 10:06 PMJoey
10/26/2021, 10:06 PMdefinition resource {
relation editor: user
relation viewer: user
permission view = viewer + editor
}
RNDude
10/26/2021, 10:06 PMJoey
10/26/2021, 10:06 PMdefinition entity {
?RNDude
10/26/2021, 10:06 PMJoey
10/26/2021, 10:07 PMRNDude
10/26/2021, 10:09 PMmixin crud {
relation editor: user
relation viewer: user
permission create = editor
permission read = editor + viewer
permission update = editor
permission delete = editor
}
definition book {
mixin crud
}
definition car {
mixin crud
}
definition movie {
mixin crud
}
RNDude
10/26/2021, 10:10 PMJoey
10/26/2021, 10:10 PMJoey
10/26/2021, 10:11 PMcrud
resource type if it is going to share the same modelRNDude
10/26/2021, 10:11 PMRNDude
10/26/2021, 10:12 PMdefinition car {
mixin crud
relation owner : user
}
RNDude
10/26/2021, 10:12 PMJoey
10/26/2021, 10:15 PMJoey
10/26/2021, 10:16 PMJake
10/27/2021, 2:03 AMJake
10/27/2021, 2:03 AMRNDude
10/27/2021, 7:06 AMRNDude
10/27/2021, 7:08 AMRNDude
10/27/2021, 7:08 AM