nest-keycloak-connect icon indicating copy to clipboard operation
nest-keycloak-connect copied to clipboard

Role merge (ALL) does not work

Open BitDesert opened this issue 2 years ago • 2 comments

The role merger implemented in f540e4475008c1972876528763e3856411e08d52 and referenced in #127 does not work.

With the configuration option roleMerge: RoleMerge.ALL and a class decorator @Roles({ roles: ['role1'] }) and a handler decorator @Roles({ roles: ['role2'] }) handler I get the following error at nest-keycloak-connect/guards/role.guard.js:79:36:

ERROR [ExceptionsHandler] Found non-callable @@iterator
TypeError: Found non-callable @@iterator

https://github.com/ferrerojosh/nest-keycloak-connect/blob/69080fc9efaa750f2ee6148080255bc3d461e691/src/guards/role.guard.ts#L48-L54

This is probably due to Nest not being able to merge the array in the roles property. Related Nest function: https://github.com/nestjs/nest/blob/a80df520bc0f5847eece8d1fd0d5a6f10b3ab6a6/packages/core/services/reflector.service.ts#L52-L76

Did I implement it wrong or is a custom merge method needed?

BitDesert avatar Dec 12 '22 12:12 BitDesert

The nest function seem to be checking if it is an array. Does it have to do with the fact that we're passing an object instead ? It checks if a and b are objects and are merging them via object spread.

ferrerojosh avatar Dec 16 '22 13:12 ferrerojosh

same is here:

[Nest] 7605  - 02/06/2024, 1:05:30 PM   ERROR [ExceptionsHandler] Spread syntax requires ...iterable[Symbol.iterator] to be a function
TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function
  at RoleGuard.<anonymous> 

sbabych avatar Feb 06 '24 11:02 sbabych