many-night-84674
11/17/2023, 4:25 AMchilly-king-10285
11/17/2023, 4:25 AMchilly-king-10285
11/17/2023, 4:25 AMedit
permission for the Post
namespace for anyone in the Administrator
namespace. Please note that this is a hypothetical example and you may need to adjust it according to your specific needs and the actual structure of your namespaces. typescript import { Namespace, Context } from "@ory/keto-namespace-types" class Administrator implements Namespace {} class Post implements Namespace { related: { editors: Administrator[] } permits = { edit: (ctx: Context): boolean => this.related.editors.includes(ctx.subject), } }
In this example, the edit
permission is granted if the subject (the user making the request) is included in the editors
relationship of the Post
namespace. The editors
relationship is defined as an array of Administrator
instances, meaning that anyone in the Administrator
namespace has the edit
permission for the Post
namespace. For more detailed information on how to define permissions in OPL, you can refer to the [Ory documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model).many-night-84674
11/17/2023, 4:26 AM