yetitwo
03/29/2023, 7:10 PMrelation can_do_thing: user:*
on a role
can't just become relation can_do_thing: user:* | persona:*
. (as an aside: apparently that's syntactically correct, but spicedb doesn't evaluate it.)
one thing i want to explore is whether caveats can cover the hole, especially for the purposes of LookupSubjects
requests where we only want to return a list of users and not personas - essentially creating a caveat is_persona () {}
that allows for requests to specify that they want to exclude personas.
I'm not quite sure what it would mean in practice, though - would it be something like:
caveat persona (personas_desired bool, is_persona bool) {
(personas_desired && is_persona) || (!personas_desired && !is_persona)
}
be needed because some part of the context has to come from the request and some part has to come from the relation?
my other question is about what "optional" means - if I had:
relation user: user | user with persona
in my schema, one relationship with is_persona
in its context, and one relationship with no context attached, and I issued a LookupSubjects
request with personas_desired: false
, which of those relations would be returned?yetitwo
03/29/2023, 7:24 PMpersonas_desired: false
, it will exclude the personas, but if you say personas_desired: true
, it doesn't restrict it to the personas, and non-persona users are returned. why is that?vroldanbet
03/30/2023, 7:57 AMpersona
.
>basically we're trying to build a schema that uses the model from the cloud IAM blog post. one of our requirements is that we want to have a concept of "personas," which are owned by users and can be used to make authz calls as if they were users (there's a conversation to be had about whether this is really an authz concern, but this was the decision we made :P).
I would like to hear more about this usecase, could you provide a real life example of what this looks like?yetitwo
03/30/2023, 3:00 PMyetitwo
03/30/2023, 3:01 PMrelation can_do_thing: user:* | persona:*
is invalid? is there a reason it must be, or could it theoretically be implemented?yetitwo
03/30/2023, 3:29 PMyetitwo
03/30/2023, 3:30 PM&&
or set intersections on what comes back for the persona vs the user.yetitwo
03/30/2023, 3:39 PMyetitwo
03/30/2023, 3:47 PMyetitwo
03/30/2023, 4:03 PMpersona:my_persona
and then it seems to work!yetitwo
03/30/2023, 4:04 PMyetitwo
03/30/2023, 6:28 PMrole:my_role#can_do_thing@user:*
and role:my_role#can_do_thing@persona:*
, and then doing the (user + persona) & role->can_do_thing
in the permissionvroldanbet
03/31/2023, 11:07 AMvroldanbet
03/31/2023, 11:08 AMvroldanbet
03/31/2023, 11:10 AMvroldanbet
03/31/2023, 11:11 AMassertTrue:
- document:my_document#can_do_thing@user:my_user
- document:my_document#can_do_thing@persona:my_persona
assertFalse:
- document:my_other_document#can_do_thing@persona:my_persona
- document:my_other_document#can_do_thing@user:my_user
`
vroldanbet
03/31/2023, 11:11 AMuser
, but that's not its type. It's persona
vroldanbet
03/31/2023, 11:12 AMuser
named my_persona
and that user
does not exist.vroldanbet
03/31/2023, 11:35 AMpersona
object, and then it will have a relation to the owning user:
definition persona {
relation owner: user
}
vroldanbet
03/31/2023, 11:37 AMdefinition user {}
definition persona {
relation owner: user
}
definition role_binding {
relation user: user | persona#owner
relation role: role
permission can_do_thing = user & role->can_do_thing
}
definition role {
relation can_do_thing: user:* | persona:*
}
/** document represents a document protected by Authzed. */
definition document {
relation granted: role_binding
permission can_do_thing = granted->can_do_thing
}
vroldanbet
03/31/2023, 11:41 AMvroldanbet
03/31/2023, 11:42 AMvroldanbet
03/31/2023, 11:42 AMyetitwo
04/03/2023, 8:09 PMyetitwo
04/03/2023, 8:11 PMyetitwo
04/03/2023, 8:11 PMvroldanbet
04/11/2023, 10:41 AMuser
is allowed, the persona is allowed. So you really want to be able to authorize a persona by its ID, not by its owning user ID.
I'm in a rush now but I'll have to think a bit about it. You are basically describing two mostly unrelated subjects in the system that should have some sort of permission inheritance across them, but I'm not sure that's supported because spicedb treats them as independent subjects, only related through the edges of the graph and graph traversal semantics.vroldanbet
04/11/2023, 11:22 AMyetitwo
04/11/2023, 5:33 PMyetitwo
04/11/2023, 5:34 PMyetitwo
04/11/2023, 5:34 PMyetitwo
04/11/2023, 5:35 PMpermission do_something = (user + persona) & role->do_something
made things seem niceryetitwo
04/11/2023, 5:36 PMuser:* | persona:*
and make sure that we write both of those relations on the roleyetitwo
04/11/2023, 5:36 PM