white-twilight-17165
10/13/2023, 12:40 PMClients, Groups and Users. If a User is a member of a Group which is an accessor of a Client, then the User has permission to access the client.
My OPL file:
import { Namespace, SubjectSet, Context } from "@ory/keto-namespace-types";
class User implements Namespace {}
class Group implements Namespace {
related: {
member: User[];
};
}
class Client implements Namespace {
related: {
accessor: SubjectSet<Group, "member">[];
};
permits = {
access: (ctx: Context) => this.related.accessor.includes(ctx.subject),
};
}
My relations in RTS (I have no idea what this syntax is officially called:
Group:admin#member@User:woodywoodsta
Client:uptime-kuma#accessor@Group:admin
My relations in JSON, as queried from what I currently have loaded into keto:
{
"relation_tuples": [
{
"namespace": "Client",
"object": "uptime-kuma",
"relation": "accessor",
"subject_set": {
"namespace": "Group",
"object": "admin",
"relation": ""
}
},
{
"namespace": "Group",
"object": "admin",
"relation": "member",
"subject_set": {
"namespace": "User",
"object": "woodywoodsta",
"relation": ""
}
}
],
"next_page_token": ""
}
If I check using a POST check with a body of:
{
"namespace": "Client",
"object": "uptime-kuma",
"relation": "access",
"subject_set": {
"namespace": "User",
"object": "woodywoodsta"
}
}
I get false, however it is my understanding that the this.related.accessor.includes(ctx.subject) portion of my OLP effectively defines the subject set rewrite. What am I misunderstanding here?white-twilight-17165
10/13/2023, 2:56 PMclass User implements Namespace {}
class Group implements Namespace {
related: {
member: User[];
};
permits = {
member: (ctx: Context) => this.related.member.includes(ctx.subject),
};
}
class Client implements Namespace {
related: {
accessor: Group[];
};
permits = {
access: (ctx: Context) =>
this.related.accessor.traverse((group) => group.permits.member(ctx)),
};
}
And this appears to indirectly give all members of accessors access to the client.
My question is now why using SubjectSet<> and a direct includes in the Client namespace permissions did not work the first time forcing me to explicitly write a check for the members relationship in the permissions of the Group namespace??
I’m very confused!white-twilight-17165
10/13/2023, 2:58 PMSubjectSet types?