jelhub / scimgateway

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

Provide sample on how to pass token to backend #90

Closed shiraze closed 1 year ago

shiraze commented 1 year ago

Following on from #75 it would be helpful if sample code showed how this could be done.

jelhub commented 1 year ago

Hi,

If you want to use the "as-is" PassThrough in plugin-scim, you may: replace https://github.com/jelhub/scimgateway/blob/master/lib/plugin-scim.js#L660 with options.headers.Authorization = ctx.request.header.authorization

If you want header to be updated on each request (in case password is changed and gateway not restarted), you must put logic below: https://github.com/jelhub/scimgateway/blob/master/lib/plugin-scim.js#L681 like: options.headers.Authorization = ctx.request.header.authorization

Regards, Jarle

jelhub commented 1 year ago

Line 660 should not be replaced as previously mentioned

Instead replace: https://github.com/jelhub/scimgateway/blob/master/lib/plugin-scim.js#L592 with: Authorization: ctx ? ctx.request.header.authorization : 'Basic ' + Buffer.from(`${config.entity[baseEntity].username}:${scimgateway.getPassword(`endpoint.entity.${baseEntity}.password`, configFile)}`).toString('base64')

jelhub commented 1 year ago

v4.2.4 now includes Auth PassThrough support for provided plugins