great-crayon-86888
11/07/2023, 12:37 PMchilly-king-10285
11/07/2023, 12:37 PMchilly-king-10285
11/07/2023, 12:38 PMtypescript import { Namespace, Context } from "@ory/keto-namespace-types" class User implements Namespace {} class Report implements Namespace { related: { financialViewers: User[] marketingViewers: User[] communityViewers: User[] } permits = { viewFinancial: (ctx: Context): boolean => this.related.financialViewers.includes(ctx.subject), viewMarketing: (ctx: Context): boolean => this.related.marketingViewers.includes(ctx.subject), viewCommunity: (ctx: Context): boolean => this.related.communityViewers.includes(ctx.subject), } }
In this example, we define a Report
class with relationships to different types of viewers (financialViewers
, marketingViewers
, communityViewers
). These relationships represent the different user groups in your application that have access to the different types of reports. We then define permissions (viewFinancial
, viewMarketing
, viewCommunity
) that check if a user is included in the corresponding viewer group. These permissions can be used to control access to the different types of reports in your application. Please note that this is a simplified example and you might need to adjust it to fit the specific needs of your application. For more information on how to define a permission model using OPL, you can refer to the [Ory documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model).