@itentialopensource/adapter-utils 4.48.10 → 4.48.12
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 +61 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
## 4.48.12 [04-06-2023]
|
|
3
|
+
|
|
4
|
+
* Update msa to handle get auth request
|
|
5
|
+
|
|
6
|
+
Closes ADAPT-2641
|
|
7
|
+
|
|
8
|
+
See merge request itentialopensource/adapter-utils!252
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 4.48.11 [04-03-2023]
|
|
13
|
+
|
|
14
|
+
* Add sso support to MSA
|
|
15
|
+
|
|
16
|
+
Closes ADAPT-2638
|
|
17
|
+
|
|
18
|
+
See merge request itentialopensource/adapter-utils!251
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
2
22
|
## 4.48.10 [03-24-2023]
|
|
3
23
|
|
|
4
24
|
* 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) {
|
|
@@ -1965,6 +1993,11 @@ async function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1965
1993
|
|
|
1966
1994
|
// if this is not a get, need to add the info to the request
|
|
1967
1995
|
let creds = {};
|
|
1996
|
+
if (authMethod === 'multi_step_authentication') {
|
|
1997
|
+
const { stepBody, stepHeaders } = callProperties.mfa;
|
|
1998
|
+
Object.assign(creds, stepBody);
|
|
1999
|
+
Object.assign(options.headers, stepHeaders);
|
|
2000
|
+
}
|
|
1968
2001
|
if (options.method !== 'GET') {
|
|
1969
2002
|
if (authMethod === 'multi_step_authentication') {
|
|
1970
2003
|
const { stepBody, stepHeaders } = callProperties.mfa;
|
|
@@ -2544,6 +2577,25 @@ function buildMfaBody(prop, mfaStepConfiguration, callProperties) {
|
|
|
2544
2577
|
callProperties.mfa.stepBody[prop] = mfaStepConfiguration.requestFields[prop];
|
|
2545
2578
|
}
|
|
2546
2579
|
}
|
|
2580
|
+
|
|
2581
|
+
/* */
|
|
2582
|
+
function buildMfaSso(prop, mfaStepConfiguration, callProperties) {
|
|
2583
|
+
const origin = `${id}-connectorRest-buildMfaSso`;
|
|
2584
|
+
log.trace(origin);
|
|
2585
|
+
const fullPropertyValue = mfaStepConfiguration.sso[prop];
|
|
2586
|
+
// Check if fullPropertyValue has reference in curly braces (e.g., {getSubToken.responseFields.token})
|
|
2587
|
+
let propertyValue = fullPropertyValue;
|
|
2588
|
+
const matching = searchTextInCurlyBraces(fullPropertyValue);
|
|
2589
|
+
if (matching) {
|
|
2590
|
+
const matchedText = matching[0];
|
|
2591
|
+
propertyValue = matching[1];
|
|
2592
|
+
const resolvedValue = getReferencedMfaValue(propertyValue);
|
|
2593
|
+
callProperties.mfa[prop] = fullPropertyValue.replace(matchedText, resolvedValue);
|
|
2594
|
+
} else {
|
|
2595
|
+
callProperties.mfa[prop] = mfaStepConfiguration.sso[prop];
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2547
2599
|
/* */
|
|
2548
2600
|
function getReferencedMfaValue(propertyValue) {
|
|
2549
2601
|
const origin = `${id}-connectorRest-getReferencedMfaValue`;
|
|
@@ -2567,6 +2619,15 @@ function buildMfaStepData(step, callProperties) {
|
|
|
2567
2619
|
const mfaStepConfiguration = multiStepAuthCalls[step];
|
|
2568
2620
|
callProperties.mfa.stepBody = {};
|
|
2569
2621
|
callProperties.mfa.stepHeaders = {};
|
|
2622
|
+
if (mfaStepConfiguration.sso) {
|
|
2623
|
+
callProperties.mfa.host = '';
|
|
2624
|
+
callProperties.mfa.port = '';
|
|
2625
|
+
callProperties.mfa.protocol = '';
|
|
2626
|
+
callProperties.mfa.path = '';
|
|
2627
|
+
Object.keys(mfaStepConfiguration.sso).forEach((prop) => {
|
|
2628
|
+
buildMfaSso(prop, mfaStepConfiguration, callProperties);
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2570
2631
|
if (mfaStepConfiguration.requestFields) {
|
|
2571
2632
|
Object.keys(mfaStepConfiguration.requestFields).forEach((prop) => {
|
|
2572
2633
|
if (prop.startsWith('header')) {
|