microscopic-answer-24504
05/12/2023, 12:49 PMmagnificent-energy-493
wide-machine-60917
05/13/2023, 7:06 AMimport { Namespace, SubjectSet, Context } from "@ory/permission-namespace-types"
class Identity implements Namespace { }
class Supportal implements Namespace {
related: {
viewers: (Identity | Supportal)[]
editors: (Identity | Supportal)[]
}
permits = {
view: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.editors.includes(ctx.subject),
edit: (ctx: Context): boolean =>
this.related.editors.includes(ctx.subject)
}
}
class Bizops implements Namespace {
related: {
parents: Supportal[]
viewers: (Identity | SubjectSet<Supportal, "viewers">)[]
editors: (Identity | SubjectSet<Supportal, "editors">)[]
}
permits = {
view: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.editors.includes(ctx.subject) ||
this.related.parents.traverse((p) => p.permits.view(ctx)) ||
this.related.parents.traverse((p) => p.permits.edit(ctx)),
edit: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.editors.includes(ctx.subject) ||
this.related.parents.traverse((p) => p.permits.edit(ctx)),
}
}
Here is relationship I ran:
[
{
"namespace": "Supportal",
"object": "bizops",
"relation": "editors",
"subject_set": {
"namespace": "Identity",
"object": "luka"
}
},
{
"namespace": "Supportal",
"object": "bizops",
"relation": "viewers",
"subject_set": {
"namespace": "Identity",
"object": "david"
}
},
{
"namespace": "Bizops",
"object": "task",
"relation": "viewers",
"subject_set": {
"namespace": "Supportal",
"object": "bizops"
}
}
]
If you run this form CLI ory create relationships r.json
, most likely you will get the same issue.
I think the problem is with relation
field which I did not specify. So this is correct syntax I guess
"subject_set": {
"namespace": "Supportal",
"object": "bizops",
"relation": "viewers"
}
purple-match-65245
06/15/2023, 6:44 PMfull-scientist-465
08/07/2023, 11:59 AMfull-scientist-465
08/07/2023, 12:52 PMmagnificent-energy-493
steep-lamp-91158