@manyos/smileconnect-api 1.33.0 → 1.35.0
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/app.js +18 -3
- package/conf/adapterConfig.js +7 -0
- package/conf/clients.json +4 -2
- package/controller/cmdbobjectController.js +6 -6
- package/controller/scriptController.js +9 -8
- package/controller/taskController.js +13 -13
- package/controller/ticketController.js +8 -8
- package/controller/ticketWorkLogController.js +5 -5
- package/docs/general/config.md +9 -0
- package/package.json +1 -1
- package/test/incidentTest.js +2 -2
- package/util/auth.js +15 -1
package/app.js
CHANGED
|
@@ -11,6 +11,7 @@ const JwtStrategy = require('passport-jwt').Strategy,
|
|
|
11
11
|
const bodyParser = require('body-parser');
|
|
12
12
|
|
|
13
13
|
const config = require('./util/config');
|
|
14
|
+
const authUtil = require('./util/auth');
|
|
14
15
|
|
|
15
16
|
const cors = require('cors');
|
|
16
17
|
|
|
@@ -83,6 +84,8 @@ if (audienceArray.length > 0) {
|
|
|
83
84
|
opts.audience = audienceArray;
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
opts.passReqToCallback = true
|
|
88
|
+
|
|
86
89
|
// Do any necessary shutdown logic for our application here
|
|
87
90
|
const shutdown = (signal, value) => {
|
|
88
91
|
console.log("shutdown!");
|
|
@@ -130,18 +133,29 @@ app.use(compression()); //Compress all routes
|
|
|
130
133
|
|
|
131
134
|
log.debug('Passport Opts', opts);
|
|
132
135
|
passport.use(
|
|
133
|
-
new JwtStrategy(opts, function (jwt_payload, done) {
|
|
136
|
+
new JwtStrategy(opts, function (req, jwt_payload, done) {
|
|
134
137
|
//log.info(jwt_payload);
|
|
135
138
|
//log.info('token', jwt_payload.sub);
|
|
136
139
|
//TODO: Config error abfangen
|
|
137
140
|
//TODO: Add AdminScope and Impersonate
|
|
138
|
-
|
|
141
|
+
let clientId = jwt_payload[SSO_CLIENTNAME_ATTRIBUTE];
|
|
142
|
+
|
|
143
|
+
//check for master client
|
|
144
|
+
const requestedClientId = req.query.clientId
|
|
145
|
+
if (requestedClientId && authUtil.isMasterClient(clientId)) {
|
|
146
|
+
log.debug(`client ${clientId} acts as ${requestedClientId}`)
|
|
147
|
+
clientId = requestedClientId
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const clientConfig = config.getClientConfig(clientId)
|
|
151
|
+
clientConfig.clientId = clientId
|
|
152
|
+
|
|
139
153
|
const user = {
|
|
140
154
|
'id': jwt_payload.sub,
|
|
141
155
|
'azp': jwt_payload.azp,
|
|
142
156
|
'scope': jwt_payload.scope,
|
|
143
157
|
'exp': jwt_payload.exp,
|
|
144
|
-
'config':
|
|
158
|
+
'config': clientConfig,
|
|
145
159
|
'username': jwt_payload.preferred_username
|
|
146
160
|
}
|
|
147
161
|
log.debug('Passport User', jwt_payload);
|
|
@@ -159,6 +173,7 @@ passport.use(
|
|
|
159
173
|
|
|
160
174
|
app.use(bodyParser.json({limit: '200mb'}));
|
|
161
175
|
app.use(bodyParser.urlencoded({limit: '200mb', extended: true}));
|
|
176
|
+
|
|
162
177
|
//health check
|
|
163
178
|
app.use('/v1/health', function (req, res, next) {
|
|
164
179
|
res.json({status:"ok"})
|
package/conf/adapterConfig.js
CHANGED
|
@@ -9,6 +9,13 @@ const adapterParams = {
|
|
|
9
9
|
cacheTime: env.AR_CACHE_TTL || 300,
|
|
10
10
|
limitDefault: env.LIMIT_DEFAULT || 100,
|
|
11
11
|
limitMax: env.LIMIT_MAX
|
|
12
|
+
},
|
|
13
|
+
smileconnect: {
|
|
14
|
+
type: "SMILEconnect",
|
|
15
|
+
clientId: env.SC_CLIENT,
|
|
16
|
+
secret: env.SC_SECRET,
|
|
17
|
+
ssoUrl: env.SC_SSO_URL,
|
|
18
|
+
smileConnectUrl: env.SC_SMILECONNECT_URL
|
|
12
19
|
}
|
|
13
20
|
};
|
|
14
21
|
|
package/conf/clients.json
CHANGED
|
@@ -299,7 +299,7 @@ async function updateCmdbObject(ticketConfig, clientConfig, id, ciData, classId)
|
|
|
299
299
|
|
|
300
300
|
//run preScripts
|
|
301
301
|
if (scripts && scripts.preMapping) {
|
|
302
|
-
await scriptController.runScripts(scripts.preMapping, ciData);
|
|
302
|
+
await scriptController.runScripts(scripts.preMapping, ciData, clientConfig.clientId);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
const myClientConfig = {};
|
|
@@ -323,14 +323,14 @@ async function updateCmdbObject(ticketConfig, clientConfig, id, ciData, classId)
|
|
|
323
323
|
|
|
324
324
|
//run postMapping
|
|
325
325
|
if (scripts && scripts.postMapping) {
|
|
326
|
-
await scriptController.runScripts(scripts.postMapping, ciData);
|
|
326
|
+
await scriptController.runScripts(scripts.postMapping, ciData, clientConfig.clientId);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
const update = await arquery.updateEntry(formName, ci['Request ID'], ciData);
|
|
330
330
|
|
|
331
331
|
//run afterExecution
|
|
332
332
|
if (scripts && scripts.afterExecution) {
|
|
333
|
-
await scriptController.runScripts(scripts.afterExecution, ciData);
|
|
333
|
+
await scriptController.runScripts(scripts.afterExecution, ciData, clientConfig.clientId);
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
return update;
|
|
@@ -365,7 +365,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
365
365
|
|
|
366
366
|
//run preScripts
|
|
367
367
|
if (scripts && scripts.preMapping) {
|
|
368
|
-
await scriptController.runScripts(scripts.preMapping, ciData);
|
|
368
|
+
await scriptController.runScripts(scripts.preMapping, ciData, clientConfig.clientId);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
const mapping = getClassMapping(classId);
|
|
@@ -377,7 +377,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
377
377
|
|
|
378
378
|
//run postMapping
|
|
379
379
|
if (scripts && scripts.postMapping) {
|
|
380
|
-
await scriptController.runScripts(scripts.postMapping, ciData);
|
|
380
|
+
await scriptController.runScripts(scripts.postMapping, ciData, clientConfig.clientId);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
ciData['Data Set Id'] = "BMC.ASSET"
|
|
@@ -388,7 +388,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
388
388
|
|
|
389
389
|
//run afterExecution
|
|
390
390
|
if (scripts && scripts.afterExecution) {
|
|
391
|
-
await scriptController.runScripts(scripts.afterExecution, ciData);
|
|
391
|
+
await scriptController.runScripts(scripts.afterExecution, ciData, clientConfig.clientId);
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
return instanceId;
|
|
@@ -45,7 +45,7 @@ function recFindByExt(base,ext,files,result) {
|
|
|
45
45
|
return result
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async function executeScriptInternal(scriptId, requestData, params, executedByScript) {
|
|
48
|
+
async function executeScriptInternal(scriptId, requestData, params, executedByScript, clientId) {
|
|
49
49
|
|
|
50
50
|
const code = await getGlobalScript(scriptId);
|
|
51
51
|
|
|
@@ -53,14 +53,14 @@ async function executeScriptInternal(scriptId, requestData, params, executedBySc
|
|
|
53
53
|
throw (`Script ${scriptId} does not exist!`);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
return executeCode(code, requestData, params, null, executedByScript);
|
|
56
|
+
return executeCode(code, requestData, params, null, executedByScript, clientId);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async function executeScript(scriptId, requestData, params) {
|
|
60
|
-
return executeScriptInternal(scriptId, requestData, params, false)
|
|
59
|
+
async function executeScript(scriptId, requestData, params, clientId) {
|
|
60
|
+
return executeScriptInternal(scriptId, requestData, params, false, clientId)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
async function executeCode(code, requestData, params, logStream, executedByScript) {
|
|
63
|
+
async function executeCode(code, requestData, params, logStream, executedByScript, clientId) {
|
|
64
64
|
//todo should only be added once
|
|
65
65
|
/*if (logStream) {
|
|
66
66
|
log.addStream(logStream);
|
|
@@ -69,7 +69,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
69
69
|
//try to set user data for sandbox
|
|
70
70
|
|
|
71
71
|
async function executeScriptByScript(scriptId, requestData, params) {
|
|
72
|
-
return executeScriptInternal(scriptId, requestData, params, true)
|
|
72
|
+
return executeScriptInternal(scriptId, requestData, params, true, clientId)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const sandbox = {
|
|
@@ -77,6 +77,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
77
77
|
params,
|
|
78
78
|
adapter,
|
|
79
79
|
log,
|
|
80
|
+
clientId,
|
|
80
81
|
script:executeScriptByScript,
|
|
81
82
|
env: process.env,
|
|
82
83
|
fetch:fetch
|
|
@@ -243,10 +244,10 @@ async function getGlobalScripts() {
|
|
|
243
244
|
return getScripts(path);
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
async function runScripts(scripts, data) {
|
|
247
|
+
async function runScripts(scripts, data, clientId) {
|
|
247
248
|
try {
|
|
248
249
|
for (let x = 0; x < scripts.length; x++) {
|
|
249
|
-
await executeScript(scripts[x], data);
|
|
250
|
+
await executeScript(scripts[x], data, undefined, clientId);
|
|
250
251
|
}
|
|
251
252
|
} catch (error) {
|
|
252
253
|
throw error;
|
|
@@ -70,21 +70,21 @@ async function createTask(clientConfig, rootForm, rootRequestId, taskData, creat
|
|
|
70
70
|
|
|
71
71
|
//run preScripts
|
|
72
72
|
if (scripts && scripts.preMapping) {
|
|
73
|
-
await scriptController.runScripts(scripts.preMapping, taskData);
|
|
73
|
+
await scriptController.runScripts(scripts.preMapping, taskData, clientConfig.clientId);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
taskData = mappingUtil.applyMapping2Remedy(taskData, mapping, clientConfig.task.constants, fields);
|
|
77
77
|
|
|
78
78
|
//run postScripts
|
|
79
79
|
if (scripts && scripts.postMapping) {
|
|
80
|
-
await scriptController.runScripts(scripts.postMapping, taskData);
|
|
80
|
+
await scriptController.runScripts(scripts.postMapping, taskData, clientConfig.clientId);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const taskResult = await arquery.createEntry('TMS:Task', taskData, clientConfig.options)
|
|
84
84
|
|
|
85
85
|
//run afterExecution
|
|
86
86
|
if (scripts && scripts.afterExecution) {
|
|
87
|
-
await scriptController.runScripts(scripts.afterExecution, data);
|
|
87
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
log.debug('Create Task Result', taskResult);
|
|
@@ -140,21 +140,21 @@ async function createWorklog(clientConfig, taskId, summary, text, attachment) {
|
|
|
140
140
|
|
|
141
141
|
//run preScripts
|
|
142
142
|
if (scripts && scripts.preMapping) {
|
|
143
|
-
await scriptController.runScripts(scripts.preMapping, data);
|
|
143
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig.taskWorklog.constants, fields);
|
|
147
147
|
|
|
148
148
|
//run postScripts
|
|
149
149
|
if (scripts && scripts.postMapping) {
|
|
150
|
-
await scriptController.runScripts(scripts.postMapping, data);
|
|
150
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const result = await arquery.createEntry('TMS:WorkInfo', data, clientConfig.options)
|
|
154
154
|
|
|
155
155
|
//run afterExecution
|
|
156
156
|
if (scripts && scripts.afterExecution) {
|
|
157
|
-
await scriptController.runScripts(scripts.afterExecution, data);
|
|
157
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
return(result);
|
|
@@ -196,7 +196,7 @@ function queryTasks(clientConfig, query) {
|
|
|
196
196
|
|
|
197
197
|
//run preScripts
|
|
198
198
|
if (scripts && scripts.preMapping) {
|
|
199
|
-
await scriptController.runScripts(scripts.preMapping, element);
|
|
199
|
+
await scriptController.runScripts(scripts.preMapping, element, clientConfig.clientId);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
//Apply mapping
|
|
@@ -212,7 +212,7 @@ function queryTasks(clientConfig, query) {
|
|
|
212
212
|
|
|
213
213
|
//run preScripts
|
|
214
214
|
if (scripts && scripts.postMapping) {
|
|
215
|
-
await scriptController.runScripts(scripts.postMapping, element);
|
|
215
|
+
await scriptController.runScripts(scripts.postMapping, element, clientConfig.clientId);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
return ({
|
|
@@ -252,7 +252,7 @@ async function queryWorklogs(clientConfig, query, mapping) {
|
|
|
252
252
|
|
|
253
253
|
//run preScripts
|
|
254
254
|
if (scripts && scripts.preMapping) {
|
|
255
|
-
await scriptController.runScripts(scripts.preMapping, element);
|
|
255
|
+
await scriptController.runScripts(scripts.preMapping, element, clientConfig.clientId);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
//Apply mapping
|
|
@@ -268,7 +268,7 @@ async function queryWorklogs(clientConfig, query, mapping) {
|
|
|
268
268
|
|
|
269
269
|
//run postScripts
|
|
270
270
|
if (scripts && scripts.postMapping) {
|
|
271
|
-
await scriptController.runScripts(scripts.postMapping, element);
|
|
271
|
+
await scriptController.runScripts(scripts.postMapping, element, clientConfig.clientId);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
return {
|
|
@@ -314,21 +314,21 @@ async function updateTask(clientConfig, id, taskData) {
|
|
|
314
314
|
|
|
315
315
|
//run preScripts
|
|
316
316
|
if (scripts && scripts.preMapping) {
|
|
317
|
-
await scriptController.runScripts(scripts.preMapping, taskData);
|
|
317
|
+
await scriptController.runScripts(scripts.preMapping, taskData, clientConfig.clientId);
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
taskData = mappingUtil.applyMapping2Remedy(taskData, mapping, taskConstants, fields);
|
|
321
321
|
|
|
322
322
|
//run postScripts
|
|
323
323
|
if (scripts && scripts.postMapping) {
|
|
324
|
-
await scriptController.runScripts(scripts.postMapping, taskData);
|
|
324
|
+
await scriptController.runScripts(scripts.postMapping, taskData, clientConfig.clientId);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
const result = await arquery.updateEntry('TMS:Task', id, taskData);
|
|
328
328
|
|
|
329
329
|
//run afterExecution
|
|
330
330
|
if (scripts && scripts.afterExecution) {
|
|
331
|
-
await scriptController.runScripts(scripts.afterExecution, taskData);
|
|
331
|
+
await scriptController.runScripts(scripts.afterExecution, taskData, clientConfig.clientId);
|
|
332
332
|
}
|
|
333
333
|
return result;
|
|
334
334
|
}
|
|
@@ -24,7 +24,7 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
24
24
|
|
|
25
25
|
//run preScripts
|
|
26
26
|
if (scripts && scripts.preMapping) {
|
|
27
|
-
await scriptController.runScripts(scripts.preMapping, data);
|
|
27
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const requestType = ticketConfig.requestType;
|
|
@@ -39,7 +39,7 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
39
39
|
|
|
40
40
|
//run postScripts
|
|
41
41
|
if (scripts && scripts.postMapping) {
|
|
42
|
-
await scriptController.runScripts(scripts.postMapping, data);
|
|
42
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options)
|
|
@@ -63,7 +63,7 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
63
63
|
|
|
64
64
|
//run afterExecution
|
|
65
65
|
if (scripts && scripts.afterExecution) {
|
|
66
|
-
await scriptController.runScripts(scripts.afterExecution, data);
|
|
66
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
67
67
|
}
|
|
68
68
|
return resultInterfaceCreate;
|
|
69
69
|
}
|
|
@@ -136,7 +136,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
136
136
|
const preScripts = scripts.preMapping;
|
|
137
137
|
try {
|
|
138
138
|
for (let x = 0; x < preScripts.length; x++) {
|
|
139
|
-
const result = await scriptController.executeScript(preScripts[x], ticket);
|
|
139
|
+
const result = await scriptController.executeScript(preScripts[x], ticket, null, clientConfig.clientId);
|
|
140
140
|
}
|
|
141
141
|
} catch (error) {
|
|
142
142
|
throw error;
|
|
@@ -160,7 +160,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
160
160
|
const postScripts = scripts.postMapping;
|
|
161
161
|
try {
|
|
162
162
|
for (let x = 0; x < postScripts.length; x++) {
|
|
163
|
-
const result = await scriptController.executeScript(postScripts[x], ticket);
|
|
163
|
+
const result = await scriptController.executeScript(postScripts[x], ticket, null, clientConfig.clientId);
|
|
164
164
|
}
|
|
165
165
|
} catch (error) {
|
|
166
166
|
throw error;
|
|
@@ -283,7 +283,7 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
|
283
283
|
|
|
284
284
|
//run preScripts
|
|
285
285
|
if (scripts && scripts.preMapping) {
|
|
286
|
-
await scriptController.runScripts(scripts.preMapping, ticketData);
|
|
286
|
+
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId);
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
log.debug(clientConfig[ticketConfig.requestType]);
|
|
@@ -300,14 +300,14 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
|
300
300
|
|
|
301
301
|
//run postMapping
|
|
302
302
|
if (scripts && scripts.postMapping) {
|
|
303
|
-
await scriptController.runScripts(scripts.postMapping, ticketData);
|
|
303
|
+
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId);
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData);
|
|
307
307
|
|
|
308
308
|
//run afterExecution
|
|
309
309
|
if (scripts && scripts.afterExecution) {
|
|
310
|
-
await scriptController.runScripts(scripts.afterExecution, ticketData);
|
|
310
|
+
await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
return update;
|
|
@@ -61,21 +61,21 @@ async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text
|
|
|
61
61
|
|
|
62
62
|
//run preScripts
|
|
63
63
|
if (scripts && scripts.preMapping) {
|
|
64
|
-
await scriptController.runScripts(scripts.preMapping, data);
|
|
64
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConstants, fields);
|
|
68
68
|
|
|
69
69
|
//run postScripts
|
|
70
70
|
if (scripts && scripts.postMapping) {
|
|
71
|
-
await scriptController.runScripts(scripts.postMapping, data);
|
|
71
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const result = arquery.createEntry(ticketConfig.forms.workLog, data, clientConfig.options)
|
|
75
75
|
|
|
76
76
|
//run afterExecution
|
|
77
77
|
if (scripts && scripts.afterExecution) {
|
|
78
|
-
await scriptController.runScripts(scripts.afterExecution, data);
|
|
78
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return result;
|
|
@@ -169,12 +169,12 @@ async function queryWorklogs(ticketConfig, clientConfig, query, mapping) {
|
|
|
169
169
|
const element = result.data[x];
|
|
170
170
|
//run preScripts
|
|
171
171
|
if (scripts && scripts.preMapping) {
|
|
172
|
-
await scriptController.runScripts(scripts.preMapping, result.data);
|
|
172
|
+
await scriptController.runScripts(scripts.preMapping, result.data, clientConfig.clientId);
|
|
173
173
|
}
|
|
174
174
|
applyMapping(element, mapping, 'Entry ID');
|
|
175
175
|
//run postScripts
|
|
176
176
|
if (scripts && scripts.postMapping) {
|
|
177
|
-
await scriptController.runScripts(scripts.postMapping, result.data);
|
|
177
|
+
await scriptController.runScripts(scripts.postMapping, result.data, clientConfig.clientId);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return {
|
package/docs/general/config.md
CHANGED
|
@@ -82,6 +82,15 @@ List of users who are allowed to access /v1/appconfig endpoints.
|
|
|
82
82
|
Sample:
|
|
83
83
|
ADMIN_USERS=username1, username2
|
|
84
84
|
|
|
85
|
+
### MASTER_CLIENTS
|
|
86
|
+
|
|
87
|
+
List of clients that can act on behalf of other clients.
|
|
88
|
+
|
|
89
|
+
The URL Parameter *clientId* is used for this.
|
|
90
|
+
|
|
91
|
+
Sample:
|
|
92
|
+
MASTER_CLIENTS=idm,adminTool
|
|
93
|
+
|
|
85
94
|
## Cache
|
|
86
95
|
|
|
87
96
|
### CACHETTL_CMDB
|
package/package.json
CHANGED
package/test/incidentTest.js
CHANGED
|
@@ -46,9 +46,9 @@ describe('Integration Tests - Incidents', function () {
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
it ('it should get all incidents', function (done) {
|
|
49
|
-
this.timeout(
|
|
49
|
+
this.timeout(25000);
|
|
50
50
|
chai.request(server)
|
|
51
|
-
.get('/v1/incidents')
|
|
51
|
+
.get('/v1/incidents?limit=10')
|
|
52
52
|
.set('Authorization', 'Bearer ' + authUser.access_token)
|
|
53
53
|
.end(function(err, res) {
|
|
54
54
|
res.should.have.status(200);
|
package/util/auth.js
CHANGED
|
@@ -19,6 +19,20 @@ function isAuthorizedAdmin(req, res, next) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
function isMasterClient(clientId) {
|
|
23
|
+
const masterClients = process.env.MASTER_CLIENTS;
|
|
24
|
+
if (masterClients !== null
|
|
25
|
+
&& masterClients !== undefined
|
|
26
|
+
&& clientId !== null
|
|
27
|
+
&& clientId !== undefined
|
|
28
|
+
&& isUserInList(masterClients, clientId)) {
|
|
29
|
+
log.debug('master client authorized', clientId);
|
|
30
|
+
return true
|
|
31
|
+
} else {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
function isUserInList(userList, userName) {
|
|
23
37
|
log.debug('Check if user is in List', userName, userList)
|
|
24
38
|
if (userList !== null && userList !== undefined && userName !== null && userName !== undefined) {
|
|
@@ -33,5 +47,5 @@ function isUserInList(userList, userName) {
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
module.exports = {
|
|
36
|
-
isAuthorizedAdmin
|
|
50
|
+
isAuthorizedAdmin, isMasterClient
|
|
37
51
|
}
|