👋 hi everyone, I’m curious whether
# spicedb
p
👋 hi everyone, I’m curious whether anyone has experience with what is the most scalable of two approaches. For a definition, we have a relationship that determines whether a resource has been made sharable. If not set, it’s private. We now need to be able to display whether the resource is private in the UI. The two options we are considering are: caching the sharable state in the DB so when we load the resource we already have all the data we need to display it and we just need to do an access check on SpiceDB. This requires that we keep the DB and SpiceDB in sync. Or, we can add a second call to SpiceDB to check whether the relationship is there and augment the results we get from the DB. We’ll need this for both querying for a single resource as well as querying for a list of resources.
y
it'd help to know what this part of your schema looks like more concretely
and also what determines whether something is shareable
if it's just "can this user share this thing," i'd make a second call to spicedb to check that permission
and another thing to remember is that you can use
CheckPermission
with any subject/permission/object tuple, not just user -> object
p
@yetitwo It’s more like “has this thing been shared” Basically when we list these resources we want to show whether something remains private to you alone or not
That’s on the “owner” side. For everyone else the relationship is used in the access check
y
right, but how is that expressed in your schema?
if it's just a question of "can any user that isn't me see this thing,"
LookupSubjects
might be useful
p
Kinda like this (excuse any syntax errors): definition user {} definition container { relation viewer: user permission view = viewer } definition thing { relation creator: user relation parent: container permission view = creator + parent->view }
So when the creator is the one viewing a thing, we need to check whether parent is set to decide whether we mark it as public or private in the UI.
Alternatively, we cache it in the DB
y
do you already know the container in question?
p
Yeah
y
then issue a check:
thing:123#parent@container:abc
p
Well my question is not how to check SpiceDB. It’s whether checking SpiceDB to display this flag in the UI is best practice or whether caching it in the DB is best and keeping SpiceDB to access and permission checks.
y
mmm... in my head this is still an access question
or at least it's answered by what's in SpiceDB
if youi're worried about load on SpiceDB, i wouldn't be - it's designed to be highly performant, this particular check would be very cheap, it's likely that it would end up cached because it's a part of other checks that you'd be making around the same time, and doing authorization checks to drive UI is a common pattern that we see
20 Views