<@U04UQ68083H> using OPL, given I have a namespace...
# ory-copilot
m
@chilly-king-10285 using OPL, given I have a namespace Post, how do I grant permission to edit anything in that namespace to anyone who is in namespace Administrator?
c
A message from kapa.ai
Based on the information provided in the extracts, you can define permissions in the Ory Permission Language (OPL) using TypeScript functions. These functions take a context containing the subject and answer permission checks based on the relationships the object has to the subject. Here's an example of how you might define the
edit
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.
Copy code
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).
m
How do I do that without manually creating an "editors" relationship on the post? i.e. an administrator inherently has that permission