stale-engineer-10188
03/06/2023, 5:14 AMimport { Context, Namespace, SubjectSet } from "@ory/keto-namespace-types"
class User implements Namespace {}
class Organisation implements Namespace {
related: {
administrators: User[]
managers: User[]
users: (User | SubjectSet<Organisation, "managers"> | SubjectSet<Organisation, "administrators">)[]
}
permits = {
view: (ctx: Context): boolean => this.related.users.includes(ctx.subject),
}
}
With this model, attempting to use Subject Sets, I assume I would only be required to add an "administrators" relation between an admin User and an Organisation, along with the SubjectSet relations being set up once. This does not appear to work.
When creating the relations, I run this js.
await Promise.all([
this.relations.createRelationship({
createRelationshipBody: {
namespace: "Organisation",
object: organisationId,
relation: "administrators",
subject_id: subjectId,
},
}),
this.relations.createRelationship({
createRelationshipBody: {
namespace: "Organisation",
object: organisationId,
relation: "users",
subject_set: {
namespace: "Organisation",
object: organisationId,
relation: "administrators"
},
},
}),
this.relations.createRelationship({
createRelationshipBody: {
namespace: "Organisation",
object: organisationId,
relation: "users",
subject_set: {
namespace: "Organisation",
object: organisationId,
relation: "managers"
},
},
}),
])
And querying via this doesn't get me any results.
this.relations.getRelationships({
namespace: "Organisation",
relation: "users",
subjectId,
}),
I'm hoping I'm just missing something really obvious here.Ory is the largest open source community in the world for cloud software application security. We maintain advanced open source security software solving authentication, authorization, access control, application network security, and delegation. Ory implements a variety of industry and best-practice standards including OAuth 2.0 / OAuth 2.1, OpenID Connect, Zero Trust Networking, Google Zanzibar Policy Framework, FIDO2 U2F, WebAuthn, TOTP, and more.
Powered by