scimgateway 4.2.10 → 4.2.11
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 +6 -0
- package/lib/scimgateway.js +22 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1169,6 +1169,12 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
|
|
|
1169
1169
|
|
|
1170
1170
|
## Change log
|
|
1171
1171
|
|
|
1172
|
+
### v4.2.11
|
|
1173
|
+
|
|
1174
|
+
[Added]
|
|
1175
|
+
|
|
1176
|
+
- Plugin can set error statusCode returned by scimgateway through error message. Error message must then contain string `"statusCode":xxx` where xxx is HTTP status code e.g., 401. Plugin using REST will have statusCode automatically included in error message thrown by plugin. This could be useful for auth.PassThrough.
|
|
1177
|
+
|
|
1172
1178
|
### v4.2.10
|
|
1173
1179
|
|
|
1174
1180
|
[Fixed]
|
package/lib/scimgateway.js
CHANGED
|
@@ -318,22 +318,35 @@ const ScimGateway = function () {
|
|
|
318
318
|
if (!userName && authType === 'Bearer') userName = 'token'
|
|
319
319
|
if (ctx.request.url !== '/favicon.ico') {
|
|
320
320
|
if (ctx.response.status < 200 || ctx.response.status > 299) {
|
|
321
|
-
|
|
321
|
+
// statusCode check in logResult method...
|
|
322
|
+
// "statusCode":xxx in error messages let plugin set error statusCode returned by scimgateway
|
|
323
|
+
let pluginStatusCode = 0
|
|
324
|
+
const reJson = '^.*"(statusCode)" *: *([0-9][0-9][0-9]).*'
|
|
325
|
+
const rePattern = new RegExp(reJson, 'i')
|
|
322
326
|
if (res.body.detail) {
|
|
323
|
-
|
|
327
|
+
const arrMatches = res.body.detail.match(rePattern)
|
|
328
|
+
if (Array.isArray(arrMatches) && arrMatches.length === 3) {
|
|
329
|
+
pluginStatusCode = parseInt(arrMatches[2])
|
|
330
|
+
}
|
|
324
331
|
} else if (res.body.Errors) {
|
|
325
|
-
if (Array.isArray(res.body.Errors) && res.body.Errors[0].description && res.body.Errors[0].description
|
|
326
|
-
|
|
332
|
+
if (Array.isArray(res.body.Errors) && res.body.Errors[0].description && res.body.Errors[0].description) {
|
|
333
|
+
const arrMatches = res.body.Errors[0].description.match(rePattern)
|
|
334
|
+
if (Array.isArray(arrMatches) && arrMatches.length === 3) {
|
|
335
|
+
pluginStatusCode = parseInt(arrMatches[2])
|
|
336
|
+
}
|
|
327
337
|
}
|
|
328
338
|
}
|
|
329
|
-
if (
|
|
330
|
-
ctx.response.
|
|
331
|
-
ctx.response.status = 401 // ctx.response.message becomes default 'Unauthorized'
|
|
332
|
-
ctx.response.body = { error: 'Access denied' }
|
|
339
|
+
if (pluginStatusCode > 0) {
|
|
340
|
+
ctx.response.status = pluginStatusCode // auto change ctx.response.message
|
|
333
341
|
res.statusCode = ctx.response.status
|
|
334
342
|
res.statusMessage = ctx.response.message
|
|
335
|
-
|
|
343
|
+
if (pluginStatusCode === 401 || pluginStatusCode === 403) { // don't reveal original SCIM error message details related to access denied (e.g. using Auth PassThrough)
|
|
344
|
+
ctx.response.set('Content-Type', 'application/json; charset=utf-8')
|
|
345
|
+
ctx.response.body = { error: 'Access denied' }
|
|
346
|
+
res.body = ctx.response.body
|
|
347
|
+
}
|
|
336
348
|
}
|
|
349
|
+
// back to logResult...
|
|
337
350
|
logger.error(`${gwName}[${pluginName}] ${ellapsed} ${ctx.request.ipcli} ${userName} ${ctx.request.method} ${ctx.request.href} Inbound = ${JSON.stringify(ctx.request.body)} Outbound = ${JSON.stringify(res)}${(config.log.loglevel.file === 'debug' && ctx.request.url !== '/ping') ? '\n' : ''}`)
|
|
338
351
|
} else logger.info(`${gwName}[${pluginName}] ${ellapsed} ${ctx.request.ipcli} ${userName} ${ctx.request.method} ${ctx.request.href} Inbound = ${JSON.stringify(ctx.request.body)} Outbound = ${JSON.stringify(res)}${(config.log.loglevel.file === 'debug' && ctx.request.url !== '/ping') ? '\n' : ''}`)
|
|
339
352
|
requestCounter += 1 // logged on exit (not win process termination)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scimgateway",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.11",
|
|
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",
|