Crud: [Feature Request/Discussion] Multi Tenancy / Row level Authorization

Created on 23 Aug 2019  路  5Comments  路  Source: nestjsx/crud

I will soon need to implement some kind of Multi Tenancy / Row level Authorization (And even field level?) on top of nest/crud

And i would love to collect ideas to how to tackle it in the most integrated way.
If you did anything like that i would like to hear how you did it!

All 5 comments

I did not implement access control with nestjsx/crud. But I have a couple of thoughts. See example:

@Crud({
  model: { type: User }
})
@Controller("users")
export class UsersController {
  constructor(private readonly moduleRef: ModuleRef) {
  }

  @Override()
  getMany(
    @ParsedRequest() req: CrudRequest,
    @User() currentUser: User
  ) {
    const myCustomRepositoryWithAccessControl = new MyCustomRepositoryWithAccessControl(currentUser);
    const someOtherDependency = this.moduleRef.get(SomeOtherDependency);
    // Note: UsersService extends TypeOrmCrudService
    const usersService = new UsersService(myCustomRepositoryWithAccessControl, someOtherDependency);
    return usersService.getMany(req);
  }

}

@Bnaya does the new @CrudAuth() feature meet your request?

Is it documented yet?
I will try to play with it

@Bnaya new @CrudAuth() decorator is here

Looks very promising, didn't had time to try i yet
I'll close the issue and reopen if i will feel something is missing

Thanks!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arikon picture arikon  路  3Comments

dulkith picture dulkith  路  3Comments

cjancsar picture cjancsar  路  4Comments

lalalalaluk picture lalalalaluk  路  4Comments

btd1337 picture btd1337  路  4Comments