NestJS - RBAC authorization guard with dynamic permissions

210 Views Asked by At

`

  1. Super Admin - create users, create admin, read, create, delete : all organizations

  2. Admin - read, create, delete : all organizations

  3. User - read, create, delete : specific organizations

Role Schema

  • name : superAdmin/admin/user
  • permissions : permisssion[]

Permission Schema

  • name : create user, create admin, read, create, delete
  • organizationAccess: organizationId[] `

I have predefined permissions for SuperAdmin and admin but, user can only have create, read, and delete for the specific organization that the user belongs to. how to implement this in a NEST guard? should I make another NEST guard for this? Please help me out.

0

There are 0 best solutions below