scimgateway 4.1.1 → 4.1.2

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/README.md CHANGED
@@ -31,7 +31,7 @@ Latest news:
31
31
 
32
32
  ## Overview
33
33
 
34
- With SCIM Gateway we could do user management by using REST based [SCIM](http://www.simplecloud.info/) 1.1 or 2.0 protocol. Gateway will translate incoming SCIM requests and expose CRUD functionality (create, read, update and delete user/group) towards destinations using endpoint specific protocols. In other words, none SCIM-endpoints will become SCIM-endpoints. Gateway do not require SCIM to be used, it's also an API Gateway that could be used for other things than user provisioning.
34
+ With SCIM Gateway we can manage users and groups by using REST based [SCIM](http://www.simplecloud.info/) 1.1 or 2.0 protocol. Gateway translates incoming SCIM requests and expose CRUD functionality (create, read, update and delete user/group) towards destinations using endpoint specific protocols. In other words, none SCIM-endpoints will become SCIM-endpoints. Gateway do not require SCIM to be used, it's also an API Gateway that could be used for other things than user provisioning.
35
35
 
36
36
  SCIM Gateway is a standalone product, however this document shows how the gateway could be used by products like Symatec/Broadcom/CA Identity Manager.
37
37
 
@@ -1139,6 +1139,24 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
1139
1139
 
1140
1140
  ## Change log
1141
1141
 
1142
+ ### v4.1.2
1143
+ [Added]
1144
+
1145
+ - endpointMapper supporting one to many mappings using a comma separated list of attributes in the `mapTo`
1146
+
1147
+ Configuration example:
1148
+
1149
+ "map": {
1150
+ "user": {
1151
+ "PersonnelNumber": {
1152
+ "mapTo": "id,userName",
1153
+ "type": "string"
1154
+ },
1155
+ ...
1156
+ }
1157
+ }
1158
+
1159
+
1142
1160
  ### v4.1.1
1143
1161
  [Added]
1144
1162
 
@@ -1994,7 +1994,7 @@ ScimGateway.prototype.endpointMapper = function endpointMapper (direction, parse
1994
1994
  }
1995
1995
  }
1996
1996
  for (const key2 in mapObj) {
1997
- if (mapObj[key2].mapTo.toLowerCase() === key.toLowerCase()) {
1997
+ if (mapObj[key2].mapTo.split(',').map(item => item.trim().toLowerCase()).includes(key.toLowerCase())) {
1998
1998
  found = true
1999
1999
  if (mapObj[key2].type === 'array' && arrIndex && arrIndex >= 0) {
2000
2000
  dotNewObj[`${key2}.${arrIndex}`] = dotObj[keyOrg] // servicePlan.0.value => servicePlan.0 and groups[0].value => memberOf.0
@@ -2007,16 +2007,19 @@ ScimGateway.prototype.endpointMapper = function endpointMapper (direction, parse
2007
2007
  }
2008
2008
  } else { // string (get)
2009
2009
  const resArr = []
2010
- let strArr
2011
- if (Array.isArray(str)) strArr = str
2012
- else strArr = str.split(',').map(item => item.trim())
2010
+ let strArr = []
2011
+ if (Array.isArray(str)) {
2012
+ for (let i = 0; i < str.length; i++) {
2013
+ strArr = strArr.concat(str[i].split(',').map(item => item.trim())) // supports "id,userName" e.g. {"mapTo": "id,userName"}
2014
+ }
2015
+ } else strArr = str.split(',').map(item => item.trim())
2013
2016
  for (let i = 0; i < strArr.length; i++) {
2014
2017
  const attr = strArr[i]
2015
2018
  let found = false
2016
2019
  for (const key in mapObj) {
2017
- if (mapObj[key].mapTo === attr) {
2020
+ if (mapObj[key].mapTo && mapObj[key].mapTo.split(',').map(item => item.trim()).includes(attr)) { // supports { "mapTo": "userName,id" }
2018
2021
  found = true
2019
- resArr.push(key)
2022
+ if (!resArr.includes(key)) resArr.push(key)
2020
2023
  break
2021
2024
  } else if (attr === 'roles' && mapObj[key].mapTo === 'roles.value') { // allow get using attribute roles - convert to correct roles.value
2022
2025
  found = true
@@ -2098,7 +2101,10 @@ ScimGateway.prototype.endpointMapper = function endpointMapper (direction, parse
2098
2101
  mapTo = mapTo.replace('.', '##') // only first occurence
2099
2102
  noneCore = true
2100
2103
  }
2101
- dotNewObj[mapTo] = dotObj[key] // {"active": {"mapTo": "accountEnabled"} => str.replace("accountEnabled", "active")
2104
+ const arrMapTo = mapTo.split(',').map(item => item.trim()) // supports {"mapTo": "id,userName"}
2105
+ for (let i = 0; i < arrMapTo.length; i++) {
2106
+ dotNewObj[arrMapTo[i]] = dotObj[key] // {"active": {"mapTo": "accountEnabled"} => str.replace("accountEnabled", "active")
2107
+ }
2102
2108
  }
2103
2109
  let mapTo = mapObj[key].mapTo
2104
2110
  if (mapTo.startsWith('urn:')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scimgateway",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
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",