Hi, all~ I have a question. If I want to label a r...
# spicedb
y
Hi, all~ I have a question. If I want to label a resource in the system as ‘public’ so that all users within the system can use this resource object, and the ‘public’ label can be added or removed at any time, how should I design it elegantly using a spiceDB schema? Or is the best practice using an external database to record whether a specific resource has a ‘public’ label? -------------------- I checked document again, and found this: https://authzed.com/docs/reference/schema-lang#wildcards if I use this wildcard feature to achieve
public
label, I thought it would be:
Copy code
definition resource {
    relation parent: system

    permission edit = parent->admin
    permission use = user
}

definition public_resource {
    relation parent: system

    permission edit = parent->admin
    permission use = user:*
}
At first, I have a random-resource instance in my system. I'd write relationship
public_resource:random-resource#use@user:*
to label random-resource public. And if I want to remove public label from random-resource, i'd delete relationship
public_resource:random-resource#use@user:*
and write
resource:random-resource#use@user:someone
2 Views