getjerry / nest-casl

Casl integration for NestJS
MIT License
225 stars 29 forks source link

Multiple Abilities => UseAbility should be able to take in arrays #618

Open aniketbiprojit opened 1 year ago

aniketbiprojit commented 1 year ago

The implementation of the library either requires coupled permissions on multiple entities or different routes.

Let's say I want to define create on Entity1 and define delete on Entity2 => I will either need to couple the definitions or separate out routes.

Offered solution:

  @UseGuards(JwtAuthGuard, MultiAccessGuard)
  @UseMultiAbility([
    {
      action: Actions.update,
      subject: OrganizationEntity,
      subjectHook: OrganizationHook,
    },
    {
      action: Actions.create,
      subject: OrganizationUserEntity,
    },
    {
      action: Actions.create,
      subject: OrganizationRoleEntity,
    },
  ])

Currently using this solution in a local implementation. Would be good to have it available out of the box.

Similarly for the rest of the proxies.