@itentialopensource/adapter-utils 4.48.9 → 4.48.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/CHANGELOG.md +20 -0
- package/lib/connectorRest.js +67 -0
- package/lib/restHandler.js +9 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
## 4.48.11 [04-03-2023]
|
|
3
|
+
|
|
4
|
+
* Add sso support to MSA
|
|
5
|
+
|
|
6
|
+
Closes ADAPT-2638
|
|
7
|
+
|
|
8
|
+
See merge request itentialopensource/adapter-utils!251
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 4.48.10 [03-24-2023]
|
|
13
|
+
|
|
14
|
+
* Added option to remove username and password from auth body and option to remove response headers
|
|
15
|
+
|
|
16
|
+
Closes ADAPT-2628
|
|
17
|
+
|
|
18
|
+
See merge request itentialopensource/adapter-utils!250
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
2
22
|
## 4.48.9 [03-23-2023]
|
|
3
23
|
|
|
4
24
|
* Add logic to strip escapes from the request body
|
package/lib/connectorRest.js
CHANGED
|
@@ -101,6 +101,7 @@ let healthcheck = false;
|
|
|
101
101
|
const healthchecklock = 0;
|
|
102
102
|
let encodeUri = true;
|
|
103
103
|
let authQueryEncode = null;
|
|
104
|
+
let addCreds = true;
|
|
104
105
|
|
|
105
106
|
// Other global variables
|
|
106
107
|
let id = null;
|
|
@@ -1726,12 +1727,40 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1726
1727
|
options.port = tokenSchema.sso.port;
|
|
1727
1728
|
}
|
|
1728
1729
|
|
|
1730
|
+
// specific token properties for auth request call
|
|
1731
|
+
if (callProperties && callProperties.mfa && callProperties.mfa.host) {
|
|
1732
|
+
options.hostname = callProperties.mfa.host;
|
|
1733
|
+
}
|
|
1734
|
+
if (callProperties && callProperties.mfa && callProperties.mfa.port) {
|
|
1735
|
+
options.port = callProperties.mfa.port;
|
|
1736
|
+
}
|
|
1737
|
+
if (callProperties && callProperties.mfa && callProperties.mfa.protocol) {
|
|
1738
|
+
// need to put protocol in token schema
|
|
1739
|
+
if (!tokenSchema) {
|
|
1740
|
+
tokenSchema = {
|
|
1741
|
+
sso: {
|
|
1742
|
+
protocol: callProperties.mfa.protocol
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
} else if (tokenSchema && !tokenSchema.sso) {
|
|
1746
|
+
tokenSchema.sso = {
|
|
1747
|
+
protocol: callProperties.mfa.protocol
|
|
1748
|
+
};
|
|
1749
|
+
} else if (tokenSchema && tokenSchema.sso && !tokenSchema.sso.protocol) {
|
|
1750
|
+
tokenSchema.sso.protocol = callProperties.mfa.protocol;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1729
1754
|
// If there is a token schema, need to take the data from there
|
|
1730
1755
|
if (tokenSchema) {
|
|
1731
1756
|
options.path = tokenSchema.entitypath;
|
|
1732
1757
|
options.method = tokenSchema.method;
|
|
1733
1758
|
}
|
|
1734
1759
|
|
|
1760
|
+
if (callProperties && callProperties.mfa && callProperties.mfa.path) {
|
|
1761
|
+
options.path = callProperties.mfa.path;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1735
1764
|
// if the path has a base path parameter in it, need to replace it
|
|
1736
1765
|
let bpathStr = '{base_path}';
|
|
1737
1766
|
if (options.path.indexOf(bpathStr) >= 0) {
|
|
@@ -2009,6 +2038,12 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
2009
2038
|
}
|
|
2010
2039
|
}
|
|
2011
2040
|
|
|
2041
|
+
if (actReqBody && !addCreds) {
|
|
2042
|
+
// remove the username and password from the creds
|
|
2043
|
+
delete creds.username;
|
|
2044
|
+
delete creds.password;
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2012
2047
|
if (tokenSchema.headers && tokenSchema.headers.Authorization) {
|
|
2013
2048
|
// remove the username and password from the creds
|
|
2014
2049
|
delete creds.username;
|
|
@@ -2537,6 +2572,25 @@ function buildMfaBody(prop, mfaStepConfiguration, callProperties) {
|
|
|
2537
2572
|
callProperties.mfa.stepBody[prop] = mfaStepConfiguration.requestFields[prop];
|
|
2538
2573
|
}
|
|
2539
2574
|
}
|
|
2575
|
+
|
|
2576
|
+
/* */
|
|
2577
|
+
function buildMfaSso(prop, mfaStepConfiguration, callProperties) {
|
|
2578
|
+
const origin = `${id}-connectorRest-buildMfaSso`;
|
|
2579
|
+
log.trace(origin);
|
|
2580
|
+
const fullPropertyValue = mfaStepConfiguration.sso[prop];
|
|
2581
|
+
// Check if fullPropertyValue has reference in curly braces (e.g., {getSubToken.responseFields.token})
|
|
2582
|
+
let propertyValue = fullPropertyValue;
|
|
2583
|
+
const matching = searchTextInCurlyBraces(fullPropertyValue);
|
|
2584
|
+
if (matching) {
|
|
2585
|
+
const matchedText = matching[0];
|
|
2586
|
+
propertyValue = matching[1];
|
|
2587
|
+
const resolvedValue = getReferencedMfaValue(propertyValue);
|
|
2588
|
+
callProperties.mfa[prop] = fullPropertyValue.replace(matchedText, resolvedValue);
|
|
2589
|
+
} else {
|
|
2590
|
+
callProperties.mfa[prop] = mfaStepConfiguration.sso[prop];
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2540
2594
|
/* */
|
|
2541
2595
|
function getReferencedMfaValue(propertyValue) {
|
|
2542
2596
|
const origin = `${id}-connectorRest-getReferencedMfaValue`;
|
|
@@ -2560,6 +2614,15 @@ function buildMfaStepData(step, callProperties) {
|
|
|
2560
2614
|
const mfaStepConfiguration = multiStepAuthCalls[step];
|
|
2561
2615
|
callProperties.mfa.stepBody = {};
|
|
2562
2616
|
callProperties.mfa.stepHeaders = {};
|
|
2617
|
+
if (mfaStepConfiguration.sso) {
|
|
2618
|
+
callProperties.mfa.host = '';
|
|
2619
|
+
callProperties.mfa.port = '';
|
|
2620
|
+
callProperties.mfa.protocol = '';
|
|
2621
|
+
callProperties.mfa.path = '';
|
|
2622
|
+
Object.keys(mfaStepConfiguration.sso).forEach((prop) => {
|
|
2623
|
+
buildMfaSso(prop, mfaStepConfiguration, callProperties);
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2563
2626
|
if (mfaStepConfiguration.requestFields) {
|
|
2564
2627
|
Object.keys(mfaStepConfiguration.requestFields).forEach((prop) => {
|
|
2565
2628
|
if (prop.startsWith('header')) {
|
|
@@ -3837,6 +3900,10 @@ class ConnectorRest {
|
|
|
3837
3900
|
if (typeof props.authentication.authQueryEncode === 'boolean') {
|
|
3838
3901
|
authQueryEncode = props.authentication.authQueryEncode;
|
|
3839
3902
|
}
|
|
3903
|
+
|
|
3904
|
+
if (typeof props.authentication.addCreds === 'boolean') {
|
|
3905
|
+
addCreds = props.authentication.addCreds;
|
|
3906
|
+
}
|
|
3840
3907
|
}
|
|
3841
3908
|
|
|
3842
3909
|
// set the stub mode (optional - default is false)
|
package/lib/restHandler.js
CHANGED
|
@@ -23,6 +23,7 @@ let returnRawGl = false;
|
|
|
23
23
|
let encodePath = true;
|
|
24
24
|
let encodeUri = true;
|
|
25
25
|
let stripEscapes = false;
|
|
26
|
+
let returnResponseHeaders = true;
|
|
26
27
|
// INTERNAL FUNCTIONS
|
|
27
28
|
/*
|
|
28
29
|
* INTERNAL FUNCTION: Get the best match for the mock data response
|
|
@@ -360,6 +361,10 @@ function handleRestRequest(request, entityId, entitySchema, callProperties, filt
|
|
|
360
361
|
delete retObject.reqHdr;
|
|
361
362
|
}
|
|
362
363
|
|
|
364
|
+
if (returnResponseHeaders === false && retObject.headers) {
|
|
365
|
+
delete retObject.headers;
|
|
366
|
+
}
|
|
367
|
+
|
|
363
368
|
// if we want the raw response
|
|
364
369
|
if (returnRawGl || (callProperties && callProperties.request && callProperties.request.return_raw)) {
|
|
365
370
|
retObject.raw = resObj.response;
|
|
@@ -1042,6 +1047,10 @@ class RestHandler {
|
|
|
1042
1047
|
this.globalRequest = properties.request.global_request;
|
|
1043
1048
|
globalRequestGl = this.globalRequest;
|
|
1044
1049
|
}
|
|
1050
|
+
|
|
1051
|
+
if (typeof properties.request.returnResponseHeaders === 'boolean') {
|
|
1052
|
+
returnResponseHeaders = properties.request.returnResponseHeaders;
|
|
1053
|
+
}
|
|
1045
1054
|
}
|
|
1046
1055
|
|
|
1047
1056
|
/**
|