wide-machine-60917
04/27/2023, 4:01 PMchilly-king-10285
04/27/2023, 4:01 PMchilly-king-10285
04/27/2023, 4:02 PMwide-machine-60917
04/27/2023, 4:07 PMchilly-king-10285
04/27/2023, 4:07 PMchilly-king-10285
04/27/2023, 4:08 PMwide-machine-60917
04/27/2023, 4:14 PMchilly-king-10285
04/27/2023, 4:14 PMchilly-king-10285
04/27/2023, 4:15 PMtypescript 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 = { write: (ctx: Context): boolean => this.related.editors.includes(ctx.subject), read: (ctx: Context): boolean => this.permits.write(ctx) || this.related.viewers.includes(ctx.subject), } }
2. Set up relationships and permissions using the Ory Console or the Ory CLI. You can find more information on configuring Ory Permissions in the [Configure Ory Permissions guide](https://www.ory.sh/docs/guides/cli/configure-permission-service). 3. To check permissions in your backend app, you can use the Check API. The Check API allows you to check if a user has a specific permission. Here's an example of how to use the Check API based on the [Basic concepts > Checking permissions](https://www.ory.sh/docs/guides/permissions/overview#get-started-with-ory-permissions) section: plaintext is users:user1 in readers of files:file1? // Yes
Unfortunately, the information extracts do not provide specific code examples for making API calls from your backend app. However, you can refer to the [Ory Keto API Reference](https://www.ory.sh/docs/keto/reference/api) for more details on how to interact with the API. Please note that the provided links and examples are for Ory Keto, which is a part of the Ory ecosystem. Make sure to review the documentation to understand how it fits into your use case.wide-machine-60917
04/27/2023, 4:19 PMchilly-king-10285
04/27/2023, 4:19 PMchilly-king-10285
04/27/2023, 4:19 PMwide-machine-60917
04/28/2023, 7:16 AMchilly-king-10285
04/28/2023, 7:16 AMchilly-king-10285
04/28/2023, 7:17 AM