jelhub / scimgateway

Using SCIM protocol as a gateway for user provisioning to other endpoints
MIT License
175 stars 57 forks source link

When using the SCIM PUT url to update users/groups/serviceplan it always tries to fetch the users by id #125

Closed nsarupr closed 3 months ago

nsarupr commented 3 months ago

When updating a Users / Group / ServicePlan using the PUT SCIM Url, once the update is done, and we are trying to fetch the resource by ID, the library always fetches users.

This always ends up throwing 404 Users not found error.

https://github.com/jelhub/scimgateway/blob/28026b7b4800adf384f9dfeedc820d8147a6582e/lib/scimgateway.js#L1688C1-L1705C5

  router.put([`/(|scim/)(!${undefined}|Users|Groups|servicePlans)/:id`,
  `/:baseEntity/(|scim/)(!${undefined}|Users|Groups|servicePlans)/:id`], async (ctx) => {
    if (config.stream.publisher.enabled) {
      const streamObj = {
        handle: 'replaceUsrGrp',
        baseEntity: ctx.params.baseEntity,
        id: ctx.params.id,
        obj: ctx.request.body,
        ctxCopy: ctx.ctxCopy
      }
      logger.debug(`${gwName}[${pluginName}] publishing replaceUsrGrp to SCIM Stream and awaiting result`)
      await this.publish(streamObj)
    } else {
      await replaceUsrGrp(ctx)
    }
    ctx.request.originalUrl = ctx.params.baseEntity ? `/${ctx.params.baseEntity}/Users/${ctx.params.id}` : `/Users/${ctx.params.id}`
    return await getById(ctx)
  })
nsarupr commented 3 months ago

@jelhub can you please take a look into this?

jelhub commented 3 months ago

Now fixed in v4.5.5 Thanks