Relations that exist by default #463
Unanswered
nazar-kostiv-moodys
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @nazar-kostiv-moodys - for these situation we generally recommend having a higher level type - that will simplify things for you a lot. For example, model
schema 1.1
type user
type system
relations
define admin: [user]
type feature
relations
define system: [system]
define reader: [user]
define can_read: reader or admin from system Then you can either persist the system<>feature tuple by writing one whenever a feature is created - user: system:<a name for your system> # you probably will only have one, and that's OK
relation: system
object: feature:X Or if you don't want to persist that, you can always send that as a contextual tuple when checking for access on a feature (aka is the system behind this feature). Now when you want to assign someone as a system admin, it's as simple as adding a tuple - user: user:jimmy
relation: admin
object: system:<my system name> On check, a user will have access if they were either directly assigned or are a system admin |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Good time of day. Earlier this year we encountered a problem where we wanted to allow both granular and broad access to a given type.
We have solved it in the following manner:
With the above model, we can grant
user:A
ability to read a subset of features by creating direct relation to them. We can also grantuser:B
ability to read all current and future features but creatingadmin_access:feature -> reader -> user:B
. Relationship betweenfeature:X -> admin_access_ctx -> admin_access:feature
is then provided as contextual tuple at run-time (which means this only works for check operations and not for list operations).A useful piece of functionality would be to define a relation that exists by default for a given type. Something along the lines of
This way any feature instance that exists now (or will be added in the future) would be related to admin_access:feature. This is particularly useful when the instances of a given type are externally controlled and may appear/disapper without notice.
Beta Was this translation helpful? Give feedback.
All reactions