scimgateway 5.3.5 → 5.3.6

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.
Files changed (50) hide show
  1. package/.gitattribute +2 -0
  2. package/.github/dependabot.yml +0 -0
  3. package/.github/workflows/test-master.yml +0 -0
  4. package/.github/workflows/test-release.yml +0 -0
  5. package/.travis.yml +0 -0
  6. package/LICENSE +0 -0
  7. package/README.md +6 -0
  8. package/bun.lock +0 -0
  9. package/config/docker/DataDockerfile +0 -0
  10. package/config/docker/Dockerfile +0 -0
  11. package/config/docker/dbinit/init.sql +0 -0
  12. package/config/docker/docker-compose-debug.yml +0 -0
  13. package/config/docker/docker-compose-mssql.yml +0 -0
  14. package/config/docker/docker-compose.yml +0 -0
  15. package/config/plugin-entra-id.json +0 -0
  16. package/config/plugin-ldap.json +0 -0
  17. package/config/plugin-mongodb.json +0 -0
  18. package/config/plugin-mssql.json +0 -0
  19. package/config/plugin-saphana.json +0 -0
  20. package/config/plugin-soap.json +0 -0
  21. package/config/resources/Azure - ScimGateway.xml +0 -0
  22. package/config/wsdls/GroupService.wsdl +0 -0
  23. package/config/wsdls/UserService.wsdl +0 -0
  24. package/eslint.config.js +0 -0
  25. package/lib/countries.json +0 -0
  26. package/lib/helper-rest.ts +0 -0
  27. package/lib/logger.ts +0 -0
  28. package/lib/plugin-api.ts +0 -0
  29. package/lib/plugin-entra-id.ts +0 -0
  30. package/lib/plugin-ldap.ts +0 -0
  31. package/lib/plugin-loki.ts +0 -0
  32. package/lib/plugin-mongodb.ts +0 -0
  33. package/lib/plugin-mssql.ts +0 -0
  34. package/lib/plugin-saphana.ts +0 -0
  35. package/lib/plugin-scim.ts +0 -0
  36. package/lib/plugin-soap.ts +0 -0
  37. package/lib/postinstall.ts +0 -0
  38. package/lib/samlAssertion.ts +0 -0
  39. package/lib/scim-stream.js +0 -0
  40. package/lib/scimdef-v1.json +0 -0
  41. package/lib/scimdef-v2.json +0 -0
  42. package/lib/scimgateway.ts +20 -17
  43. package/lib/utils-scim.ts +0 -0
  44. package/lib/utils.ts +0 -0
  45. package/package.json +1 -1
  46. package/test/lib/plugin-api_test.ts +0 -0
  47. package/test/lib/plugin-loki_test.ts +0 -0
  48. package/test/lib/plugin-mongodb_test.ts_excluded +0 -0
  49. package/test/lib/plugin-scim_test.ts +0 -0
  50. package/tsconfig.json +0 -0
package/.gitattribute ADDED
@@ -0,0 +1,2 @@
1
+ * text=auto eol=lf
2
+
File without changes
File without changes
File without changes
package/.travis.yml CHANGED
File without changes
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1406,6 +1406,12 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
1406
1406
 
1407
1407
  ## Change log
1408
1408
 
1409
+ ### v5.3.6
1410
+
1411
+ [Fixed]
1412
+
1413
+ - Some minor ETag improvements
1414
+
1409
1415
  ### v5.3.5
1410
1416
 
1411
1417
  [Improved]
package/bun.lock CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/eslint.config.js CHANGED
File without changes
File without changes
File without changes
package/lib/logger.ts CHANGED
File without changes
package/lib/plugin-api.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -583,7 +583,9 @@ export class ScimGateway {
583
583
  }
584
584
 
585
585
  if (ctx.response.status && (ctx.response.status < 200 || ctx.response.status > 299)) {
586
- if (ctx.response.status === 404 || ctx.response.status === 412 || ctx.response.status === 304) {
586
+ if (ctx.response.status === 412 || ctx.response.status === 304) {
587
+ logger.info(`${gwName}[${pluginName}][${ctx?.routeObj?.baseEntity}] ${ellapsed} ${ctx.ip} ${userName} ${ctx.response.status} ${ctx.request.method} ${ctx.request.url} Inbound=${JSON.stringify(ctx.request.body)} Outbound=${outbound}`)
588
+ } else if (ctx.response.status === 404) {
587
589
  logger.warn(`${gwName}[${pluginName}][${ctx?.routeObj?.baseEntity}] ${ellapsed} ${ctx.ip} ${userName} ${ctx.response.status} ${ctx.request.method} ${ctx.request.url} Inbound=${JSON.stringify(ctx.request.body)} Outbound=${outbound}`)
588
590
  } else logger.error(`${gwName}[${pluginName}][${ctx?.routeObj?.baseEntity}] ${ellapsed} ${ctx.ip} ${userName} ${ctx.response.status} ${ctx.request.method} ${ctx.request.url} Inbound=${JSON.stringify(ctx.request.body)} Outbound=${outbound}`)
589
591
  } else logger.info(`${gwName}[${pluginName}][${ctx?.routeObj?.baseEntity}] ${ellapsed} ${ctx.ip} ${ctx.response.status} ${userName} ${ctx.request.method} ${ctx.request.url} Inbound=${JSON.stringify(ctx.request.body)} Outbound=${outbound}`)
@@ -1089,18 +1091,18 @@ export class ScimGateway {
1089
1091
  const userObj = scimdata.Resources[0]
1090
1092
  const eTag = utils.getEtag(userObj)
1091
1093
 
1092
- const eTagIfMatch = ctx.request.headers.get('if-match')
1093
- const eTagIfNoneMatch = ctx.request.headers.get('if-none-match')
1094
+ const eTagIfMatch = ctx.request.headers.get('if-match')?.split(',').map((item: string) => item.trim()).filter(Boolean)
1095
+ const eTagIfNoneMatch = ctx.request.headers.get('if-none-match')?.split(',').map((item: string) => item.trim()).filter(Boolean)
1094
1096
 
1095
1097
  if (eTag) {
1096
- if (eTagIfMatch && eTagIfMatch !== eTag) {
1098
+ if (eTagIfMatch && !eTagIfMatch.includes(eTag) && !eTagIfMatch.includes('*')) {
1097
1099
  ctx.response.headers.set('ETag', eTag)
1098
1100
  ctx.response.status = 412 // Precondition Failed
1099
1101
  const err = new Error(`ETag If-Match mismatch: ${eTagIfMatch} != ${eTag}`)
1100
1102
  const [e] = utilsScim.jsonErr(this.config.scimgateway.scim.version, pluginName, ctx.response.status, err)
1101
1103
  ctx.response.body = JSON.stringify(e)
1102
1104
  return
1103
- } else if (eTagIfNoneMatch && eTagIfNoneMatch === eTag) {
1105
+ } else if (eTagIfNoneMatch && (eTagIfNoneMatch.includes(eTag) || eTagIfNoneMatch.includes('*'))) {
1104
1106
  ctx.response.headers.set('ETag', eTag)
1105
1107
  ctx.response.status = 304 // Not Modified
1106
1108
  ctx.response.body = ''
@@ -1587,8 +1589,8 @@ export class ScimGateway {
1587
1589
 
1588
1590
  logger.debug(`${gwName}[${pluginName}][${ctx?.routeObj?.baseEntity}] [Modify ${handle.description}] id=${id}`)
1589
1591
 
1590
- const eTagIfMatch = ctx.request.headers.get('if-match')
1591
- const eTagIfNoneMatch = ctx.request.headers.get('if-none-match')
1592
+ const eTagIfMatch = ctx.request.headers.get('if-match')?.split(',').map((item: string) => item.trim()).filter(Boolean)
1593
+ const eTagIfNoneMatch = ctx.request.headers.get('if-none-match')?.split(',').map((item: string) => item.trim()).filter(Boolean)
1592
1594
  if (eTagIfMatch || eTagIfNoneMatch) {
1593
1595
  let eTag = ''
1594
1596
  if (handle.getMethod === handler.users.getMethod || handle.getMethod === handler.groups.getMethod) { // getUsers or getGroups implemented
@@ -1608,16 +1610,16 @@ export class ScimGateway {
1608
1610
  }
1609
1611
  }
1610
1612
  if (eTag)
1611
- if (eTagIfMatch && eTagIfMatch !== eTag) {
1613
+ if (eTagIfMatch && !eTagIfMatch.includes(eTag) && !eTagIfMatch.includes('*')) {
1612
1614
  ctx.response.headers.set('ETag', eTag)
1613
1615
  ctx.response.status = 412 // Precondition Failed
1614
1616
  const err = new Error(`ETag If-Match mismatch: ${eTagIfMatch} != ${eTag}`)
1615
1617
  const [e] = utilsScim.jsonErr(this.config.scimgateway.scim.version, pluginName, ctx.response.status, err)
1616
1618
  ctx.response.body = JSON.stringify(e)
1617
1619
  return
1618
- } else if (eTagIfNoneMatch && eTagIfNoneMatch === eTag) {
1620
+ } else if (eTagIfNoneMatch && (eTagIfNoneMatch.includes(eTag) || eTagIfNoneMatch.includes('*'))) {
1619
1621
  ctx.response.headers.set('ETag', eTag)
1620
- ctx.response.status = 304 // Not Modified
1622
+ ctx.response.status = 412 // Precondition Failed
1621
1623
  ctx.response.body = ''
1622
1624
  return
1623
1625
  }
@@ -1746,18 +1748,18 @@ export class ScimGateway {
1746
1748
  throw err
1747
1749
  }
1748
1750
 
1749
- const eTagIfMatch = headers ? headers.get('if-match') : undefined
1750
- const eTagIfNoneMatch = headers ? headers.get('if-none-match') : undefined
1751
+ const eTagIfMatch = headers ? headers.get('if-match')?.split(',').map((item: string) => item.trim()).filter(Boolean) : undefined
1752
+ const eTagIfNoneMatch = headers ? headers.get('if-none-match')?.split(',').map((item: string) => item.trim()).filter(Boolean) : undefined
1751
1753
  if (eTagIfMatch || eTagIfNoneMatch) {
1752
1754
  const eTag = utils.getEtag(currentObj)
1753
1755
  if (eTag) {
1754
- if (eTagIfMatch && eTagIfMatch !== eTag) {
1756
+ if (eTagIfMatch && !eTagIfMatch.includes(eTag) && !eTagIfMatch.includes('*')) {
1755
1757
  const err = new Error(`put using method ${handle.getMethod} error: ETag If-Match mismatch: ${eTagIfMatch} != ${eTag}`)
1756
1758
  err.name += '#412' // Precondition Failed
1757
1759
  throw err
1758
- } else if (eTagIfNoneMatch && eTagIfNoneMatch === eTag) {
1760
+ } else if (eTagIfNoneMatch && (eTagIfNoneMatch.includes(eTag) || eTagIfNoneMatch.includes('*'))) {
1759
1761
  const err = new Error(`put using method ${handle.getMethod} error: ETag If-None-Match mismatch: ${eTagIfNoneMatch} = ${eTag}`)
1760
- err.name += '#304' // Not Modified
1762
+ err.name += '#412' // Precondition Failed
1761
1763
  throw err
1762
1764
  }
1763
1765
  }
@@ -2758,9 +2760,10 @@ export class ScimGateway {
2758
2760
  idleTimeout,
2759
2761
  hostname, // hostname === 'localhost' ? hostname : undefined, // bun defaults to '0.0.0.0', but using '0.0.0.0.' or other ip like '127.0.0.1' becomes extremly slow - bun bug
2760
2762
  tls,
2761
- async fetch(req: Request & { raw: IncomingMessage }, srv) {
2763
+ async fetch(req, srv) {
2762
2764
  // start route processing and return response
2763
- return await route(req, srv.requestIP(req)?.address || '')
2765
+ const reqWithRaw = req as Request & { raw: IncomingMessage }
2766
+ return await route(reqWithRaw, srv.requestIP(req)?.address || '')
2764
2767
  },
2765
2768
  error(err) {
2766
2769
  logger.error(`${gwName} internal error: ${err.message}`)
package/lib/utils-scim.ts CHANGED
File without changes
package/lib/utils.ts CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scimgateway",
3
- "version": "5.3.5",
3
+ "version": "5.3.6",
4
4
  "type": "module",
5
5
  "description": "Using SCIM protocol as a gateway for user provisioning to other endpoints",
6
6
  "author": "Jarle Elshaug <jarle.elshaug@gmail.com> (https://elshaug.xyz)",
File without changes
File without changes
File without changes
File without changes
package/tsconfig.json CHANGED
File without changes