ferrerojosh / nest-keycloak-connect

keycloak-nodejs-connect module for Nest
MIT License
318 stars 123 forks source link

Role merge (ALL) does not work #144

Closed BitDesert closed 1 month ago

BitDesert commented 1 year ago

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?

ferrerojosh commented 1 year ago

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.

sbabych commented 9 months ago

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>