scimgateway 4.2.7 → 4.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: node_js
2
2
 
3
3
  node_js:
4
- - "14"
4
+ - "16"
5
5
 
6
6
  sudo: false
7
7
 
package/README.md CHANGED
@@ -1169,11 +1169,23 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
1169
1169
 
1170
1170
  ## Change log
1171
1171
 
1172
+ ### v4.2.9
1173
+
1174
+ [Fixed]
1175
+
1176
+ - installation require nodejs >= v.16.0.0 due to previous dependencies bump
1177
+
1178
+ ### v4.2.8
1179
+
1180
+ [Fixed]
1181
+
1182
+ - PUT did not allow group name to be modified
1183
+
1172
1184
  ### v4.2.7
1173
1185
 
1174
1186
  [Added]
1175
1187
 
1176
- - new plugin configuration **scim.usePutGroupMemberOfUser** can be set to true or false, default false. `PUT /Users/<user>` will replace the user bjensen with body content. If body contains groups and usePutGroupMemberOfUser=true, groups will be set on user object (groups are member of user) instead of default user member of groups
1188
+ - new plugin configuration **scim.usePutGroupMemberOfUser** can be set to true or false, default false. `PUT /Users/<user>` will replace user with body content. If body contains groups and usePutGroupMemberOfUser=true, groups will be set on user object (groups are member of user) instead of default user member of groups
1177
1189
  - plugin-forwardinc renamed to plugin-soap
1178
1190
  - Dependencies bump
1179
1191
 
@@ -1280,6 +1280,7 @@ const ScimGateway = function () {
1280
1280
  ctx.body = e
1281
1281
  return
1282
1282
  }
1283
+ delete scimdata.id
1283
1284
  logger.debug(`${gwName}[${pluginName}] calling "${handle.modifyMethod}" and awaiting result`)
1284
1285
  try {
1285
1286
  await this[handle.modifyMethod](ctx.params.baseEntity, id, scimdata, ctx.ctxCopy)
@@ -1291,21 +1292,25 @@ const ScimGateway = function () {
1291
1292
  logger.debug(`${gwName}[${pluginName}] calling "${handle.getMethod}" and awaiting result`)
1292
1293
  const res = await this[handle.getMethod](ctx.params.baseEntity, { attribute: 'id', operator: 'eq', value: id }, ctx.query.attributes ? ctx.query.attributes.split(',').map(item => item.trim()) : [], ctx.ctxCopy)
1293
1294
 
1294
- if (!res || !res.Resources || !Array.isArray(res.Resources)) {
1295
- throw new Error(`using ${handle.getMethod} to retrive ${id} after ${handle.modifyMethod} - got invalid response: ${res}`)
1295
+ scimdata = {
1296
+ Resources: []
1296
1297
  }
1297
- if (res.Resources.length > 1) {
1298
- throw new Error(`using ${handle.getMethod} to retrive ${id} after ${handle.modifyMethod} - response returned ${res.Resources.length} objects`)
1299
- }
1300
- if (res.Resources.length === 0) {
1298
+ if (res) {
1299
+ if (res.Resources && Array.isArray(res.Resources)) {
1300
+ scimdata.Resources = res.Resources
1301
+ } else if (Array.isArray(res)) scimdata.Resources = res
1302
+ else if (typeof (res) === 'object') scimdata.Resources[0] = res
1303
+ else scimdata.Resources = []
1304
+ } else scimdata.Resources = []
1305
+ if (scimdata.Resources.length === 0 || scimdata.Resources.length > 1) {
1301
1306
  ctx.status = 204
1302
1307
  return
1303
1308
  }
1304
1309
 
1305
1310
  const location = ctx.origin + ctx.path
1306
1311
  ctx.set('Location', location)
1307
- res.Resources[0] = addPrimaryAttrs(res.Resources[0])
1308
- scimdata = utils.stripObj(res.Resources[0], ctx.query.attributes, ctx.query.excludedAttributes)
1312
+ const userObj = addPrimaryAttrs(scimdata.Resources[0])
1313
+ scimdata = utils.stripObj(userObj, ctx.query.attributes, ctx.query.excludedAttributes)
1309
1314
  scimdata = addSchemas(scimdata, handle.description, isScimv2)
1310
1315
  ctx.status = 200
1311
1316
  ctx.body = scimdata
@@ -1377,12 +1382,12 @@ const ScimGateway = function () {
1377
1382
  // merge cleared object with the new
1378
1383
  const newObj = utils.extendObj(clearedObj, jsonBody)
1379
1384
  delete newObj.id
1380
- delete newObj.userName
1381
- delete newObj.externalId
1382
1385
  delete newObj.schemas
1383
1386
  delete newObj.meta
1384
1387
  if (!config.scim.usePutGroupMemberOfUser) delete newObj.groups
1385
- if (handle.getMethod === handler.groups.getMethod) delete newObj.displayName
1388
+ // not allowing userName/displayName set to blank
1389
+ if (!newObj.userName) delete newObj.userName
1390
+ if (!newObj.displayName) delete newObj.displayName
1386
1391
 
1387
1392
  let [scimdata, err] = ScimGateway.prototype.convertedScim(newObj)
1388
1393
  if (err) throw err
@@ -1488,17 +1493,21 @@ const ScimGateway = function () {
1488
1493
  logger.debug(`${gwName}[${pluginName}] calling "${handle.getMethod}" and awaiting result`)
1489
1494
  res = await this[handle.getMethod](ctx.params.baseEntity, { attribute: 'id', operator: 'eq', value: id }, [], ctx.ctxCopy)
1490
1495
 
1491
- if (!res || !res.Resources || !Array.isArray(res.Resources)) {
1492
- throw new Error(`put using method ${handle.getMethod} - got unexpected response: ${JSON.stringify(res)}`)
1493
- }
1494
- if (res.Resources.length > 1) {
1495
- throw new Error(`put using method ${handle.getMethod} to retrive ${id} - response returned ${res.Resources.length} objects`)
1496
+ scimdata = {
1497
+ Resources: []
1496
1498
  }
1497
- if (res.Resources.length === 0) {
1499
+ if (res) {
1500
+ if (res.Resources && Array.isArray(res.Resources)) {
1501
+ scimdata.Resources = res.Resources
1502
+ } else if (Array.isArray(res)) scimdata.Resources = res
1503
+ else if (typeof (res) === 'object') scimdata.Resources[0] = res
1504
+ else scimdata.Resources = []
1505
+ } else scimdata.Resources = []
1506
+ if (scimdata.Resources.length === 0 || scimdata.Resources.length > 1) {
1498
1507
  ctx.status = 204
1499
1508
  return
1500
1509
  }
1501
- scimdata = res.Resources[0]
1510
+ scimdata = scimdata.Resources[0]
1502
1511
 
1503
1512
  // include groups
1504
1513
  if (!config.scim.usePutGroupMemberOfUser) { // default user member of group
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scimgateway",
3
- "version": "4.2.7",
3
+ "version": "4.2.9",
4
4
  "description": "Using SCIM protocol as a gateway for user provisioning to other endpoints",
5
5
  "author": "Jarle Elshaug <jarle.elshaug@gmail.com> (https://elshaug.xyz)",
6
6
  "homepage": "https://elshaug.xyz",
@@ -29,7 +29,7 @@
29
29
  "iga"
30
30
  ],
31
31
  "engines": {
32
- "node": ">=14.0.0"
32
+ "node": ">=16.0.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@godaddy/terminus": "^4.12.0",