green-kitchen-58087
03/09/2023, 11:57 AMsteep-lamp-91158
green-kitchen-58087
03/09/2023, 12:34 PM// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
// import { Namespace, SubjectSet, Context } from "@ory/keto-namespace-types"
/// <reference path="./lib.ts" />
class User implements Namespace {
related: {
manager: User[]
}
}
class Group implements Namespace {
related: {
members: (User | Group)[]
}
}
class Folder implements Namespace {
related: {
parents: (File | Folder)[]
viewers: SubjectSet<Group, "members">[]
}
permits = {
view: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.parents.traverse((p) => p.permits.view(ctx)),
}
}
class File implements Namespace {
related: {
parents: (File | Folder)[]
viewers: (User | SubjectSet<Group, "members">)[]
owners: (User | SubjectSet<Group, "members">)[]
}
// Some comment
permits = {
view: (ctx: Context): boolean =>
this.related.parents.traverse((p) => p.permits.view(ctx)) ||
this.related.viewers.includes(ctx.subject) ||
this.related.owners.includes(ctx.subject),
edit: (ctx: Context) => this.related.owners.includes(ctx.subject),
}
}
green-kitchen-58087
03/09/2023, 12:34 PM[
{
"namespace": "Group",
"object": "developer",
"relation": "members",
"subject_id": "patrik"
},
{
"namespace": "Group",
"object": "developer",
"relation": "members",
"subject_set": {
"namespace": "User",
"object": "Patrik"
}
},
{
"namespace": "Group",
"object": "developer",
"relation": "members",
"subject_set": {
"namespace": "User",
"object": "Henning"
}
},
{
"namespace": "Folder",
"object": "keto/",
"relation": "viewers",
"subject_set": {
"namespace": "Group",
"object": "developer",
"relation": "members"
}
},
{
"namespace": "File",
"object": "keto/README.md",
"relation": "parents",
"subject_set": {
"namespace": "Folder",
"object": "keto/"
}
},
{
"namespace": "Folder",
"object": "keto/src/",
"relation": "parents",
"subject_set": {
"namespace": "Folder",
"object": "keto/"
}
},
{
"namespace": "File",
"object": "keto/src/main.go",
"relation": "parents",
"subject_set": {
"namespace": "Folder",
"object": "keto/src/"
}
},
{
"namespace": "File",
"object": "private",
"relation": "owners",
"subject_set": {
"namespace": "User",
"object": "Henning"
}
}
]
green-kitchen-58087
03/09/2023, 12:36 PM{
"type": "union",
"children": [
{
"type": "leaf",
"tuple": {
"namespace": "",
"object": "",
"relation": "",
"subject_set": {
"namespace": "Folder",
"object": "keto/",
"relation": ""
}
}
}
],
"tuple": {
"namespace": "",
"object": "",
"relation": "",
"subject_set": {
"namespace": "File",
"object": "keto/README.md",
"relation": "parents"
}
}
}
green-kitchen-58087
03/09/2023, 12:37 PMsteep-lamp-91158
steep-lamp-91158
steep-lamp-91158
green-kitchen-58087
03/09/2023, 12:56 PMketo/README.md
object under the Folder
namespace as well?
What i mean is: If i ask the expand API to fetch me all the users who have permission on the File keto/README.md
indirectly via the parent of the File which in this case is keto/
, then how would we achieve it?steep-lamp-91158
steep-lamp-91158
green-kitchen-58087
03/09/2023, 1:15 PMsteep-lamp-91158
steep-lamp-91158
green-kitchen-58087
03/09/2023, 2:13 PMdelightful-gpu-48475
03/18/2023, 3:58 PMgreen-kitchen-58087
03/24/2023, 7:29 AMsteep-lamp-91158
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