helpful-laptop-78221
01/30/2024, 7:02 AMchilly-king-10285
01/30/2024, 7:02 AMchilly-king-10285
01/30/2024, 7:02 AMtypescript import { Namespace, Context } from "@ory/keto-namespace-types" class User implements Namespace {} class Document implements Namespace { // All relationships for a single document. related: { editors: User[] viewers: User[] } // The permissions derived from the relationships and context. permits = { // A permission is a function that takes the context and returns a boolean. It can reference `this.related` and `this.permits`. write: (ctx: Context): boolean => this.related.editors.includes(ctx.subject), read: (ctx: Context): boolean => this.permits.write(ctx) || this.related.viewers.includes(ctx.subject), } }
For self-hosting Ory services, you should use the respective client. More information about self-hosting can be found in the [self-hosting documentation](https://www.ory.sh/docs/ecosystem/projects) for each service under Reference/SDK. Before using the SDK, consult the Ory [REST API documentation](https://www.ory.sh/docs/reference/api), which includes code samples and examples for various programming languages. Sources: - [Ory Permission Language](https://www.ory.sh/docs/keto#ory-permission-language) - [Ory SDK](https://www.ory.sh/docs/sdk)