@rockcarver/frodo-lib 0.18.2-0 → 0.18.3
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 +22 -2
- package/cjs/index.js +3 -1
- package/cjs/index.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +28 -12
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/esm/index.mjs +1 -0
- package/esm/ops/Saml2Ops.mjs +30 -14
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/ops/Saml2Ops.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.18.3] - 2023-01-27
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- rockcarver/frodo-cli#192: Backend support for better error handling and reporting in frodo-cli
|
|
15
|
+
|
|
16
|
+
## [0.18.2] - 2023-01-25
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- rockcarver/frodo-cli#52: Library support for script extract and watch functionality
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- rockcarver/frodo-cli#190: Frodo now properly imports previously exported saml providers.
|
|
25
|
+
|
|
10
26
|
## [0.18.2-0] - 2023-01-24
|
|
11
27
|
|
|
12
28
|
## [0.18.1] - 2023-01-20
|
|
@@ -14,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
30
|
### Changed
|
|
15
31
|
|
|
16
32
|
- Return service account name when calling `ConnectionProfile.getConnectionProfileByHost`.
|
|
17
|
-
- Save missing service account name when calling `
|
|
33
|
+
- Save missing service account name when calling `ConnectionProfile.saveConnectionProfile`.
|
|
18
34
|
|
|
19
35
|
### Fixed
|
|
20
36
|
|
|
@@ -1030,7 +1046,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1030
1046
|
- Fixed problem with adding connection profiles
|
|
1031
1047
|
- Miscellaneous bug fixes
|
|
1032
1048
|
|
|
1033
|
-
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.18.
|
|
1049
|
+
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.18.3...HEAD
|
|
1050
|
+
|
|
1051
|
+
[0.18.3]: https://github.com/rockcarver/frodo-lib/compare/v0.18.2...v0.18.3
|
|
1052
|
+
|
|
1053
|
+
[0.18.2]: https://github.com/rockcarver/frodo-lib/compare/v0.18.2-0...v0.18.2
|
|
1034
1054
|
|
|
1035
1055
|
[0.18.2-0]: https://github.com/rockcarver/frodo-lib/compare/v0.18.1...v0.18.2-0
|
|
1036
1056
|
|
package/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.state = exports.constants = exports.VariablesRaw = exports.Variables = exports.ValidationUtils = exports.Utils = exports.TypesRaw = exports.Types = exports.TreeRaw = exports.Theme = exports.StartupRaw = exports.Startup = exports.SocialIdentityProvidersRaw = exports.ServiceAccount = exports.Service = exports.SecretsRaw = exports.Secrets = exports.Script = exports.Saml2 = exports.Realm = exports.Organization = exports.OAuth2OIDCApi = exports.OAuth2Client = exports.NodeRaw = exports.Node = exports.ManagedObject = exports.Log = exports.LibVersion = exports.Journey = exports.Jose = exports.Info = exports.Idp = exports.IdmConfigRaw = exports.Idm = exports.ExportImportUtils = exports.EmailTemplate = exports.ConnectionProfile = exports.CirclesOfTrust = exports.AuthenticateRaw = exports.Authenticate = exports.AgentRaw = exports.Agent = exports.Admin = void 0;
|
|
6
|
+
exports.state = exports.constants = exports.VariablesRaw = exports.Variables = exports.ValidationUtils = exports.Utils = exports.TypesRaw = exports.Types = exports.TreeRaw = exports.Theme = exports.StartupRaw = exports.Startup = exports.SocialIdentityProvidersRaw = exports.ServiceAccount = exports.Service = exports.SecretsRaw = exports.Secrets = exports.Script = exports.Saml2 = exports.Realm = exports.Organization = exports.OAuth2OIDCApi = exports.OAuth2Client = exports.NodeRaw = exports.Node = exports.ManagedObject = exports.Log = exports.LibVersion = exports.Journey = exports.Jose = exports.Info = exports.Idp = exports.IdmConfigRaw = exports.Idm = exports.ExportImportUtils = exports.EmailTemplate = exports.ConnectionProfile = exports.CirclesOfTrust = exports.Base64 = exports.AuthenticateRaw = exports.Authenticate = exports.AgentRaw = exports.Agent = exports.Admin = void 0;
|
|
7
7
|
var _colors = _interopRequireDefault(require("colors"));
|
|
8
8
|
var _AgentRaw = _interopRequireWildcard(require("./api/AgentApi"));
|
|
9
9
|
exports.AgentRaw = _AgentRaw;
|
|
@@ -81,6 +81,8 @@ var _Variables = _interopRequireWildcard(require("./ops/cloud/VariablesOps"));
|
|
|
81
81
|
exports.Variables = _Variables;
|
|
82
82
|
var _Utils = _interopRequireWildcard(require("./ops/utils/OpsUtils"));
|
|
83
83
|
exports.Utils = _Utils;
|
|
84
|
+
var _Base = _interopRequireWildcard(require("./api/utils/Base64"));
|
|
85
|
+
exports.Base64 = _Base;
|
|
84
86
|
var _ValidationUtils = _interopRequireWildcard(require("./ops/utils/ValidationUtils"));
|
|
85
87
|
exports.ValidationUtils = _ValidationUtils;
|
|
86
88
|
var _LibVersion = _interopRequireWildcard(require("./ops/utils/Version"));
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Color","enable"],"sources":["index.ts"],"sourcesContent":["import Color from 'colors';\n\nColor.enable();\n\n// Api Layer\nexport * as AgentRaw from './api/AgentApi';\nexport * as AuthenticateRaw from './api/AuthenticateApi';\nexport * as NodeRaw from './api/NodeApi';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\nexport * as SecretsRaw from './api/cloud/SecretsApi';\nexport * as SocialIdentityProvidersRaw from './api/SocialIdentityProvidersApi';\nexport * as StartupRaw from './api/cloud/StartupApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as TypesRaw from './api/ApiTypes';\nexport * as VariablesRaw from './api/cloud/VariablesApi';\nexport * as IdmConfigRaw from './api/IdmConfigApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Agent from './ops/AgentOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Info from './ops/InfoOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Jose from './ops/JoseOps';\nexport * as Log from './ops/cloud/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as Node from './ops/NodeOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Service from './ops/ServiceOps';\nexport * as Secrets from './ops/cloud/SecretsOps';\nexport * as ServiceAccount from './ops/cloud/ServiceAccountOps';\nexport * as Startup from './ops/cloud/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Types from './ops/OpsTypes';\nexport * as Variables from './ops/cloud/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\nexport * as ValidationUtils from './ops/utils/ValidationUtils';\nexport * as LibVersion from './ops/utils/Version';\nexport * as ExportImportUtils from './ops/utils/ExportImportUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './shared/State';\nexport * as constants from './storage/StaticStorage';\n"],"mappings":";;;;;;AAAA;AAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE3BA,eAAK,CAACC,MAAM,EAAE;;AAEd"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Color","enable"],"sources":["index.ts"],"sourcesContent":["import Color from 'colors';\n\nColor.enable();\n\n// Api Layer\nexport * as AgentRaw from './api/AgentApi';\nexport * as AuthenticateRaw from './api/AuthenticateApi';\nexport * as NodeRaw from './api/NodeApi';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\nexport * as SecretsRaw from './api/cloud/SecretsApi';\nexport * as SocialIdentityProvidersRaw from './api/SocialIdentityProvidersApi';\nexport * as StartupRaw from './api/cloud/StartupApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as TypesRaw from './api/ApiTypes';\nexport * as VariablesRaw from './api/cloud/VariablesApi';\nexport * as IdmConfigRaw from './api/IdmConfigApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Agent from './ops/AgentOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Info from './ops/InfoOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Jose from './ops/JoseOps';\nexport * as Log from './ops/cloud/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as Node from './ops/NodeOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Service from './ops/ServiceOps';\nexport * as Secrets from './ops/cloud/SecretsOps';\nexport * as ServiceAccount from './ops/cloud/ServiceAccountOps';\nexport * as Startup from './ops/cloud/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Types from './ops/OpsTypes';\nexport * as Variables from './ops/cloud/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\nexport * as Base64 from './api/utils/Base64';\nexport * as ValidationUtils from './ops/utils/ValidationUtils';\nexport * as LibVersion from './ops/utils/Version';\nexport * as ExportImportUtils from './ops/utils/ExportImportUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './shared/State';\nexport * as constants from './storage/StaticStorage';\n"],"mappings":";;;;;;AAAA;AAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE3BA,eAAK,CAACC,MAAM,EAAE;;AAEd"}
|
package/cjs/ops/Saml2Ops.js
CHANGED
|
@@ -127,18 +127,18 @@ function _exportDependencies() {
|
|
|
127
127
|
if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {
|
|
128
128
|
var scriptData = yield (0, _ScriptApi.getScript)(attrMapperScriptId);
|
|
129
129
|
scriptData.script = (0, _ExportImportUtils.convertBase64TextToArray)(scriptData.script);
|
|
130
|
-
// eslint-disable-next-line no-param-reassign
|
|
131
130
|
fileData.script[attrMapperScriptId] = scriptData;
|
|
132
131
|
}
|
|
133
132
|
var idpAdapterScriptId = _lodash.default.get(providerData, ['identityProvider', 'advanced', 'idpAdapter', 'idpAdapterScript']);
|
|
134
133
|
if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {
|
|
135
134
|
var _scriptData = yield (0, _ScriptApi.getScript)(idpAdapterScriptId);
|
|
136
135
|
_scriptData.script = (0, _ExportImportUtils.convertBase64TextToArray)(_scriptData.script);
|
|
137
|
-
// eslint-disable-next-line no-param-reassign
|
|
138
136
|
fileData.script[idpAdapterScriptId] = _scriptData;
|
|
139
137
|
}
|
|
140
138
|
var metaDataResponse = yield getProviderMetadata(providerData.entityId);
|
|
141
|
-
|
|
139
|
+
if (!metaDataResponse) {
|
|
140
|
+
throw new Error("Unable to obtain metadata from ".concat(getProviderMetadataUrl(providerData.entityId)));
|
|
141
|
+
}
|
|
142
142
|
fileData.saml.metadata[providerData._id] = (0, _ExportImportUtils.convertBase64UrlTextToArray)((0, _Base.encodeBase64Url)(metaDataResponse));
|
|
143
143
|
});
|
|
144
144
|
return _exportDependencies.apply(this, arguments);
|
|
@@ -252,7 +252,11 @@ function _exportSaml2Provider() {
|
|
|
252
252
|
var id = stub._id;
|
|
253
253
|
var providerData = yield getProviderByLocationAndId(location, id);
|
|
254
254
|
exportData.saml[stub.location][providerData._id] = providerData;
|
|
255
|
-
|
|
255
|
+
try {
|
|
256
|
+
yield exportDependencies(providerData, exportData);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
(0, _Console.printMessage)(error.message, 'error');
|
|
259
|
+
}
|
|
256
260
|
(0, _Console.debugMessage)("Saml2Ops.exportSaml2Provider: end [entityId=".concat(entityId, "]"));
|
|
257
261
|
return exportData;
|
|
258
262
|
});
|
|
@@ -272,7 +276,11 @@ function _exportSaml2Providers() {
|
|
|
272
276
|
var stubs = yield getSaml2ProviderStubs();
|
|
273
277
|
for (var stub of stubs) {
|
|
274
278
|
var providerData = yield getProviderByLocationAndId(stub.location, stub._id);
|
|
275
|
-
|
|
279
|
+
try {
|
|
280
|
+
yield exportDependencies(providerData, fileData);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
(0, _Console.printMessage)(error, 'error');
|
|
283
|
+
}
|
|
276
284
|
fileData.saml[stub.location][providerData._id] = providerData;
|
|
277
285
|
}
|
|
278
286
|
return fileData;
|
|
@@ -336,6 +344,7 @@ function _importSaml2Provider() {
|
|
|
336
344
|
(0, _Console.debugMessage)("Saml2Ops.importSaml2Provider: start");
|
|
337
345
|
var entityId64 = (0, _Base.encode)(entityId, false);
|
|
338
346
|
var location = getLocation(entityId64, importData);
|
|
347
|
+
(0, _Console.debugMessage)("Saml2Ops.importSaml2Provider: entityId=".concat(entityId, ", entityId64=").concat(entityId64, ", location=").concat(location));
|
|
339
348
|
if (location) {
|
|
340
349
|
var providerData = importData.saml[location][entityId64];
|
|
341
350
|
yield importDependencies(providerData, importData);
|
|
@@ -343,7 +352,11 @@ function _importSaml2Provider() {
|
|
|
343
352
|
if (location === _ApiTypes.Saml2ProiderLocation.REMOTE) {
|
|
344
353
|
metaData = (0, _ExportImportUtils.convertTextArrayToBase64Url)(importData.saml.metadata[entityId64]);
|
|
345
354
|
}
|
|
346
|
-
|
|
355
|
+
try {
|
|
356
|
+
yield (0, _Saml2Api.createProvider)(location, providerData, metaData);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
yield (0, _Saml2Api.updateProvider)(location, providerData);
|
|
359
|
+
}
|
|
347
360
|
} else {
|
|
348
361
|
throw new Error("Provider ".concat(entityId, " not found in import data!"));
|
|
349
362
|
}
|
|
@@ -375,7 +388,6 @@ function _importSaml2Providers() {
|
|
|
375
388
|
var remoteIds = Object.keys(importData.saml.remote);
|
|
376
389
|
var providerIds = hostedIds.concat(remoteIds);
|
|
377
390
|
myStatus.total = providerIds.length;
|
|
378
|
-
(0, _Console.createProgressIndicator)(providerIds.length, 'Importing providers...');
|
|
379
391
|
for (var entityId64 of providerIds) {
|
|
380
392
|
(0, _Console.debugMessage)("Saml2Ops.importSaml2Providers: entityId=".concat((0, _Base.decodeBase64Url)(entityId64)));
|
|
381
393
|
var location = hostedIds.includes(entityId64) ? _ApiTypes.Saml2ProiderLocation.HOSTED : _ApiTypes.Saml2ProiderLocation.REMOTE;
|
|
@@ -395,15 +407,19 @@ function _importSaml2Providers() {
|
|
|
395
407
|
try {
|
|
396
408
|
yield (0, _Saml2Api.createProvider)(location, providerData, metaData);
|
|
397
409
|
myStatus.successes += 1;
|
|
398
|
-
(0, _Console.updateProgressIndicator)("Imported ".concat(entityId));
|
|
399
410
|
} catch (createProviderErr) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
411
|
+
try {
|
|
412
|
+
yield (0, _Saml2Api.updateProvider)(location, providerData);
|
|
413
|
+
myStatus.successes += 1;
|
|
414
|
+
} catch (updateProviderError) {
|
|
415
|
+
var _updateProviderError$;
|
|
416
|
+
myStatus.failures += 1;
|
|
417
|
+
(0, _Console.printMessage)("\nError importing provider ".concat(entityId, ": ").concat(updateProviderError.message), 'error');
|
|
418
|
+
(0, _Console.printMessage)((_updateProviderError$ = updateProviderError.response) === null || _updateProviderError$ === void 0 ? void 0 : _updateProviderError$.data, 'error');
|
|
419
|
+
}
|
|
403
420
|
}
|
|
404
421
|
}
|
|
405
422
|
myStatus.message = "".concat(myStatus.successes, "/").concat(myStatus.total, " providers imported.");
|
|
406
|
-
(0, _Console.stopProgressIndicator)(myStatus.message);
|
|
407
423
|
} catch (error) {
|
|
408
424
|
myStatus.failures += 1;
|
|
409
425
|
(0, _Console.printMessage)("\nError importing providers ".concat(error.message), 'error');
|
package/cjs/ops/Saml2Ops.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2Ops.js","names":["roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","createSaml2ExportTemplate","meta","getMetadata","script","saml","hosted","remote","metadata","getSaml2ProviderStubs","result","getProviders","getProviderByLocationAndId","location","entityId64","_getProviderByLocationAndId","getProviderMetadataUrl","entityId","_getProviderMetadataUrl","getProviderMetadata","_getProviderMetadata","exportDependencies","providerData","fileData","attrMapperScriptId","_","get","scriptData","getScript","convertBase64TextToArray","idpAdapterScriptId","metaDataResponse","_id","convertBase64UrlTextToArray","encodeBase64Url","getSaml2ProviderStub","debugMessage","found","findProviders","resultCount","Error","getSaml2Provider","stub","id","deleteSaml2Provider","deleteProviderByLocationAndId","deleteSaml2Providers","providers","stubs","provider","push","length","exportSaml2Provider","exportData","exportSaml2Providers","importDependencies","convertTextArrayToBase64","putScript","getLocation","data","Saml2ProiderLocation","HOSTED","REMOTE","undefined","importSaml2Provider","importData","encode","metaData","convertTextArrayToBase64Url","createProvider","importSaml2Providers","myStatus","total","successes","warnings","failures","hostedIds","Object","keys","remoteIds","providerIds","concat","createProgressIndicator","decodeBase64Url","includes","decode","importDependenciesErr","printMessage","response","updateProgressIndicator","createProviderErr","message","stopProgressIndicator","error","deleteRawSaml2Provider","deleteRawProvider","deleteRawSaml2Providers","applicationList","getRawSaml2Providers","deleteApplicationPromises","forEach","item","deleteApplicationResult","Promise","all","_getRawProviders","getRawSaml2Provider","_getRawProvider","putRawSaml2Provider","entityData","_putRawProvider"],"sources":["ops/Saml2Ops.ts"],"sourcesContent":["import _ from 'lodash';\nimport {\n Saml2ProiderLocation,\n Saml2ProviderSkeleton,\n Saml2ProviderStub,\n} from '../api/ApiTypes';\nimport {\n createProvider,\n deleteRawProvider,\n findProviders,\n getProviderByLocationAndId as _getProviderByLocationAndId,\n getProviderMetadata as _getProviderMetadata,\n getProviderMetadataUrl as _getProviderMetadataUrl,\n getRawProvider as _getRawProvider,\n getProviders,\n getRawProviders as _getRawProviders,\n putRawProvider as _putRawProvider,\n deleteProviderByLocationAndId,\n} from '../api/Saml2Api';\nimport { getScript } from '../api/ScriptApi';\nimport {\n decode,\n decodeBase64Url,\n encode,\n encodeBase64Url,\n} from '../api/utils/Base64';\nimport { MultiOpStatusInterface, Saml2ExportInterface } from './OpsTypes';\nimport { putScript } from './ScriptOps';\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n convertBase64TextToArray,\n convertBase64UrlTextToArray,\n convertTextArrayToBase64,\n convertTextArrayToBase64Url,\n getMetadata,\n} from './utils/ExportImportUtils';\n\nexport const roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n// use a function vs a template variable to avoid problems in loops\nexport function createSaml2ExportTemplate(): Saml2ExportInterface {\n return {\n meta: getMetadata(),\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n },\n } as Saml2ExportInterface;\n}\n\n/**\n * Get SAML2 entity provider stubs\n * @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getSaml2ProviderStubs(): Promise<Saml2ProviderStub[]> {\n const { result } = await getProviders();\n return result;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded-without-padding provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n return _getProviderByLocationAndId(location, entityId64);\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return _getProviderMetadataUrl(entityId);\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {Promise<object>} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n return _getProviderMetadata(entityId);\n}\n\n/**\n * Include dependencies in the export file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = await getScript(attrMapperScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[attrMapperScriptId] = scriptData;\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = await getScript(idpAdapterScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[idpAdapterScriptId] = scriptData;\n }\n const metaDataResponse = await getProviderMetadata(providerData.entityId);\n // eslint-disable-next-line no-param-reassign\n fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(\n encodeBase64Url(metaDataResponse)\n );\n}\n\n/**\n *\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2ProviderStub(\n entityId: string\n): Promise<Saml2ProviderStub> {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: start [entityId=${entityId}]`);\n const found = await findProviders(`entityId eq '${entityId}'`);\n switch (found.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: end [entityId=${entityId}]`);\n return found.result[0];\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.getSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.getSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete an entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await deleteProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete all entity providers.\n * @returns {Promise<Saml2ProviderSkeleton[]>} Promise resolving to an array of Saml2ProviderSkeleton objects.\n */\nexport async function deleteSaml2Providers(): Promise<Saml2ProviderSkeleton[]> {\n debugMessage(`Saml2Ops.deleteSaml2Providers: start`);\n const providers: Saml2ProviderSkeleton[] = [];\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const provider = await deleteProviderByLocationAndId(\n stub.location,\n stub._id\n );\n providers.push(provider);\n }\n debugMessage(\n `Saml2Ops.deleteSaml2Providers: end [deleted ${providers.length} providers]`\n );\n return providers;\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Provider(\n entityId: string\n): Promise<Saml2ExportInterface> {\n debugMessage(`Saml2Ops.exportSaml2Provider: start [entityId=${entityId}]`);\n const exportData = createSaml2ExportTemplate();\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n exportData.saml[stub.location][providerData._id] = providerData;\n await exportDependencies(providerData, exportData);\n debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);\n return exportData;\n}\n\n/**\n * Export all entity providers. The response can be saved to file as is.\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Providers(): Promise<Saml2ExportInterface> {\n const fileData = createSaml2ExportTemplate();\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const providerData = await getProviderByLocationAndId(\n stub.location,\n stub._id\n );\n await exportDependencies(providerData, fileData);\n fileData.saml[stub.location][providerData._id] = providerData;\n }\n return fileData;\n}\n\n/**\n * Include dependencies from the import file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to read dependencies from\n */\nasync function importDependencies(providerData, fileData) {\n debugMessage(`Saml2Ops.importDependencies: start`);\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`\n );\n const scriptData = _.get(fileData, ['script', attrMapperScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(attrMapperScriptId, scriptData);\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`\n );\n const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(idpAdapterScriptId, scriptData);\n }\n debugMessage(`Saml2Ops.importDependencies: end`);\n}\n\n/**\n * Find provider in import file and return its location\n * @param {string} entityId64 Base64-encoded provider entity id\n * @param {Saml2ExportInterface} data Import file json data\n * @returns {string} 'hosted' or 'remote' if found, undefined otherwise\n */\nfunction getLocation(\n entityId64: string,\n data: Saml2ExportInterface\n): Saml2ProiderLocation {\n if (data.saml.hosted[entityId64]) {\n return Saml2ProiderLocation.HOSTED;\n }\n if (data.saml.remote[entityId64]) {\n return Saml2ProiderLocation.REMOTE;\n }\n return undefined;\n}\n\n/**\n * Import a SAML entity provider\n * @param {string} entityId Provider entity id\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Provider(\n entityId: string,\n importData: Saml2ExportInterface\n): Promise<boolean> {\n debugMessage(`Saml2Ops.importSaml2Provider: start`);\n const entityId64 = encode(entityId, false);\n const location = getLocation(entityId64, importData);\n if (location) {\n const providerData = importData.saml[location][entityId64];\n await importDependencies(providerData, importData);\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n await createProvider(location, providerData, metaData);\n } else {\n throw new Error(`Provider ${entityId} not found in import data!`);\n }\n debugMessage(`Saml2Ops.importSaml2Provider: end`);\n return true;\n}\n\n/**\n * Import SAML entity providers\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Providers(\n importData: Saml2ExportInterface\n): Promise<MultiOpStatusInterface> {\n debugMessage(`Saml2Ops.importSaml2Providers: start`);\n const myStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n try {\n // find providers in hosted and in remote and map locations\n const hostedIds = Object.keys(importData.saml.hosted);\n const remoteIds = Object.keys(importData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n myStatus.total = providerIds.length;\n createProgressIndicator(providerIds.length, 'Importing providers...');\n for (const entityId64 of providerIds) {\n debugMessage(\n `Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`\n );\n const location = hostedIds.includes(entityId64)\n ? Saml2ProiderLocation.HOSTED\n : Saml2ProiderLocation.REMOTE;\n const entityId = decode(entityId64);\n const providerData = importData.saml[location][entityId64];\n try {\n await importDependencies(providerData, importData);\n } catch (importDependenciesErr) {\n myStatus.warnings += 1;\n printMessage(\n `\\nWarning importing dependencies for ${entityId}`,\n 'warn'\n );\n printMessage(importDependenciesErr.response.data, 'error');\n }\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n myStatus.successes += 1;\n updateProgressIndicator(`Imported ${entityId}`);\n } catch (createProviderErr) {\n myStatus.failures += 1;\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr, 'error');\n }\n }\n myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;\n stopProgressIndicator(myStatus.message);\n } catch (error) {\n myStatus.failures += 1;\n printMessage(`\\nError importing providers ${error.message}`, 'error');\n }\n debugMessage(`Saml2Ops.importSaml2Providers: end`);\n return myStatus;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes entity provider\n * @param {string} entityId The entity id for the entity to be deleted\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteRawSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const response = await deleteRawProvider(entityId);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return response;\n}\n\n/**\n * Deletes all entity providers.\n */\nexport async function deleteRawSaml2Providers(): Promise<\n Saml2ProviderSkeleton[]\n> {\n const applicationList = (await getRawSaml2Providers()).result;\n const deleteApplicationPromises = [];\n applicationList.forEach((item) => {\n printMessage(`Deleting Application ${item._id}`, 'error');\n deleteApplicationPromises.push(deleteRawProvider(item._id));\n });\n const deleteApplicationResult = await Promise.all(deleteApplicationPromises);\n if (deleteApplicationResult.length == applicationList.length) {\n printMessage('SAML Entity cleanup done', 'info');\n }\n return deleteApplicationResult;\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Providers() {\n return _getRawProviders();\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @param {string} entityId The entity provider id\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Provider(entityId: string) {\n return _getRawProvider(entityId);\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawSaml2Provider(entityId: string, entityData) {\n return _putRawProvider(entityId, entityData);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAKA;AAaA;AACA;AAOA;AACA;AAOA;AAMmC;AAAA;AAAA;AAE5B,IAAMA,OAAO,GAA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;EAAA;AAAA;AAAA,SAOqBC,mBAAmB;EAAA;AAAA;AAIzC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,yCAJO,WAAmCzF,QAAgB,EAAE;IAC1D,OAAO,IAAA0F,wBAAe,EAAC1F,QAAQ,CAAC;EAClC,CAAC;EAAA;AAAA;AAAA,SAQqB2F,mBAAmB;EAAA;AAAA;AAAA;EAAA,yCAAlC,WAAmC3F,QAAgB,EAAE4F,UAAU,EAAE;IACtE,OAAO,IAAAC,wBAAe,EAAC7F,QAAQ,EAAE4F,UAAU,CAAC;EAC9C,CAAC;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"Saml2Ops.js","names":["roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","createSaml2ExportTemplate","meta","getMetadata","script","saml","hosted","remote","metadata","getSaml2ProviderStubs","result","getProviders","getProviderByLocationAndId","location","entityId64","_getProviderByLocationAndId","getProviderMetadataUrl","entityId","_getProviderMetadataUrl","getProviderMetadata","_getProviderMetadata","exportDependencies","providerData","fileData","attrMapperScriptId","_","get","scriptData","getScript","convertBase64TextToArray","idpAdapterScriptId","metaDataResponse","Error","_id","convertBase64UrlTextToArray","encodeBase64Url","getSaml2ProviderStub","debugMessage","found","findProviders","resultCount","getSaml2Provider","stub","id","deleteSaml2Provider","deleteProviderByLocationAndId","deleteSaml2Providers","providers","stubs","provider","push","length","exportSaml2Provider","exportData","error","printMessage","message","exportSaml2Providers","importDependencies","convertTextArrayToBase64","putScript","getLocation","data","Saml2ProiderLocation","HOSTED","REMOTE","undefined","importSaml2Provider","importData","encode","metaData","convertTextArrayToBase64Url","createProvider","updateProvider","importSaml2Providers","myStatus","total","successes","warnings","failures","hostedIds","Object","keys","remoteIds","providerIds","concat","decodeBase64Url","includes","decode","importDependenciesErr","response","createProviderErr","updateProviderError","deleteRawSaml2Provider","deleteRawProvider","deleteRawSaml2Providers","applicationList","getRawSaml2Providers","deleteApplicationPromises","forEach","item","deleteApplicationResult","Promise","all","_getRawProviders","getRawSaml2Provider","_getRawProvider","putRawSaml2Provider","entityData","_putRawProvider"],"sources":["ops/Saml2Ops.ts"],"sourcesContent":["import _ from 'lodash';\nimport {\n Saml2ProiderLocation,\n Saml2ProviderSkeleton,\n Saml2ProviderStub,\n} from '../api/ApiTypes';\nimport {\n createProvider,\n updateProvider,\n deleteRawProvider,\n findProviders,\n getProviderByLocationAndId as _getProviderByLocationAndId,\n getProviderMetadata as _getProviderMetadata,\n getProviderMetadataUrl as _getProviderMetadataUrl,\n getRawProvider as _getRawProvider,\n getProviders,\n getRawProviders as _getRawProviders,\n putRawProvider as _putRawProvider,\n deleteProviderByLocationAndId,\n} from '../api/Saml2Api';\nimport { getScript } from '../api/ScriptApi';\nimport {\n decode,\n decodeBase64Url,\n encode,\n encodeBase64Url,\n} from '../api/utils/Base64';\nimport { MultiOpStatusInterface, Saml2ExportInterface } from './OpsTypes';\nimport { putScript } from './ScriptOps';\nimport { debugMessage, printMessage } from './utils/Console';\nimport {\n convertBase64TextToArray,\n convertBase64UrlTextToArray,\n convertTextArrayToBase64,\n convertTextArrayToBase64Url,\n getMetadata,\n} from './utils/ExportImportUtils';\n\nexport const roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n// use a function vs a template variable to avoid problems in loops\nexport function createSaml2ExportTemplate(): Saml2ExportInterface {\n return {\n meta: getMetadata(),\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n },\n } as Saml2ExportInterface;\n}\n\n/**\n * Get SAML2 entity provider stubs\n * @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getSaml2ProviderStubs(): Promise<Saml2ProviderStub[]> {\n const { result } = await getProviders();\n return result;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded-without-padding provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n return _getProviderByLocationAndId(location, entityId64);\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return _getProviderMetadataUrl(entityId);\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {Promise<object>} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n return _getProviderMetadata(entityId);\n}\n\n/**\n * Include dependencies in the export file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = await getScript(attrMapperScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[attrMapperScriptId] = scriptData;\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = await getScript(idpAdapterScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpAdapterScriptId] = scriptData;\n }\n const metaDataResponse = await getProviderMetadata(providerData.entityId);\n if (!metaDataResponse) {\n throw new Error(\n `Unable to obtain metadata from ${getProviderMetadataUrl(\n providerData.entityId\n )}`\n );\n }\n fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(\n encodeBase64Url(metaDataResponse)\n );\n}\n\n/**\n *\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2ProviderStub(\n entityId: string\n): Promise<Saml2ProviderStub> {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: start [entityId=${entityId}]`);\n const found = await findProviders(`entityId eq '${entityId}'`);\n switch (found.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: end [entityId=${entityId}]`);\n return found.result[0];\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.getSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.getSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete an entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await deleteProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete all entity providers.\n * @returns {Promise<Saml2ProviderSkeleton[]>} Promise resolving to an array of Saml2ProviderSkeleton objects.\n */\nexport async function deleteSaml2Providers(): Promise<Saml2ProviderSkeleton[]> {\n debugMessage(`Saml2Ops.deleteSaml2Providers: start`);\n const providers: Saml2ProviderSkeleton[] = [];\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const provider = await deleteProviderByLocationAndId(\n stub.location,\n stub._id\n );\n providers.push(provider);\n }\n debugMessage(\n `Saml2Ops.deleteSaml2Providers: end [deleted ${providers.length} providers]`\n );\n return providers;\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Provider(\n entityId: string\n): Promise<Saml2ExportInterface> {\n debugMessage(`Saml2Ops.exportSaml2Provider: start [entityId=${entityId}]`);\n const exportData = createSaml2ExportTemplate();\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n exportData.saml[stub.location][providerData._id] = providerData;\n try {\n await exportDependencies(providerData, exportData);\n } catch (error) {\n printMessage(error.message, 'error');\n }\n debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);\n return exportData;\n}\n\n/**\n * Export all entity providers. The response can be saved to file as is.\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Providers(): Promise<Saml2ExportInterface> {\n const fileData = createSaml2ExportTemplate();\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const providerData = await getProviderByLocationAndId(\n stub.location,\n stub._id\n );\n try {\n await exportDependencies(providerData, fileData);\n } catch (error) {\n printMessage(error, 'error');\n }\n fileData.saml[stub.location][providerData._id] = providerData;\n }\n return fileData;\n}\n\n/**\n * Include dependencies from the import file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to read dependencies from\n */\nasync function importDependencies(providerData, fileData) {\n debugMessage(`Saml2Ops.importDependencies: start`);\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`\n );\n const scriptData = _.get(fileData, ['script', attrMapperScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(attrMapperScriptId, scriptData);\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`\n );\n const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(idpAdapterScriptId, scriptData);\n }\n debugMessage(`Saml2Ops.importDependencies: end`);\n}\n\n/**\n * Find provider in import file and return its location\n * @param {string} entityId64 Base64-encoded provider entity id\n * @param {Saml2ExportInterface} data Import file json data\n * @returns {string} 'hosted' or 'remote' if found, undefined otherwise\n */\nfunction getLocation(\n entityId64: string,\n data: Saml2ExportInterface\n): Saml2ProiderLocation {\n if (data.saml.hosted[entityId64]) {\n return Saml2ProiderLocation.HOSTED;\n }\n if (data.saml.remote[entityId64]) {\n return Saml2ProiderLocation.REMOTE;\n }\n return undefined;\n}\n\n/**\n * Import a SAML entity provider\n * @param {string} entityId Provider entity id\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Provider(\n entityId: string,\n importData: Saml2ExportInterface\n): Promise<boolean> {\n debugMessage(`Saml2Ops.importSaml2Provider: start`);\n const entityId64 = encode(entityId, false);\n const location = getLocation(entityId64, importData);\n debugMessage(\n `Saml2Ops.importSaml2Provider: entityId=${entityId}, entityId64=${entityId64}, location=${location}`\n );\n if (location) {\n const providerData = importData.saml[location][entityId64];\n await importDependencies(providerData, importData);\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n } catch (error) {\n await updateProvider(location, providerData);\n }\n } else {\n throw new Error(`Provider ${entityId} not found in import data!`);\n }\n debugMessage(`Saml2Ops.importSaml2Provider: end`);\n return true;\n}\n\n/**\n * Import SAML entity providers\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Providers(\n importData: Saml2ExportInterface\n): Promise<MultiOpStatusInterface> {\n debugMessage(`Saml2Ops.importSaml2Providers: start`);\n const myStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n try {\n // find providers in hosted and in remote and map locations\n const hostedIds = Object.keys(importData.saml.hosted);\n const remoteIds = Object.keys(importData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n myStatus.total = providerIds.length;\n for (const entityId64 of providerIds) {\n debugMessage(\n `Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`\n );\n const location = hostedIds.includes(entityId64)\n ? Saml2ProiderLocation.HOSTED\n : Saml2ProiderLocation.REMOTE;\n const entityId = decode(entityId64);\n const providerData = importData.saml[location][entityId64];\n try {\n await importDependencies(providerData, importData);\n } catch (importDependenciesErr) {\n myStatus.warnings += 1;\n printMessage(\n `\\nWarning importing dependencies for ${entityId}`,\n 'warn'\n );\n printMessage(importDependenciesErr.response.data, 'error');\n }\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n myStatus.successes += 1;\n } catch (createProviderErr) {\n try {\n await updateProvider(location, providerData);\n myStatus.successes += 1;\n } catch (updateProviderError) {\n myStatus.failures += 1;\n printMessage(\n `\\nError importing provider ${entityId}: ${updateProviderError.message}`,\n 'error'\n );\n printMessage(updateProviderError.response?.data, 'error');\n }\n }\n }\n myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;\n } catch (error) {\n myStatus.failures += 1;\n printMessage(`\\nError importing providers ${error.message}`, 'error');\n }\n debugMessage(`Saml2Ops.importSaml2Providers: end`);\n return myStatus;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes entity provider\n * @param {string} entityId The entity id for the entity to be deleted\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteRawSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const response = await deleteRawProvider(entityId);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return response;\n}\n\n/**\n * Deletes all entity providers.\n */\nexport async function deleteRawSaml2Providers(): Promise<\n Saml2ProviderSkeleton[]\n> {\n const applicationList = (await getRawSaml2Providers()).result;\n const deleteApplicationPromises = [];\n applicationList.forEach((item) => {\n printMessage(`Deleting Application ${item._id}`, 'error');\n deleteApplicationPromises.push(deleteRawProvider(item._id));\n });\n const deleteApplicationResult = await Promise.all(deleteApplicationPromises);\n if (deleteApplicationResult.length == applicationList.length) {\n printMessage('SAML Entity cleanup done', 'info');\n }\n return deleteApplicationResult;\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Providers() {\n return _getRawProviders();\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @param {string} entityId The entity provider id\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Provider(entityId: string) {\n return _getRawProvider(entityId);\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawSaml2Provider(entityId: string, entityData) {\n return _putRawProvider(entityId, entityData);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAKA;AAcA;AAC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;IAC7D,IAAMwF,yBAAyB,GAAG,EAAE;IACpCF,eAAe,CAACG,OAAO,CAAEC,IAAI,IAAK;MAChC,IAAA7C,qBAAY,iCAAyB6C,IAAI,CAACnE,GAAG,GAAI,OAAO,CAAC;MACzDiE,yBAAyB,CAAChD,IAAI,CAAC,IAAA4C,2BAAiB,EAACM,IAAI,CAACnE,GAAG,CAAC,CAAC;IAC7D,CAAC,CAAC;IACF,IAAMoE,uBAAuB,SAASC,OAAO,CAACC,GAAG,CAACL,yBAAyB,CAAC;IAC5E,IAAIG,uBAAuB,CAAClD,MAAM,IAAI6C,eAAe,CAAC7C,MAAM,EAAE;MAC5D,IAAAI,qBAAY,EAAC,0BAA0B,EAAE,MAAM,CAAC;IAClD;IACA,OAAO8C,uBAAuB;EAChC,CAAC;EAAA;AAAA;AAAA,SAMqBJ,oBAAoB;EAAA;AAAA;AAI1C;AACA;AACA;AACA;AACA;AAJA;EAAA,0CAJO,aAAsC;IAC3C,OAAO,IAAAO,yBAAgB,GAAE;EAC3B,CAAC;EAAA;AAAA;AAAA,SAOqBC,mBAAmB;EAAA;AAAA;AAIzC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,yCAJO,WAAmCxF,QAAgB,EAAE;IAC1D,OAAO,IAAAyF,wBAAe,EAACzF,QAAQ,CAAC;EAClC,CAAC;EAAA;AAAA;AAAA,SAQqB0F,mBAAmB;EAAA;AAAA;AAAA;EAAA,yCAAlC,WAAmC1F,QAAgB,EAAE2F,UAAU,EAAE;IACtE,OAAO,IAAAC,wBAAe,EAAC5F,QAAQ,EAAE2F,UAAU,CAAC;EAC9C,CAAC;EAAA;AAAA"}
|
package/esm/index.mjs
CHANGED
|
@@ -46,6 +46,7 @@ export * as Types from './ops/OpsTypes';
|
|
|
46
46
|
export * as Variables from './ops/cloud/VariablesOps';
|
|
47
47
|
// TODO: revisit if there are better ways
|
|
48
48
|
export * as Utils from './ops/utils/OpsUtils';
|
|
49
|
+
export * as Base64 from './api/utils/Base64';
|
|
49
50
|
export * as ValidationUtils from './ops/utils/ValidationUtils';
|
|
50
51
|
export * as LibVersion from './ops/utils/Version';
|
|
51
52
|
export * as ExportImportUtils from './ops/utils/ExportImportUtils';
|
package/esm/ops/Saml2Ops.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Saml2ProiderLocation } from '../api/ApiTypes';
|
|
3
|
-
import { createProvider, deleteRawProvider, findProviders, getProviderByLocationAndId as _getProviderByLocationAndId, getProviderMetadata as _getProviderMetadata, getProviderMetadataUrl as _getProviderMetadataUrl, getRawProvider as _getRawProvider, getProviders, getRawProviders as _getRawProviders, putRawProvider as _putRawProvider, deleteProviderByLocationAndId } from '../api/Saml2Api';
|
|
3
|
+
import { createProvider, updateProvider, deleteRawProvider, findProviders, getProviderByLocationAndId as _getProviderByLocationAndId, getProviderMetadata as _getProviderMetadata, getProviderMetadataUrl as _getProviderMetadataUrl, getRawProvider as _getRawProvider, getProviders, getRawProviders as _getRawProviders, putRawProvider as _putRawProvider, deleteProviderByLocationAndId } from '../api/Saml2Api';
|
|
4
4
|
import { getScript } from '../api/ScriptApi';
|
|
5
5
|
import { decode, decodeBase64Url, encode, encodeBase64Url } from '../api/utils/Base64';
|
|
6
6
|
import { putScript } from './ScriptOps';
|
|
7
|
-
import {
|
|
7
|
+
import { debugMessage, printMessage } from './utils/Console';
|
|
8
8
|
import { convertBase64TextToArray, convertBase64UrlTextToArray, convertTextArrayToBase64, convertTextArrayToBase64Url, getMetadata } from './utils/ExportImportUtils';
|
|
9
9
|
export const roleMap = {
|
|
10
10
|
identityProvider: 'IDP',
|
|
@@ -75,18 +75,18 @@ async function exportDependencies(providerData, fileData) {
|
|
|
75
75
|
if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {
|
|
76
76
|
const scriptData = await getScript(attrMapperScriptId);
|
|
77
77
|
scriptData.script = convertBase64TextToArray(scriptData.script);
|
|
78
|
-
// eslint-disable-next-line no-param-reassign
|
|
79
78
|
fileData.script[attrMapperScriptId] = scriptData;
|
|
80
79
|
}
|
|
81
80
|
const idpAdapterScriptId = _.get(providerData, ['identityProvider', 'advanced', 'idpAdapter', 'idpAdapterScript']);
|
|
82
81
|
if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {
|
|
83
82
|
const scriptData = await getScript(idpAdapterScriptId);
|
|
84
83
|
scriptData.script = convertBase64TextToArray(scriptData.script);
|
|
85
|
-
// eslint-disable-next-line no-param-reassign
|
|
86
84
|
fileData.script[idpAdapterScriptId] = scriptData;
|
|
87
85
|
}
|
|
88
86
|
const metaDataResponse = await getProviderMetadata(providerData.entityId);
|
|
89
|
-
|
|
87
|
+
if (!metaDataResponse) {
|
|
88
|
+
throw new Error(`Unable to obtain metadata from ${getProviderMetadataUrl(providerData.entityId)}`);
|
|
89
|
+
}
|
|
90
90
|
fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(encodeBase64Url(metaDataResponse));
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -176,7 +176,11 @@ export async function exportSaml2Provider(entityId) {
|
|
|
176
176
|
const id = stub._id;
|
|
177
177
|
const providerData = await getProviderByLocationAndId(location, id);
|
|
178
178
|
exportData.saml[stub.location][providerData._id] = providerData;
|
|
179
|
-
|
|
179
|
+
try {
|
|
180
|
+
await exportDependencies(providerData, exportData);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
printMessage(error.message, 'error');
|
|
183
|
+
}
|
|
180
184
|
debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);
|
|
181
185
|
return exportData;
|
|
182
186
|
}
|
|
@@ -190,7 +194,11 @@ export async function exportSaml2Providers() {
|
|
|
190
194
|
const stubs = await getSaml2ProviderStubs();
|
|
191
195
|
for (const stub of stubs) {
|
|
192
196
|
const providerData = await getProviderByLocationAndId(stub.location, stub._id);
|
|
193
|
-
|
|
197
|
+
try {
|
|
198
|
+
await exportDependencies(providerData, fileData);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
printMessage(error, 'error');
|
|
201
|
+
}
|
|
194
202
|
fileData.saml[stub.location][providerData._id] = providerData;
|
|
195
203
|
}
|
|
196
204
|
return fileData;
|
|
@@ -245,6 +253,7 @@ export async function importSaml2Provider(entityId, importData) {
|
|
|
245
253
|
debugMessage(`Saml2Ops.importSaml2Provider: start`);
|
|
246
254
|
const entityId64 = encode(entityId, false);
|
|
247
255
|
const location = getLocation(entityId64, importData);
|
|
256
|
+
debugMessage(`Saml2Ops.importSaml2Provider: entityId=${entityId}, entityId64=${entityId64}, location=${location}`);
|
|
248
257
|
if (location) {
|
|
249
258
|
const providerData = importData.saml[location][entityId64];
|
|
250
259
|
await importDependencies(providerData, importData);
|
|
@@ -252,7 +261,11 @@ export async function importSaml2Provider(entityId, importData) {
|
|
|
252
261
|
if (location === Saml2ProiderLocation.REMOTE) {
|
|
253
262
|
metaData = convertTextArrayToBase64Url(importData.saml.metadata[entityId64]);
|
|
254
263
|
}
|
|
255
|
-
|
|
264
|
+
try {
|
|
265
|
+
await createProvider(location, providerData, metaData);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
await updateProvider(location, providerData);
|
|
268
|
+
}
|
|
256
269
|
} else {
|
|
257
270
|
throw new Error(`Provider ${entityId} not found in import data!`);
|
|
258
271
|
}
|
|
@@ -278,7 +291,6 @@ export async function importSaml2Providers(importData) {
|
|
|
278
291
|
const remoteIds = Object.keys(importData.saml.remote);
|
|
279
292
|
const providerIds = hostedIds.concat(remoteIds);
|
|
280
293
|
myStatus.total = providerIds.length;
|
|
281
|
-
createProgressIndicator(providerIds.length, 'Importing providers...');
|
|
282
294
|
for (const entityId64 of providerIds) {
|
|
283
295
|
debugMessage(`Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`);
|
|
284
296
|
const location = hostedIds.includes(entityId64) ? Saml2ProiderLocation.HOSTED : Saml2ProiderLocation.REMOTE;
|
|
@@ -298,15 +310,19 @@ export async function importSaml2Providers(importData) {
|
|
|
298
310
|
try {
|
|
299
311
|
await createProvider(location, providerData, metaData);
|
|
300
312
|
myStatus.successes += 1;
|
|
301
|
-
updateProgressIndicator(`Imported ${entityId}`);
|
|
302
313
|
} catch (createProviderErr) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
314
|
+
try {
|
|
315
|
+
await updateProvider(location, providerData);
|
|
316
|
+
myStatus.successes += 1;
|
|
317
|
+
} catch (updateProviderError) {
|
|
318
|
+
var _updateProviderError$;
|
|
319
|
+
myStatus.failures += 1;
|
|
320
|
+
printMessage(`\nError importing provider ${entityId}: ${updateProviderError.message}`, 'error');
|
|
321
|
+
printMessage((_updateProviderError$ = updateProviderError.response) === null || _updateProviderError$ === void 0 ? void 0 : _updateProviderError$.data, 'error');
|
|
322
|
+
}
|
|
306
323
|
}
|
|
307
324
|
}
|
|
308
325
|
myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;
|
|
309
|
-
stopProgressIndicator(myStatus.message);
|
|
310
326
|
} catch (error) {
|
|
311
327
|
myStatus.failures += 1;
|
|
312
328
|
printMessage(`\nError importing providers ${error.message}`, 'error');
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export * as Theme from './ops/ThemeOps';
|
|
|
36
36
|
export * as Types from './ops/OpsTypes';
|
|
37
37
|
export * as Variables from './ops/cloud/VariablesOps';
|
|
38
38
|
export * as Utils from './ops/utils/OpsUtils';
|
|
39
|
+
export * as Base64 from './api/utils/Base64';
|
|
39
40
|
export * as ValidationUtils from './ops/utils/ValidationUtils';
|
|
40
41
|
export * as LibVersion from './ops/utils/Version';
|
|
41
42
|
export * as ExportImportUtils from './ops/utils/ExportImportUtils';
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;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AAiB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAGnE,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC","file":"index.d.ts","sourcesContent":["import Color from 'colors';\n\nColor.enable();\n\n// Api Layer\nexport * as AgentRaw from './api/AgentApi';\nexport * as AuthenticateRaw from './api/AuthenticateApi';\nexport * as NodeRaw from './api/NodeApi';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\nexport * as SecretsRaw from './api/cloud/SecretsApi';\nexport * as SocialIdentityProvidersRaw from './api/SocialIdentityProvidersApi';\nexport * as StartupRaw from './api/cloud/StartupApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as TypesRaw from './api/ApiTypes';\nexport * as VariablesRaw from './api/cloud/VariablesApi';\nexport * as IdmConfigRaw from './api/IdmConfigApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Agent from './ops/AgentOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Info from './ops/InfoOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Jose from './ops/JoseOps';\nexport * as Log from './ops/cloud/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as Node from './ops/NodeOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Service from './ops/ServiceOps';\nexport * as Secrets from './ops/cloud/SecretsOps';\nexport * as ServiceAccount from './ops/cloud/ServiceAccountOps';\nexport * as Startup from './ops/cloud/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Types from './ops/OpsTypes';\nexport * as Variables from './ops/cloud/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\nexport * as ValidationUtils from './ops/utils/ValidationUtils';\nexport * as LibVersion from './ops/utils/Version';\nexport * as ExportImportUtils from './ops/utils/ExportImportUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './shared/State';\nexport * as constants from './storage/StaticStorage';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,0BAA0B,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO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;AACxC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAGnE,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC","file":"index.d.ts","sourcesContent":["import Color from 'colors';\n\nColor.enable();\n\n// Api Layer\nexport * as AgentRaw from './api/AgentApi';\nexport * as AuthenticateRaw from './api/AuthenticateApi';\nexport * as NodeRaw from './api/NodeApi';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\nexport * as SecretsRaw from './api/cloud/SecretsApi';\nexport * as SocialIdentityProvidersRaw from './api/SocialIdentityProvidersApi';\nexport * as StartupRaw from './api/cloud/StartupApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as TypesRaw from './api/ApiTypes';\nexport * as VariablesRaw from './api/cloud/VariablesApi';\nexport * as IdmConfigRaw from './api/IdmConfigApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Agent from './ops/AgentOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Info from './ops/InfoOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Jose from './ops/JoseOps';\nexport * as Log from './ops/cloud/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as Node from './ops/NodeOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Service from './ops/ServiceOps';\nexport * as Secrets from './ops/cloud/SecretsOps';\nexport * as ServiceAccount from './ops/cloud/ServiceAccountOps';\nexport * as Startup from './ops/cloud/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Types from './ops/OpsTypes';\nexport * as Variables from './ops/cloud/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\nexport * as Base64 from './api/utils/Base64';\nexport * as ValidationUtils from './ops/utils/ValidationUtils';\nexport * as LibVersion from './ops/utils/Version';\nexport * as ExportImportUtils from './ops/utils/ExportImportUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './shared/State';\nexport * as constants from './storage/StaticStorage';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ops/Saml2Ops.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAqBzB,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAiB1E,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAGF,wBAAgB,yBAAyB,IAAI,oBAAoB,CAUhE;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAG1E;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,gBAGnB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM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AE,UAAU,KAAA,gBAErE","file":"Saml2Ops.d.ts","sourcesContent":["import _ from 'lodash';\nimport {\n Saml2ProiderLocation,\n Saml2ProviderSkeleton,\n Saml2ProviderStub,\n} from '../api/ApiTypes';\nimport {\n createProvider,\n deleteRawProvider,\n findProviders,\n getProviderByLocationAndId as _getProviderByLocationAndId,\n getProviderMetadata as _getProviderMetadata,\n getProviderMetadataUrl as _getProviderMetadataUrl,\n getRawProvider as _getRawProvider,\n getProviders,\n getRawProviders as _getRawProviders,\n putRawProvider as _putRawProvider,\n deleteProviderByLocationAndId,\n} from '../api/Saml2Api';\nimport { getScript } from '../api/ScriptApi';\nimport {\n decode,\n decodeBase64Url,\n encode,\n encodeBase64Url,\n} from '../api/utils/Base64';\nimport { MultiOpStatusInterface, Saml2ExportInterface } from './OpsTypes';\nimport { putScript } from './ScriptOps';\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n convertBase64TextToArray,\n convertBase64UrlTextToArray,\n convertTextArrayToBase64,\n convertTextArrayToBase64Url,\n getMetadata,\n} from './utils/ExportImportUtils';\n\nexport const roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n// use a function vs a template variable to avoid problems in loops\nexport function createSaml2ExportTemplate(): Saml2ExportInterface {\n return {\n meta: getMetadata(),\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n },\n } as Saml2ExportInterface;\n}\n\n/**\n * Get SAML2 entity provider stubs\n * @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getSaml2ProviderStubs(): Promise<Saml2ProviderStub[]> {\n const { result } = await getProviders();\n return result;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded-without-padding provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n return _getProviderByLocationAndId(location, entityId64);\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return _getProviderMetadataUrl(entityId);\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {Promise<object>} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n return _getProviderMetadata(entityId);\n}\n\n/**\n * Include dependencies in the export file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = await getScript(attrMapperScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[attrMapperScriptId] = scriptData;\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = await getScript(idpAdapterScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[idpAdapterScriptId] = scriptData;\n }\n const metaDataResponse = await getProviderMetadata(providerData.entityId);\n // eslint-disable-next-line no-param-reassign\n fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(\n encodeBase64Url(metaDataResponse)\n );\n}\n\n/**\n *\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2ProviderStub(\n entityId: string\n): Promise<Saml2ProviderStub> {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: start [entityId=${entityId}]`);\n const found = await findProviders(`entityId eq '${entityId}'`);\n switch (found.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: end [entityId=${entityId}]`);\n return found.result[0];\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.getSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.getSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete an entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await deleteProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete all entity providers.\n * @returns {Promise<Saml2ProviderSkeleton[]>} Promise resolving to an array of Saml2ProviderSkeleton objects.\n */\nexport async function deleteSaml2Providers(): Promise<Saml2ProviderSkeleton[]> {\n debugMessage(`Saml2Ops.deleteSaml2Providers: start`);\n const providers: Saml2ProviderSkeleton[] = [];\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const provider = await deleteProviderByLocationAndId(\n stub.location,\n stub._id\n );\n providers.push(provider);\n }\n debugMessage(\n `Saml2Ops.deleteSaml2Providers: end [deleted ${providers.length} providers]`\n );\n return providers;\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Provider(\n entityId: string\n): Promise<Saml2ExportInterface> {\n debugMessage(`Saml2Ops.exportSaml2Provider: start [entityId=${entityId}]`);\n const exportData = createSaml2ExportTemplate();\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n exportData.saml[stub.location][providerData._id] = providerData;\n await exportDependencies(providerData, exportData);\n debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);\n return exportData;\n}\n\n/**\n * Export all entity providers. The response can be saved to file as is.\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Providers(): Promise<Saml2ExportInterface> {\n const fileData = createSaml2ExportTemplate();\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const providerData = await getProviderByLocationAndId(\n stub.location,\n stub._id\n );\n await exportDependencies(providerData, fileData);\n fileData.saml[stub.location][providerData._id] = providerData;\n }\n return fileData;\n}\n\n/**\n * Include dependencies from the import file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to read dependencies from\n */\nasync function importDependencies(providerData, fileData) {\n debugMessage(`Saml2Ops.importDependencies: start`);\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`\n );\n const scriptData = _.get(fileData, ['script', attrMapperScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(attrMapperScriptId, scriptData);\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`\n );\n const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(idpAdapterScriptId, scriptData);\n }\n debugMessage(`Saml2Ops.importDependencies: end`);\n}\n\n/**\n * Find provider in import file and return its location\n * @param {string} entityId64 Base64-encoded provider entity id\n * @param {Saml2ExportInterface} data Import file json data\n * @returns {string} 'hosted' or 'remote' if found, undefined otherwise\n */\nfunction getLocation(\n entityId64: string,\n data: Saml2ExportInterface\n): Saml2ProiderLocation {\n if (data.saml.hosted[entityId64]) {\n return Saml2ProiderLocation.HOSTED;\n }\n if (data.saml.remote[entityId64]) {\n return Saml2ProiderLocation.REMOTE;\n }\n return undefined;\n}\n\n/**\n * Import a SAML entity provider\n * @param {string} entityId Provider entity id\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Provider(\n entityId: string,\n importData: Saml2ExportInterface\n): Promise<boolean> {\n debugMessage(`Saml2Ops.importSaml2Provider: start`);\n const entityId64 = encode(entityId, false);\n const location = getLocation(entityId64, importData);\n if (location) {\n const providerData = importData.saml[location][entityId64];\n await importDependencies(providerData, importData);\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n await createProvider(location, providerData, metaData);\n } else {\n throw new Error(`Provider ${entityId} not found in import data!`);\n }\n debugMessage(`Saml2Ops.importSaml2Provider: end`);\n return true;\n}\n\n/**\n * Import SAML entity providers\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Providers(\n importData: Saml2ExportInterface\n): Promise<MultiOpStatusInterface> {\n debugMessage(`Saml2Ops.importSaml2Providers: start`);\n const myStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n try {\n // find providers in hosted and in remote and map locations\n const hostedIds = Object.keys(importData.saml.hosted);\n const remoteIds = Object.keys(importData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n myStatus.total = providerIds.length;\n createProgressIndicator(providerIds.length, 'Importing providers...');\n for (const entityId64 of providerIds) {\n debugMessage(\n `Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`\n );\n const location = hostedIds.includes(entityId64)\n ? Saml2ProiderLocation.HOSTED\n : Saml2ProiderLocation.REMOTE;\n const entityId = decode(entityId64);\n const providerData = importData.saml[location][entityId64];\n try {\n await importDependencies(providerData, importData);\n } catch (importDependenciesErr) {\n myStatus.warnings += 1;\n printMessage(\n `\\nWarning importing dependencies for ${entityId}`,\n 'warn'\n );\n printMessage(importDependenciesErr.response.data, 'error');\n }\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n myStatus.successes += 1;\n updateProgressIndicator(`Imported ${entityId}`);\n } catch (createProviderErr) {\n myStatus.failures += 1;\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr, 'error');\n }\n }\n myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;\n stopProgressIndicator(myStatus.message);\n } catch (error) {\n myStatus.failures += 1;\n printMessage(`\\nError importing providers ${error.message}`, 'error');\n }\n debugMessage(`Saml2Ops.importSaml2Providers: end`);\n return myStatus;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes entity provider\n * @param {string} entityId The entity id for the entity to be deleted\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteRawSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const response = await deleteRawProvider(entityId);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return response;\n}\n\n/**\n * Deletes all entity providers.\n */\nexport async function deleteRawSaml2Providers(): Promise<\n Saml2ProviderSkeleton[]\n> {\n const applicationList = (await getRawSaml2Providers()).result;\n const deleteApplicationPromises = [];\n applicationList.forEach((item) => {\n printMessage(`Deleting Application ${item._id}`, 'error');\n deleteApplicationPromises.push(deleteRawProvider(item._id));\n });\n const deleteApplicationResult = await Promise.all(deleteApplicationPromises);\n if (deleteApplicationResult.length == applicationList.length) {\n printMessage('SAML Entity cleanup done', 'info');\n }\n return deleteApplicationResult;\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Providers() {\n return _getRawProviders();\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @param {string} entityId The entity provider id\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Provider(entityId: string) {\n return _getRawProvider(entityId);\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawSaml2Provider(entityId: string, entityData) {\n return _putRawProvider(entityId, entityData);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/ops/Saml2Ops.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAsBzB,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAW1E,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAGF,wBAAgB,yBAAyB,IAAI,o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;;GAEG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CACtD,qBAAqB,EAAE,CACxB,CAYA;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,iBAEzC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,gBAEzD;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,KAAA,gBAErE","file":"Saml2Ops.d.ts","sourcesContent":["import _ from 'lodash';\nimport {\n Saml2ProiderLocation,\n Saml2ProviderSkeleton,\n Saml2ProviderStub,\n} from '../api/ApiTypes';\nimport {\n createProvider,\n updateProvider,\n deleteRawProvider,\n findProviders,\n getProviderByLocationAndId as _getProviderByLocationAndId,\n getProviderMetadata as _getProviderMetadata,\n getProviderMetadataUrl as _getProviderMetadataUrl,\n getRawProvider as _getRawProvider,\n getProviders,\n getRawProviders as _getRawProviders,\n putRawProvider as _putRawProvider,\n deleteProviderByLocationAndId,\n} from '../api/Saml2Api';\nimport { getScript } from '../api/ScriptApi';\nimport {\n decode,\n decodeBase64Url,\n encode,\n encodeBase64Url,\n} from '../api/utils/Base64';\nimport { MultiOpStatusInterface, Saml2ExportInterface } from './OpsTypes';\nimport { putScript } from './ScriptOps';\nimport { debugMessage, printMessage } from './utils/Console';\nimport {\n convertBase64TextToArray,\n convertBase64UrlTextToArray,\n convertTextArrayToBase64,\n convertTextArrayToBase64Url,\n getMetadata,\n} from './utils/ExportImportUtils';\n\nexport const roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n// use a function vs a template variable to avoid problems in loops\nexport function createSaml2ExportTemplate(): Saml2ExportInterface {\n return {\n meta: getMetadata(),\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n },\n } as Saml2ExportInterface;\n}\n\n/**\n * Get SAML2 entity provider stubs\n * @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getSaml2ProviderStubs(): Promise<Saml2ProviderStub[]> {\n const { result } = await getProviders();\n return result;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded-without-padding provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n return _getProviderByLocationAndId(location, entityId64);\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return _getProviderMetadataUrl(entityId);\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {Promise<object>} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n return _getProviderMetadata(entityId);\n}\n\n/**\n * Include dependencies in the export file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = await getScript(attrMapperScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[attrMapperScriptId] = scriptData;\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = await getScript(idpAdapterScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpAdapterScriptId] = scriptData;\n }\n const metaDataResponse = await getProviderMetadata(providerData.entityId);\n if (!metaDataResponse) {\n throw new Error(\n `Unable to obtain metadata from ${getProviderMetadataUrl(\n providerData.entityId\n )}`\n );\n }\n fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(\n encodeBase64Url(metaDataResponse)\n );\n}\n\n/**\n *\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2ProviderStub(\n entityId: string\n): Promise<Saml2ProviderStub> {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: start [entityId=${entityId}]`);\n const found = await findProviders(`entityId eq '${entityId}'`);\n switch (found.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: end [entityId=${entityId}]`);\n return found.result[0];\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.getSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.getSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete an entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await deleteProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Delete all entity providers.\n * @returns {Promise<Saml2ProviderSkeleton[]>} Promise resolving to an array of Saml2ProviderSkeleton objects.\n */\nexport async function deleteSaml2Providers(): Promise<Saml2ProviderSkeleton[]> {\n debugMessage(`Saml2Ops.deleteSaml2Providers: start`);\n const providers: Saml2ProviderSkeleton[] = [];\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const provider = await deleteProviderByLocationAndId(\n stub.location,\n stub._id\n );\n providers.push(provider);\n }\n debugMessage(\n `Saml2Ops.deleteSaml2Providers: end [deleted ${providers.length} providers]`\n );\n return providers;\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {string} entityId Provider entity id\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Provider(\n entityId: string\n): Promise<Saml2ExportInterface> {\n debugMessage(`Saml2Ops.exportSaml2Provider: start [entityId=${entityId}]`);\n const exportData = createSaml2ExportTemplate();\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n exportData.saml[stub.location][providerData._id] = providerData;\n try {\n await exportDependencies(providerData, exportData);\n } catch (error) {\n printMessage(error.message, 'error');\n }\n debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);\n return exportData;\n}\n\n/**\n * Export all entity providers. The response can be saved to file as is.\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Providers(): Promise<Saml2ExportInterface> {\n const fileData = createSaml2ExportTemplate();\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const providerData = await getProviderByLocationAndId(\n stub.location,\n stub._id\n );\n try {\n await exportDependencies(providerData, fileData);\n } catch (error) {\n printMessage(error, 'error');\n }\n fileData.saml[stub.location][providerData._id] = providerData;\n }\n return fileData;\n}\n\n/**\n * Include dependencies from the import file\n * @param {object} providerData Object representing a SAML entity provider\n * @param {object} fileData File data object to read dependencies from\n */\nasync function importDependencies(providerData, fileData) {\n debugMessage(`Saml2Ops.importDependencies: start`);\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`\n );\n const scriptData = _.get(fileData, ['script', attrMapperScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(attrMapperScriptId, scriptData);\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`\n );\n const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(idpAdapterScriptId, scriptData);\n }\n debugMessage(`Saml2Ops.importDependencies: end`);\n}\n\n/**\n * Find provider in import file and return its location\n * @param {string} entityId64 Base64-encoded provider entity id\n * @param {Saml2ExportInterface} data Import file json data\n * @returns {string} 'hosted' or 'remote' if found, undefined otherwise\n */\nfunction getLocation(\n entityId64: string,\n data: Saml2ExportInterface\n): Saml2ProiderLocation {\n if (data.saml.hosted[entityId64]) {\n return Saml2ProiderLocation.HOSTED;\n }\n if (data.saml.remote[entityId64]) {\n return Saml2ProiderLocation.REMOTE;\n }\n return undefined;\n}\n\n/**\n * Import a SAML entity provider\n * @param {string} entityId Provider entity id\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Provider(\n entityId: string,\n importData: Saml2ExportInterface\n): Promise<boolean> {\n debugMessage(`Saml2Ops.importSaml2Provider: start`);\n const entityId64 = encode(entityId, false);\n const location = getLocation(entityId64, importData);\n debugMessage(\n `Saml2Ops.importSaml2Provider: entityId=${entityId}, entityId64=${entityId64}, location=${location}`\n );\n if (location) {\n const providerData = importData.saml[location][entityId64];\n await importDependencies(providerData, importData);\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n } catch (error) {\n await updateProvider(location, providerData);\n }\n } else {\n throw new Error(`Provider ${entityId} not found in import data!`);\n }\n debugMessage(`Saml2Ops.importSaml2Provider: end`);\n return true;\n}\n\n/**\n * Import SAML entity providers\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Providers(\n importData: Saml2ExportInterface\n): Promise<MultiOpStatusInterface> {\n debugMessage(`Saml2Ops.importSaml2Providers: start`);\n const myStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n try {\n // find providers in hosted and in remote and map locations\n const hostedIds = Object.keys(importData.saml.hosted);\n const remoteIds = Object.keys(importData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n myStatus.total = providerIds.length;\n for (const entityId64 of providerIds) {\n debugMessage(\n `Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`\n );\n const location = hostedIds.includes(entityId64)\n ? Saml2ProiderLocation.HOSTED\n : Saml2ProiderLocation.REMOTE;\n const entityId = decode(entityId64);\n const providerData = importData.saml[location][entityId64];\n try {\n await importDependencies(providerData, importData);\n } catch (importDependenciesErr) {\n myStatus.warnings += 1;\n printMessage(\n `\\nWarning importing dependencies for ${entityId}`,\n 'warn'\n );\n printMessage(importDependenciesErr.response.data, 'error');\n }\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n myStatus.successes += 1;\n } catch (createProviderErr) {\n try {\n await updateProvider(location, providerData);\n myStatus.successes += 1;\n } catch (updateProviderError) {\n myStatus.failures += 1;\n printMessage(\n `\\nError importing provider ${entityId}: ${updateProviderError.message}`,\n 'error'\n );\n printMessage(updateProviderError.response?.data, 'error');\n }\n }\n }\n myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;\n } catch (error) {\n myStatus.failures += 1;\n printMessage(`\\nError importing providers ${error.message}`, 'error');\n }\n debugMessage(`Saml2Ops.importSaml2Providers: end`);\n return myStatus;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes entity provider\n * @param {string} entityId The entity id for the entity to be deleted\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function deleteRawSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);\n const response = await deleteRawProvider(entityId);\n debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);\n return response;\n}\n\n/**\n * Deletes all entity providers.\n */\nexport async function deleteRawSaml2Providers(): Promise<\n Saml2ProviderSkeleton[]\n> {\n const applicationList = (await getRawSaml2Providers()).result;\n const deleteApplicationPromises = [];\n applicationList.forEach((item) => {\n printMessage(`Deleting Application ${item._id}`, 'error');\n deleteApplicationPromises.push(deleteRawProvider(item._id));\n });\n const deleteApplicationResult = await Promise.all(deleteApplicationPromises);\n if (deleteApplicationResult.length == applicationList.length) {\n printMessage('SAML Entity cleanup done', 'info');\n }\n return deleteApplicationResult;\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Providers() {\n return _getRawProviders();\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @param {string} entityId The entity provider id\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawSaml2Provider(entityId: string) {\n return _getRawProvider(entityId);\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawSaml2Provider(entityId: string, entityData) {\n return _putRawProvider(entityId, entityData);\n}\n"]}
|