Joey
03/03/2022, 10:31 PMJoey
03/03/2022, 10:31 PMJoey
03/03/2022, 10:35 PMJoey
03/03/2022, 10:40 PMBryan
03/03/2022, 10:51 PMtnarg
03/07/2022, 5:25 PMJoey
03/07/2022, 5:41 PMdefinition user {
relation viewer_only: user
permission all = viewer_only
}
definition document {
relation writer: user#all
relation reader: user#all | user#viewer_only
permission edit = writer
permission view = reader + edit
}
in this example, you grant a role on document
to either user#all
or to user#viewer_only
. Then, at check time, you can check for user:whomever#all
as the subject or user:whomever#viewer_only
, and it'll "scope down" based on that. Since #all
also includes the lower "scopes", it'll handle that case too
Playground link here: https://play.authzed.com/s/NvrMRnPDnnT4/Joey
03/07/2022, 5:42 PMtnarg
03/07/2022, 6:37 PMJoey
03/07/2022, 6:44 PMJoey
03/07/2022, 6:45 PMwriter
and reader
Joey
03/07/2022, 6:52 PMJoey
03/07/2022, 6:52 PMcheck document:somedoc#view@user:someuser#all
Joey
03/07/2022, 6:52 PM#all
in the reader
or writer
, then its found the subject and terminatesJoey
03/07/2022, 6:53 PMcheck document:somedoc#view@user:someuser#viewer_only
, SpiceDB will walk #all
(if it exists for that user) to viewer_only
and then stop thereJoey
03/07/2022, 6:53 PMviewer_only
relation (in this example)tnarg
03/07/2022, 7:03 PMJoey
03/07/2022, 7:19 PMJoey
03/07/2022, 7:20 PMJoey
03/07/2022, 7:20 PMviewer_only
of the user" rather than the user as a wholeNick
03/08/2022, 1:36 PMNick
03/08/2022, 1:36 PMNick
03/08/2022, 1:37 PMNick
03/08/2022, 1:38 PMNick
03/08/2022, 1:38 PMNick
03/08/2022, 1:39 PMJake
03/08/2022, 1:42 PMNick
03/08/2022, 1:42 PMNick
03/08/2022, 1:43 PMJake
03/08/2022, 1:45 PM