@itentialopensource/adapter-utils 4.48.10 → 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 +10 -0
- package/lib/connectorRest.js +56 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
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
|
+
|
|
2
12
|
## 4.48.10 [03-24-2023]
|
|
3
13
|
|
|
4
14
|
* Added option to remove username and password from auth body and option to remove response headers
|
package/lib/connectorRest.js
CHANGED
|
@@ -1727,12 +1727,40 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1727
1727
|
options.port = tokenSchema.sso.port;
|
|
1728
1728
|
}
|
|
1729
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
|
+
|
|
1730
1754
|
// If there is a token schema, need to take the data from there
|
|
1731
1755
|
if (tokenSchema) {
|
|
1732
1756
|
options.path = tokenSchema.entitypath;
|
|
1733
1757
|
options.method = tokenSchema.method;
|
|
1734
1758
|
}
|
|
1735
1759
|
|
|
1760
|
+
if (callProperties && callProperties.mfa && callProperties.mfa.path) {
|
|
1761
|
+
options.path = callProperties.mfa.path;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1736
1764
|
// if the path has a base path parameter in it, need to replace it
|
|
1737
1765
|
let bpathStr = '{base_path}';
|
|
1738
1766
|
if (options.path.indexOf(bpathStr) >= 0) {
|
|
@@ -2544,6 +2572,25 @@ function buildMfaBody(prop, mfaStepConfiguration, callProperties) {
|
|
|
2544
2572
|
callProperties.mfa.stepBody[prop] = mfaStepConfiguration.requestFields[prop];
|
|
2545
2573
|
}
|
|
2546
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
|
+
|
|
2547
2594
|
/* */
|
|
2548
2595
|
function getReferencedMfaValue(propertyValue) {
|
|
2549
2596
|
const origin = `${id}-connectorRest-getReferencedMfaValue`;
|
|
@@ -2567,6 +2614,15 @@ function buildMfaStepData(step, callProperties) {
|
|
|
2567
2614
|
const mfaStepConfiguration = multiStepAuthCalls[step];
|
|
2568
2615
|
callProperties.mfa.stepBody = {};
|
|
2569
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
|
+
}
|
|
2570
2626
|
if (mfaStepConfiguration.requestFields) {
|
|
2571
2627
|
Object.keys(mfaStepConfiguration.requestFields).forEach((prop) => {
|
|
2572
2628
|
if (prop.startsWith('header')) {
|