@rockcarver/frodo-lib 0.16.2-9 → 0.17.1
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 +222 -1
- package/cjs/api/AgentApi.js +14 -61
- package/cjs/api/AgentApi.js.map +1 -1
- package/cjs/api/AgentApi.test.js.map +1 -1
- package/cjs/api/ApiTypes.js +0 -5
- package/cjs/api/ApiTypes.js.map +1 -1
- package/cjs/api/AuthenticateApi.js +9 -20
- package/cjs/api/AuthenticateApi.js.map +1 -1
- package/cjs/api/AuthenticateApi.test.js.map +1 -0
- package/cjs/api/BaseApi.js +82 -124
- package/cjs/api/BaseApi.js.map +1 -1
- package/cjs/api/CirclesOfTrustApi.js +8 -32
- package/cjs/api/CirclesOfTrustApi.js.map +1 -1
- package/cjs/api/IdmConfigApi.js +9 -34
- package/cjs/api/IdmConfigApi.js.map +1 -1
- package/cjs/api/LogApi.js +8 -31
- package/cjs/api/LogApi.js.map +1 -1
- package/cjs/api/ManagedObjectApi.js +34 -31
- package/cjs/api/ManagedObjectApi.js.map +1 -1
- package/cjs/api/NodeApi.js +10 -41
- package/cjs/api/NodeApi.js.map +1 -1
- package/cjs/api/NodeApi.test.js.map +1 -1
- package/cjs/api/OAuth2ClientApi.js +7 -26
- package/cjs/api/OAuth2ClientApi.js.map +1 -1
- package/cjs/api/OAuth2OIDCApi.js +28 -34
- package/cjs/api/OAuth2OIDCApi.js.map +1 -1
- package/cjs/api/OAuth2OIDCApi.test.js.map +1 -0
- package/cjs/api/OAuth2ProviderApi.js +5 -15
- package/cjs/api/OAuth2ProviderApi.js.map +1 -1
- package/cjs/api/RealmApi.js +8 -34
- package/cjs/api/RealmApi.js.map +1 -1
- package/cjs/api/Saml2Api.js +16 -67
- package/cjs/api/Saml2Api.js.map +1 -1
- package/cjs/api/ScriptApi.js +8 -30
- package/cjs/api/ScriptApi.js.map +1 -1
- package/cjs/api/SecretsApi.js +14 -64
- package/cjs/api/SecretsApi.js.map +1 -1
- package/cjs/api/SecretsApi.test.js.map +1 -1
- package/cjs/api/ServerInfoApi.js +6 -21
- package/cjs/api/ServerInfoApi.js.map +1 -1
- package/cjs/api/ServiceApi.js +49 -47
- package/cjs/api/ServiceApi.js.map +1 -1
- package/cjs/api/SocialIdentityProvidersApi.js +9 -36
- package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
- package/cjs/api/StartupApi.js +5 -24
- package/cjs/api/StartupApi.js.map +1 -1
- package/cjs/api/StartupApi.test.js.map +1 -1
- package/cjs/api/TreeApi.js +8 -30
- package/cjs/api/TreeApi.js.map +1 -1
- package/cjs/api/TreeApi.test.js.map +1 -1
- package/cjs/api/VariablesApi.js +9 -37
- package/cjs/api/VariablesApi.js.map +1 -1
- package/cjs/api/VariablesApi.test.js.map +1 -1
- package/cjs/api/utils/ApiUtils.js +47 -57
- package/cjs/api/utils/ApiUtils.js.map +1 -1
- package/cjs/api/utils/ApiUtils.test.js.map +1 -1
- package/cjs/api/utils/Base64.js +5 -15
- package/cjs/api/utils/Base64.js.map +1 -1
- package/cjs/ext/axios-curlirize/curlirize.js +2 -9
- package/cjs/ext/axios-curlirize/curlirize.js.map +1 -1
- package/cjs/ext/axios-curlirize/lib/CurlHelper.js +7 -22
- package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -1
- package/cjs/index.js +30 -89
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AdminOps.js +27 -165
- package/cjs/ops/AdminOps.js.map +1 -1
- package/cjs/ops/AgentOps.js +2 -159
- package/cjs/ops/AgentOps.js.map +1 -1
- package/cjs/ops/AgentOps.test.js.map +1 -1
- package/cjs/ops/AuthenticateOps.js +266 -226
- package/cjs/ops/AuthenticateOps.js.map +1 -1
- package/cjs/ops/AuthenticateOps.test.js.map +1 -1
- package/cjs/ops/CirclesOfTrustOps.js +13 -91
- package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.js +220 -136
- package/cjs/ops/ConnectionProfileOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.js +35 -379
- package/cjs/ops/EmailTemplateOps.js.map +1 -1
- package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
- package/cjs/ops/IdmOps.js +52 -426
- package/cjs/ops/IdmOps.js.map +1 -1
- package/cjs/ops/IdmOps.test.js.map +1 -1
- package/cjs/ops/IdpOps.js +11 -94
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/IdpOps.test.js.map +1 -1
- package/cjs/ops/JoseOps.js +81 -0
- package/cjs/ops/JoseOps.js.map +1 -0
- package/cjs/ops/JoseOps.test.js.map +1 -0
- package/cjs/ops/JourneyOps.js +139 -370
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/JourneyOps.test.js.map +1 -1
- package/cjs/ops/LogOps.js +14 -47
- package/cjs/ops/LogOps.js.map +1 -1
- package/cjs/ops/ManagedObjectOps.js +4 -12
- package/cjs/ops/ManagedObjectOps.js.map +1 -1
- package/cjs/ops/NodeOps.js +9 -67
- package/cjs/ops/NodeOps.js.map +1 -1
- package/cjs/ops/OAuth2ClientOps.js +10 -40
- package/cjs/ops/OAuth2ClientOps.js.map +1 -1
- package/cjs/ops/OpsTypes.js +0 -5
- package/cjs/ops/OpsTypes.js.map +1 -1
- package/cjs/ops/OrganizationOps.js +6 -25
- package/cjs/ops/OrganizationOps.js.map +1 -1
- package/cjs/ops/RealmOps.js +0 -19
- package/cjs/ops/RealmOps.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +11 -107
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/ops/Saml2Ops.test.js.map +1 -1
- package/cjs/ops/ScriptOps.js +26 -73
- package/cjs/ops/ScriptOps.js.map +1 -1
- package/cjs/ops/SecretsOps.js +2 -58
- package/cjs/ops/SecretsOps.js.map +1 -1
- package/cjs/ops/ServiceAccountOps.js +61 -0
- package/cjs/ops/ServiceAccountOps.js.map +1 -0
- package/cjs/ops/ServiceAccountOps.test.js.map +1 -0
- package/cjs/ops/ServiceOps.js +55 -101
- package/cjs/ops/ServiceOps.js.map +1 -1
- package/cjs/ops/StartupOps.js +2 -23
- package/cjs/ops/StartupOps.js.map +1 -1
- package/cjs/ops/ThemeOps.js +230 -436
- package/cjs/ops/ThemeOps.js.map +1 -1
- package/cjs/ops/ThemeOps.test.js.map +1 -0
- package/cjs/ops/VariablesOps.js +0 -38
- package/cjs/ops/VariablesOps.js.map +1 -1
- package/cjs/ops/utils/Console.js +29 -62
- package/cjs/ops/utils/Console.js.map +1 -1
- package/cjs/ops/utils/DataProtection.js +13 -47
- package/cjs/ops/utils/DataProtection.js.map +1 -1
- package/cjs/ops/utils/DataProtection.test.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.js +36 -74
- package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
- package/cjs/ops/utils/OpsUtils.js +27 -43
- package/cjs/ops/utils/OpsUtils.js.map +1 -1
- package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
- package/cjs/ops/utils/ValidationUtils.js +0 -13
- package/cjs/ops/utils/ValidationUtils.js.map +1 -1
- package/cjs/ops/utils/ValidationUtils.test.js.map +1 -1
- package/cjs/ops/utils/Version.js +2 -12
- package/cjs/ops/utils/Version.js.map +1 -1
- package/cjs/ops/utils/Version.test.js.map +1 -1
- package/cjs/ops/utils/Wordwrap.js +1 -2
- package/cjs/ops/utils/Wordwrap.js.map +1 -1
- package/cjs/ops/utils/Wordwrap.test.js.map +1 -0
- package/cjs/shared/State.js +239 -0
- package/cjs/shared/State.js.map +1 -0
- package/cjs/shared/State.test.js.map +1 -0
- package/cjs/storage/StaticStorage.js.map +1 -1
- package/cjs/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +161 -83
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
- package/cjs/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
- package/cjs/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
- package/cjs/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
- package/cjs/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
- package/cjs/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
- package/cjs/utils/AutoSetupPolly.js +79 -0
- package/cjs/utils/AutoSetupPolly.js.map +1 -0
- package/cjs/utils/SetupJest.js +6 -0
- package/cjs/utils/SetupJest.js.map +1 -0
- package/cjs/{test/mocks → utils}/snapshotResolve.js +10 -12
- package/cjs/utils/snapshotResolve.js.map +1 -0
- package/esm/api/AgentApi.mjs +19 -21
- package/esm/api/AgentApi.test.mjs +6 -15
- package/esm/api/ApiTypes.mjs +0 -5
- package/esm/api/AuthenticateApi.mjs +7 -10
- package/esm/api/AuthenticateApi.test.mjs +39 -0
- package/esm/api/BaseApi.mjs +96 -81
- package/esm/api/CirclesOfTrustApi.mjs +9 -12
- package/esm/api/IdmConfigApi.mjs +11 -12
- package/esm/api/LogApi.mjs +6 -10
- package/esm/api/ManagedObjectApi.mjs +23 -8
- package/esm/api/NodeApi.mjs +13 -15
- package/esm/api/NodeApi.test.mjs +13 -17
- package/esm/api/OAuth2ClientApi.mjs +7 -9
- package/esm/api/OAuth2OIDCApi.mjs +15 -9
- package/esm/api/OAuth2OIDCApi.test.mjs +53 -0
- package/esm/api/OAuth2ProviderApi.mjs +3 -5
- package/esm/api/RealmApi.mjs +10 -13
- package/esm/api/Saml2Api.mjs +25 -29
- package/esm/api/ScriptApi.mjs +9 -11
- package/esm/api/SecretsApi.mjs +21 -24
- package/esm/api/SecretsApi.test.mjs +9 -31
- package/esm/api/ServerInfoApi.mjs +5 -9
- package/esm/api/ServiceApi.mjs +53 -26
- package/esm/api/SocialIdentityProvidersApi.mjs +11 -13
- package/esm/api/StartupApi.mjs +5 -10
- package/esm/api/StartupApi.test.mjs +4 -7
- package/esm/api/TreeApi.mjs +9 -11
- package/esm/api/TreeApi.test.mjs +24 -61
- package/esm/api/VariablesApi.mjs +11 -13
- package/esm/api/VariablesApi.test.mjs +80 -222
- package/esm/api/utils/ApiUtils.mjs +45 -48
- package/esm/api/utils/ApiUtils.test.mjs +33 -32
- package/esm/api/utils/Base64.mjs +5 -9
- package/esm/ext/axios-curlirize/curlirize.mjs +2 -7
- package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +7 -20
- package/esm/index.mjs +23 -13
- package/esm/ops/AdminOps.mjs +33 -119
- package/esm/ops/AgentOps.mjs +37 -80
- package/esm/ops/AgentOps.test.mjs +5 -45
- package/esm/ops/AuthenticateOps.mjs +242 -175
- package/esm/ops/AuthenticateOps.test.mjs +7 -9
- package/esm/ops/CirclesOfTrustOps.mjs +24 -61
- package/esm/ops/ConnectionProfileOps.mjs +192 -82
- package/esm/ops/ConnectionProfileOps.test.mjs +19 -19
- package/esm/ops/EmailTemplateOps.mjs +18 -276
- package/esm/ops/EmailTemplateOps.test.mjs +19 -44
- package/esm/ops/IdmOps.mjs +30 -327
- package/esm/ops/IdmOps.test.mjs +47 -54
- package/esm/ops/IdpOps.mjs +21 -59
- package/esm/ops/IdpOps.test.mjs +5 -5
- package/esm/ops/JoseOps.mjs +41 -0
- package/esm/ops/JoseOps.test.mjs +137 -0
- package/esm/ops/JourneyOps.mjs +146 -289
- package/esm/ops/JourneyOps.test.mjs +29 -27
- package/esm/ops/LogOps.mjs +15 -25
- package/esm/ops/ManagedObjectOps.mjs +6 -6
- package/esm/ops/NodeOps.mjs +9 -47
- package/esm/ops/OAuth2ClientOps.mjs +13 -19
- package/esm/ops/OpsTypes.mjs +1 -3
- package/esm/ops/OrganizationOps.mjs +7 -14
- package/esm/ops/RealmOps.mjs +4 -7
- package/esm/ops/Saml2Ops.mjs +28 -62
- package/esm/ops/Saml2Ops.test.mjs +20 -23
- package/esm/ops/ScriptOps.mjs +29 -47
- package/esm/ops/SecretsOps.mjs +15 -31
- package/esm/ops/ServiceAccountOps.mjs +41 -0
- package/esm/ops/ServiceAccountOps.test.mjs +51 -0
- package/esm/ops/ServiceOps.mjs +66 -83
- package/esm/ops/StartupOps.mjs +4 -13
- package/esm/ops/ThemeOps.mjs +189 -298
- package/esm/{api/ThemeApi.test.mjs → ops/ThemeOps.test.mjs} +91 -96
- package/esm/ops/VariablesOps.mjs +9 -18
- package/esm/ops/utils/Console.mjs +28 -46
- package/esm/ops/utils/DataProtection.mjs +15 -28
- package/esm/ops/utils/DataProtection.test.mjs +8 -8
- package/esm/ops/utils/ExportImportUtils.mjs +34 -43
- package/esm/ops/utils/ExportImportUtils.test.mjs +20 -18
- package/esm/ops/utils/OpsUtils.mjs +27 -21
- package/esm/ops/utils/OpsUtils.test.mjs +155 -27
- package/esm/ops/utils/ValidationUtils.mjs +0 -9
- package/esm/ops/utils/Version.mjs +2 -3
- package/esm/ops/utils/Version.test.mjs +0 -2
- package/esm/ops/utils/Wordwrap.mjs +1 -1
- package/esm/ops/utils/Wordwrap.test.mjs +19 -0
- package/esm/shared/State.mjs +164 -0
- package/esm/shared/State.test.mjs +249 -0
- package/esm/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +147 -31
- package/esm/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
- package/esm/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
- package/esm/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
- package/esm/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
- package/esm/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
- package/esm/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
- package/esm/utils/AutoSetupPolly.mjs +72 -0
- package/esm/utils/SetupJest.mjs +3 -0
- package/esm/{test/mocks → utils}/snapshotResolve.mjs +10 -12
- package/package.json +36 -26
- package/types/api/AgentApi.d.ts.map +1 -1
- package/types/api/ApiTypes.d.ts +15 -16
- package/types/api/ApiTypes.d.ts.map +1 -1
- package/types/api/AuthenticateApi.d.ts +1 -1
- package/types/api/AuthenticateApi.d.ts.map +1 -1
- package/types/api/BaseApi.d.ts +2 -0
- package/types/api/BaseApi.d.ts.map +1 -1
- package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
- package/types/api/IdmConfigApi.d.ts.map +1 -1
- package/types/api/LogApi.d.ts.map +1 -1
- package/types/api/ManagedObjectApi.d.ts +9 -1
- package/types/api/ManagedObjectApi.d.ts.map +1 -1
- package/types/api/NodeApi.d.ts.map +1 -1
- package/types/api/OAuth2ClientApi.d.ts.map +1 -1
- package/types/api/OAuth2OIDCApi.d.ts +4 -2
- package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
- package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
- package/types/api/RealmApi.d.ts.map +1 -1
- package/types/api/Saml2Api.d.ts.map +1 -1
- package/types/api/ScriptApi.d.ts.map +1 -1
- package/types/api/SecretsApi.d.ts.map +1 -1
- package/types/api/ServerInfoApi.d.ts.map +1 -1
- package/types/api/ServiceApi.d.ts +14 -7
- package/types/api/ServiceApi.d.ts.map +1 -1
- package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
- package/types/api/StartupApi.d.ts.map +1 -1
- package/types/api/TreeApi.d.ts.map +1 -1
- package/types/api/VariablesApi.d.ts.map +1 -1
- package/types/api/utils/ApiUtils.d.ts +1 -0
- package/types/api/utils/ApiUtils.d.ts.map +1 -1
- package/types/index.d.ts +11 -5
- package/types/index.d.ts.map +1 -1
- package/types/ops/AuthenticateOps.d.ts +10 -2
- package/types/ops/AuthenticateOps.d.ts.map +1 -1
- package/types/ops/ConnectionProfileOps.d.ts +49 -21
- package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
- package/types/ops/EmailTemplateOps.d.ts +14 -33
- package/types/ops/EmailTemplateOps.d.ts.map +1 -1
- package/types/ops/IdmOps.d.ts +29 -37
- package/types/ops/IdmOps.d.ts.map +1 -1
- package/types/ops/JoseOps.d.ts +33 -0
- package/types/ops/JoseOps.d.ts.map +1 -0
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/LogOps.d.ts.map +1 -1
- package/types/ops/NodeOps.d.ts.map +1 -1
- package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
- package/types/ops/OpsTypes.d.ts +1 -1
- package/types/ops/OpsTypes.d.ts.map +1 -1
- package/types/ops/OrganizationOps.d.ts.map +1 -1
- package/types/ops/ScriptOps.d.ts.map +1 -1
- package/types/ops/ServiceAccountOps.d.ts +20 -0
- package/types/ops/ServiceAccountOps.d.ts.map +1 -0
- package/types/ops/ServiceOps.d.ts +18 -10
- package/types/ops/ServiceOps.d.ts.map +1 -1
- package/types/ops/ThemeOps.d.ts +35 -50
- package/types/ops/ThemeOps.d.ts.map +1 -1
- package/types/ops/utils/Console.d.ts +1 -1
- package/types/ops/utils/Console.d.ts.map +1 -1
- package/types/ops/utils/DataProtection.d.ts.map +1 -1
- package/types/ops/utils/ExportImportUtils.d.ts +5 -2
- package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
- package/types/ops/utils/OpsUtils.d.ts +6 -0
- package/types/ops/utils/OpsUtils.d.ts.map +1 -1
- package/types/ops/utils/Wordwrap.d.ts.map +1 -1
- package/types/shared/State.d.ts +223 -0
- package/types/shared/State.d.ts.map +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +19 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
- package/types/utils/AutoSetupPolly.d.ts +1 -0
- package/types/utils/AutoSetupPolly.d.ts.map +1 -0
- package/types/utils/SetupJest.d.ts +1 -0
- package/types/utils/SetupJest.d.ts.map +1 -0
- package/types/utils/snapshotResolve.d.ts +1 -0
- package/types/utils/snapshotResolve.d.ts.map +1 -0
- package/cjs/api/EmailTemplateApi.js +0 -73
- package/cjs/api/EmailTemplateApi.js.map +0 -1
- package/cjs/api/ThemeApi.js +0 -367
- package/cjs/api/ThemeApi.js.map +0 -1
- package/cjs/api/ThemeApi.test.js.map +0 -1
- package/cjs/storage/SessionStorage.js +0 -91
- package/cjs/storage/SessionStorage.js.map +0 -1
- package/cjs/test/mocks/snapshotResolve.js.map +0 -1
- package/esm/api/EmailTemplateApi.mjs +0 -34
- package/esm/api/ThemeApi.mjs +0 -271
- package/esm/storage/SessionStorage.mjs +0 -79
- package/types/api/EmailTemplateApi.d.ts +0 -22
- package/types/api/EmailTemplateApi.d.ts.map +0 -1
- package/types/api/ThemeApi.d.ts +0 -56
- package/types/api/ThemeApi.d.ts.map +0 -1
- package/types/storage/SessionStorage.d.ts +0 -71
- package/types/storage/SessionStorage.d.ts.map +0 -1
- package/types/test/mocks/snapshotResolve.d.ts +0 -1
- package/types/test/mocks/snapshotResolve.d.ts.map +0 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { createTable, printMessage } from './utils/Console';
|
|
3
3
|
import { getTypedFilename, saveToFile, titleCase, validateImport } from './utils/ExportImportUtils';
|
|
4
|
-
import
|
|
4
|
+
import * as state from '../shared/State';
|
|
5
5
|
import { getOAuth2Client, getOAuth2Clients, putOAuth2Client } from '../api/OAuth2ClientApi';
|
|
6
6
|
import { getOAuth2Provider } from '../api/OAuth2ProviderApi';
|
|
7
7
|
import { getRealmName } from '../api/utils/ApiUtils';
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* List OAuth2 clients
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
export async function listOAuth2Clients(long = false) {
|
|
13
13
|
try {
|
|
14
14
|
const clients = (await getOAuth2Clients()).data.result;
|
|
15
15
|
clients.sort((a, b) => a._id.localeCompare(b._id));
|
|
16
|
-
|
|
17
16
|
if (long) {
|
|
18
|
-
const table = createTable(['Client Id', 'Status', 'Client Type', 'Grant Types', 'Scopes', 'Redirect URIs'
|
|
17
|
+
const table = createTable(['Client Id', 'Status', 'Client Type', 'Grant Types', 'Scopes', 'Redirect URIs'
|
|
18
|
+
// 'Description',
|
|
19
19
|
]);
|
|
20
|
+
|
|
20
21
|
const grantTypesMap = {
|
|
21
22
|
authorization_code: 'Authz Code',
|
|
22
23
|
client_credentials: 'Client Creds',
|
|
@@ -31,9 +32,11 @@ export async function listOAuth2Clients(long = false) {
|
|
|
31
32
|
'urn:ietf:params:oauth:grant-type:jwt-bearer': 'JWT Bearer'
|
|
32
33
|
};
|
|
33
34
|
clients.forEach(client => {
|
|
34
|
-
table.push([client._id, client.coreOAuth2ClientConfig.status === 'Active' ? 'Active'['brightGreen'] : client.coreOAuth2ClientConfig.status.brightRed, client.coreOAuth2ClientConfig.clientType, client.advancedOAuth2ClientConfig.grantTypes.map(type => grantTypesMap[type]).join('\n'), client.coreOAuth2ClientConfig.scopes.join('\n'), client.coreOAuth2ClientConfig.redirectionUris.join('\n')
|
|
35
|
+
table.push([client._id, client.coreOAuth2ClientConfig.status === 'Active' ? 'Active'['brightGreen'] : client.coreOAuth2ClientConfig.status.brightRed, client.coreOAuth2ClientConfig.clientType, client.advancedOAuth2ClientConfig.grantTypes.map(type => grantTypesMap[type]).join('\n'), client.coreOAuth2ClientConfig.scopes.join('\n'), client.coreOAuth2ClientConfig.redirectionUris.join('\n')
|
|
36
|
+
// wordwrap(client.description, 30),
|
|
35
37
|
]);
|
|
36
38
|
});
|
|
39
|
+
|
|
37
40
|
printMessage(table.toString(), 'data');
|
|
38
41
|
} else {
|
|
39
42
|
clients.forEach(client => {
|
|
@@ -44,77 +47,68 @@ export async function listOAuth2Clients(long = false) {
|
|
|
44
47
|
printMessage(`Error listing applications - ${error}`, 'error');
|
|
45
48
|
}
|
|
46
49
|
}
|
|
50
|
+
|
|
47
51
|
/**
|
|
48
52
|
* Export OAuth2 client to file
|
|
49
53
|
* @param {String} id client id
|
|
50
54
|
* @param {String} file file name
|
|
51
55
|
*/
|
|
52
|
-
|
|
53
56
|
export async function exportOAuth2ClientToFile(id, file) {
|
|
54
57
|
let fileName = getTypedFilename(id, 'oauth2.app');
|
|
55
|
-
|
|
56
58
|
if (file) {
|
|
57
59
|
fileName = file;
|
|
58
60
|
}
|
|
59
|
-
|
|
60
61
|
const oauth2Service = (await getOAuth2Provider()).data;
|
|
61
62
|
const client = (await getOAuth2Client(id)).data;
|
|
62
63
|
client._provider = oauth2Service;
|
|
63
64
|
saveToFile('application', [client], '_id', fileName);
|
|
64
65
|
}
|
|
66
|
+
|
|
65
67
|
/**
|
|
66
68
|
* Export all OAuth2 clients to file
|
|
67
69
|
* @param {String} file file name
|
|
68
70
|
*/
|
|
69
|
-
|
|
70
71
|
export async function exportOAuth2ClientsToFile(file) {
|
|
71
|
-
let fileName = getTypedFilename(`all${titleCase(getRealmName(
|
|
72
|
-
|
|
72
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Applications`, 'oauth2.app');
|
|
73
73
|
if (file) {
|
|
74
74
|
fileName = file;
|
|
75
75
|
}
|
|
76
|
-
|
|
77
76
|
const oauth2Service = (await getOAuth2Provider()).data;
|
|
78
77
|
const clients = (await getOAuth2Clients()).data.result;
|
|
79
78
|
const exportData = [];
|
|
80
|
-
|
|
81
79
|
for (const client of clients) {
|
|
82
80
|
client._provider = oauth2Service;
|
|
83
81
|
exportData.push(client);
|
|
84
82
|
}
|
|
85
|
-
|
|
86
83
|
saveToFile('application', exportData, '_id', fileName);
|
|
87
84
|
}
|
|
85
|
+
|
|
88
86
|
/**
|
|
89
87
|
* Export all OAuth2 clients to separate files
|
|
90
88
|
*/
|
|
91
|
-
|
|
92
89
|
export async function exportOAuth2ClientsToFiles() {
|
|
93
90
|
const oauth2Service = (await getOAuth2Provider()).data;
|
|
94
91
|
const clients = (await getOAuth2Clients()).data.result;
|
|
95
|
-
|
|
96
92
|
for (const client of clients) {
|
|
97
93
|
client._provider = oauth2Service;
|
|
98
94
|
const fileName = getTypedFilename(client._id, 'oauth2.app');
|
|
99
95
|
saveToFile('application', [client], '_id', fileName);
|
|
100
96
|
}
|
|
101
97
|
}
|
|
98
|
+
|
|
102
99
|
/**
|
|
103
100
|
* Import OAuth2 clients from file
|
|
104
101
|
* @param {String} file file name
|
|
105
102
|
*/
|
|
106
|
-
|
|
107
103
|
export async function importOAuth2ClientsFromFile(file) {
|
|
108
104
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
109
105
|
if (err) throw err;
|
|
110
106
|
const applicationData = JSON.parse(data);
|
|
111
|
-
|
|
112
107
|
if (validateImport(applicationData.meta)) {
|
|
113
108
|
for (const id in applicationData.application) {
|
|
114
109
|
if (Object.prototype.hasOwnProperty.call(applicationData.application, id)) {
|
|
115
110
|
delete applicationData.application[id]._provider;
|
|
116
111
|
delete applicationData.application[id]._rev;
|
|
117
|
-
|
|
118
112
|
try {
|
|
119
113
|
await putOAuth2Client(id, applicationData.application[id]);
|
|
120
114
|
printMessage(`Imported ${id}`);
|
package/esm/ops/OpsTypes.mjs
CHANGED
|
@@ -5,17 +5,15 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Tree import options
|
|
7
7
|
*/
|
|
8
|
-
export let NodeClassification;
|
|
9
8
|
|
|
9
|
+
export let NodeClassification;
|
|
10
10
|
(function (NodeClassification) {
|
|
11
11
|
NodeClassification["STANDARD"] = "standard";
|
|
12
12
|
NodeClassification["CUSTOM"] = "custom";
|
|
13
13
|
NodeClassification["CLOUD"] = "cloud";
|
|
14
14
|
NodeClassification["PREMIUM"] = "premium";
|
|
15
15
|
})(NodeClassification || (NodeClassification = {}));
|
|
16
|
-
|
|
17
16
|
export let JourneyClassification;
|
|
18
|
-
|
|
19
17
|
(function (JourneyClassification) {
|
|
20
18
|
JourneyClassification["STANDARD"] = "standard";
|
|
21
19
|
JourneyClassification["CUSTOM"] = "custom";
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { queryAllManagedObjectsByType } from '../api/IdmConfigApi';
|
|
2
|
-
import
|
|
2
|
+
import * as state from '../shared/State';
|
|
3
3
|
import { printMessage } from './utils/Console';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Get organization managed object type
|
|
6
7
|
* @returns {String} organization managed object type in this realm
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
export function getRealmManagedOrganization() {
|
|
10
10
|
let realmManagedOrg = 'organization';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
realmManagedOrg = `${storage.session.getRealm()}_organization`;
|
|
11
|
+
if (state.getDeploymentType() === global.CLOUD_DEPLOYMENT_TYPE_KEY) {
|
|
12
|
+
realmManagedOrg = `${state.getRealm()}_organization`;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
return realmManagedOrg;
|
|
17
15
|
}
|
|
16
|
+
|
|
18
17
|
/**
|
|
19
18
|
* Get organizations
|
|
20
19
|
* @returns {Promise} promise resolving to an object containing an array of organization objects
|
|
21
20
|
*/
|
|
22
|
-
|
|
23
21
|
export async function getOrganizations() {
|
|
24
22
|
const orgs = [];
|
|
25
23
|
let result = {
|
|
@@ -30,7 +28,6 @@ export async function getOrganizations() {
|
|
|
30
28
|
totalPagedResults: -1,
|
|
31
29
|
remainingPagedResults: -1
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
try {
|
|
35
32
|
do {
|
|
36
33
|
try {
|
|
@@ -40,7 +37,6 @@ export async function getOrganizations() {
|
|
|
40
37
|
printMessage(queryAllManagedObjectsByTypeError, 'error');
|
|
41
38
|
printMessage(`Error querying ${getRealmManagedOrganization()} objects: ${queryAllManagedObjectsByTypeError}`, 'error');
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
orgs.concat(result.result);
|
|
45
41
|
printMessage('.', 'text', false);
|
|
46
42
|
} while (result.pagedResultsCookie);
|
|
@@ -48,10 +44,10 @@ export async function getOrganizations() {
|
|
|
48
44
|
printMessage(error.response.data, 'error');
|
|
49
45
|
printMessage(`Error retrieving all organizations: ${error}`, 'error');
|
|
50
46
|
}
|
|
51
|
-
|
|
52
47
|
return orgs;
|
|
53
|
-
}
|
|
48
|
+
}
|
|
54
49
|
|
|
50
|
+
// unfinished work
|
|
55
51
|
export async function listOrganizationsTopDown() {
|
|
56
52
|
const orgs = [];
|
|
57
53
|
let result = {
|
|
@@ -62,7 +58,6 @@ export async function listOrganizationsTopDown() {
|
|
|
62
58
|
totalPagedResults: -1,
|
|
63
59
|
remainingPagedResults: -1
|
|
64
60
|
};
|
|
65
|
-
|
|
66
61
|
do {
|
|
67
62
|
try {
|
|
68
63
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -71,11 +66,9 @@ export async function listOrganizationsTopDown() {
|
|
|
71
66
|
printMessage(queryAllManagedObjectsByTypeError, 'error');
|
|
72
67
|
printMessage(`Error querying ${getRealmManagedOrganization()} objects: ${queryAllManagedObjectsByTypeError}`, 'error');
|
|
73
68
|
}
|
|
74
|
-
|
|
75
69
|
orgs.concat(result.result);
|
|
76
70
|
printMessage('.', 'text', false);
|
|
77
71
|
} while (result.pagedResultsCookie);
|
|
78
|
-
|
|
79
72
|
return orgs;
|
|
80
73
|
}
|
|
81
74
|
//# sourceMappingURL=OrganizationOps.js.map
|
package/esm/ops/RealmOps.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createKeyValueTable, createTable, printMessage } from './utils/Console';
|
|
2
2
|
import { getRealmByName, getRealms, putRealm } from '../api/RealmApi';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* List realms
|
|
5
6
|
* @param {boolean} long Long list format with details
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
8
|
export async function listRealms(long = false) {
|
|
9
9
|
try {
|
|
10
10
|
const realms = (await getRealms()).data.result;
|
|
11
|
-
|
|
12
11
|
if (long) {
|
|
13
12
|
const table = createTable(['Name'['brightCyan'], 'Status'['brightCyan'], 'Custom Domains'['brightCyan'], 'Parent'['brightCyan']]);
|
|
14
13
|
realms.forEach(realmConfig => {
|
|
@@ -25,11 +24,11 @@ export async function listRealms(long = false) {
|
|
|
25
24
|
printMessage(error.response.data, 'error');
|
|
26
25
|
}
|
|
27
26
|
}
|
|
27
|
+
|
|
28
28
|
/**
|
|
29
29
|
* Describe realm
|
|
30
30
|
* @param {String} realm realm name
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
32
|
export async function describe(realm) {
|
|
34
33
|
try {
|
|
35
34
|
const realmConfig = await getRealmByName(realm);
|
|
@@ -44,12 +43,12 @@ export async function describe(realm) {
|
|
|
44
43
|
printMessage(`Realm ${realm} not found!`, 'error');
|
|
45
44
|
}
|
|
46
45
|
}
|
|
46
|
+
|
|
47
47
|
/**
|
|
48
48
|
* Add custom DNS domain name (realm DNS alias)
|
|
49
49
|
* @param {String} realm realm name
|
|
50
50
|
* @param {String} domain domain name
|
|
51
51
|
*/
|
|
52
|
-
|
|
53
52
|
export async function addCustomDomain(realm, domain) {
|
|
54
53
|
try {
|
|
55
54
|
let realmConfig = await getRealmByName(realm);
|
|
@@ -59,7 +58,6 @@ export async function addCustomDomain(realm, domain) {
|
|
|
59
58
|
exists = true;
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
|
-
|
|
63
61
|
if (!exists) {
|
|
64
62
|
try {
|
|
65
63
|
realmConfig.aliases.push(domain.toLowerCase());
|
|
@@ -79,17 +77,16 @@ export async function addCustomDomain(realm, domain) {
|
|
|
79
77
|
printMessage(`${error.message}`, 'error');
|
|
80
78
|
}
|
|
81
79
|
}
|
|
80
|
+
|
|
82
81
|
/**
|
|
83
82
|
* Remove custom DNS domain name (realm DNS alias)
|
|
84
83
|
* @param {String} realm realm name
|
|
85
84
|
* @param {String} domain domain name
|
|
86
85
|
*/
|
|
87
|
-
|
|
88
86
|
export async function removeCustomDomain(realm, domain) {
|
|
89
87
|
try {
|
|
90
88
|
let realmConfig = await getRealmByName(realm);
|
|
91
89
|
const aliases = realmConfig.aliases.filter(alias => domain.toLowerCase() !== alias.toLowerCase());
|
|
92
|
-
|
|
93
90
|
if (aliases.length < realmConfig.aliases.length) {
|
|
94
91
|
try {
|
|
95
92
|
realmConfig.aliases = aliases;
|
package/esm/ops/Saml2Ops.mjs
CHANGED
|
@@ -11,8 +11,9 @@ export const roleMap = {
|
|
|
11
11
|
serviceProvider: 'SP',
|
|
12
12
|
attributeQueryProvider: 'AttrQuery',
|
|
13
13
|
xacmlPolicyEnforcementPoint: 'XACML PEP'
|
|
14
|
-
};
|
|
14
|
+
};
|
|
15
15
|
|
|
16
|
+
// use a function vs a template variable to avoid problems in loops
|
|
16
17
|
export function createSaml2ExportTemplate() {
|
|
17
18
|
return {
|
|
18
19
|
meta: {},
|
|
@@ -24,105 +25,97 @@ export function createSaml2ExportTemplate() {
|
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
27
|
}
|
|
28
|
+
|
|
27
29
|
/**
|
|
28
30
|
* Get SAML2 entity provider stubs
|
|
29
31
|
* @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs
|
|
30
32
|
*/
|
|
31
|
-
|
|
32
33
|
export async function getSaml2ProviderStubs() {
|
|
33
34
|
const {
|
|
34
35
|
result
|
|
35
36
|
} = await getProviders();
|
|
36
37
|
return result;
|
|
37
38
|
}
|
|
39
|
+
|
|
38
40
|
/**
|
|
39
41
|
* Geta SAML2 entity provider by location and id
|
|
40
42
|
* @param {string} location Entity provider location (hosted or remote)
|
|
41
43
|
* @param {string} entityId64 Base64-encoded provider entity id
|
|
42
44
|
* @returns {Promise} a promise that resolves to a saml2 entity provider object
|
|
43
45
|
*/
|
|
44
|
-
|
|
45
46
|
export async function getProviderByLocationAndId(location, entityId64) {
|
|
46
47
|
return _getProviderByLocationAndId(location, entityId64);
|
|
47
48
|
}
|
|
49
|
+
|
|
48
50
|
/**
|
|
49
51
|
* Get a SAML2 entity provider's metadata URL by entity id
|
|
50
52
|
* @param {string} entityId SAML2 entity id
|
|
51
53
|
* @returns {string} the URL to get the metadata from
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
55
|
export function getProviderMetadataUrl(entityId) {
|
|
55
56
|
return _getProviderMetadataUrl(entityId);
|
|
56
57
|
}
|
|
58
|
+
|
|
57
59
|
/**
|
|
58
60
|
* Get a SAML2 entity provider's metadata by entity id
|
|
59
61
|
* @param {String} entityId SAML2 entity id
|
|
60
62
|
* @returns {Promise} a promise that resolves to an object containing a SAML2 metadata
|
|
61
63
|
*/
|
|
62
|
-
|
|
63
64
|
export async function getProviderMetadata(entityId) {
|
|
64
65
|
return _getProviderMetadata(entityId);
|
|
65
66
|
}
|
|
67
|
+
|
|
66
68
|
/**
|
|
67
69
|
* Include dependencies in the export file
|
|
68
70
|
* @param {Object} providerData Object representing a SAML entity provider
|
|
69
71
|
* @param {Object} fileData File data object to add dependencies to
|
|
70
72
|
*/
|
|
71
|
-
|
|
72
73
|
async function exportDependencies(providerData, fileData) {
|
|
73
74
|
const attrMapperScriptId = _.get(providerData, ['identityProvider', 'assertionProcessing', 'attributeMapper', 'attributeMapperScript']);
|
|
74
|
-
|
|
75
75
|
if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {
|
|
76
76
|
const scriptData = await getScript(attrMapperScriptId);
|
|
77
|
-
scriptData.script = convertBase64TextToArray(scriptData.script);
|
|
78
|
-
|
|
77
|
+
scriptData.script = convertBase64TextToArray(scriptData.script);
|
|
78
|
+
// eslint-disable-next-line no-param-reassign
|
|
79
79
|
fileData.script[attrMapperScriptId] = scriptData;
|
|
80
80
|
}
|
|
81
|
-
|
|
82
81
|
const idpAdapterScriptId = _.get(providerData, ['identityProvider', 'advanced', 'idpAdapter', 'idpAdapterScript']);
|
|
83
|
-
|
|
84
82
|
if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {
|
|
85
83
|
const scriptData = await getScript(idpAdapterScriptId);
|
|
86
|
-
scriptData.script = convertBase64TextToArray(scriptData.script);
|
|
87
|
-
|
|
84
|
+
scriptData.script = convertBase64TextToArray(scriptData.script);
|
|
85
|
+
// eslint-disable-next-line no-param-reassign
|
|
88
86
|
fileData.script[idpAdapterScriptId] = scriptData;
|
|
89
87
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const metaDataResponse = await getProviderMetadata(providerData.entityId);
|
|
89
|
+
// eslint-disable-next-line no-param-reassign
|
|
93
90
|
fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(encodeBase64Url(metaDataResponse));
|
|
94
91
|
}
|
|
92
|
+
|
|
95
93
|
/**
|
|
96
94
|
*
|
|
97
95
|
* @param {String} entityId Provider entity id
|
|
98
96
|
* @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.
|
|
99
97
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
98
|
export async function getSaml2ProviderStub(entityId) {
|
|
103
99
|
debugMessage(`Saml2Ops.getSaml2ProviderStub: start [entityId=${entityId}]`);
|
|
104
100
|
const found = await findProviders(`entityId eq '${entityId}'`);
|
|
105
|
-
|
|
106
101
|
switch (found.resultCount) {
|
|
107
102
|
case 0:
|
|
108
103
|
throw new Error(`No provider with entity id '${entityId}' found`);
|
|
109
|
-
|
|
110
104
|
case 1:
|
|
111
105
|
{
|
|
112
106
|
debugMessage(`Saml2Ops.getSaml2ProviderStub: end [entityId=${entityId}]`);
|
|
113
107
|
return found.result[0];
|
|
114
108
|
}
|
|
115
|
-
|
|
116
109
|
default:
|
|
117
110
|
throw new Error(`Multiple providers with entity id '${entityId}' found`);
|
|
118
111
|
}
|
|
119
112
|
}
|
|
113
|
+
|
|
120
114
|
/**
|
|
121
115
|
* Export a single entity provider. The response can be saved to file as is.
|
|
122
116
|
* @param {String} entityId Provider entity id
|
|
123
117
|
* @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.
|
|
124
118
|
*/
|
|
125
|
-
|
|
126
119
|
export async function getSaml2Provider(entityId) {
|
|
127
120
|
debugMessage(`Saml2Ops.getSaml2Provider: start [entityId=${entityId}]`);
|
|
128
121
|
const stub = await getSaml2ProviderStub(entityId);
|
|
@@ -134,12 +127,12 @@ export async function getSaml2Provider(entityId) {
|
|
|
134
127
|
debugMessage(`Saml2Ops.getSaml2Provider: end [entityId=${entityId}]`);
|
|
135
128
|
return providerData;
|
|
136
129
|
}
|
|
130
|
+
|
|
137
131
|
/**
|
|
138
132
|
* Export a single entity provider. The response can be saved to file as is.
|
|
139
133
|
* @param {String} entityId Provider entity id
|
|
140
134
|
* @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.
|
|
141
135
|
*/
|
|
142
|
-
|
|
143
136
|
export async function exportSaml2Provider(entityId) {
|
|
144
137
|
debugMessage(`Saml2Ops.exportSaml2Provider: start [entityId=${entityId}]`);
|
|
145
138
|
const exportData = createSaml2ExportTemplate();
|
|
@@ -154,108 +147,89 @@ export async function exportSaml2Provider(entityId) {
|
|
|
154
147
|
debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);
|
|
155
148
|
return exportData;
|
|
156
149
|
}
|
|
150
|
+
|
|
157
151
|
/**
|
|
158
152
|
* Export all entity providers. The response can be saved to file as is.
|
|
159
153
|
* @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.
|
|
160
154
|
*/
|
|
161
|
-
|
|
162
155
|
export async function exportSaml2Providers() {
|
|
163
156
|
const fileData = createSaml2ExportTemplate();
|
|
164
157
|
const stubs = await getSaml2ProviderStubs();
|
|
165
|
-
|
|
166
158
|
for (const stub of stubs) {
|
|
167
159
|
const providerData = await getProviderByLocationAndId(stub.location, stub._id);
|
|
168
160
|
await exportDependencies(providerData, fileData);
|
|
169
161
|
fileData.saml[stub.location][providerData._id] = providerData;
|
|
170
162
|
}
|
|
171
|
-
|
|
172
163
|
return fileData;
|
|
173
164
|
}
|
|
165
|
+
|
|
174
166
|
/**
|
|
175
167
|
* Include dependencies from the import file
|
|
176
168
|
* @param {Object} providerData Object representing a SAML entity provider
|
|
177
169
|
* @param {Object} fileData File data object to read dependencies from
|
|
178
170
|
*/
|
|
179
|
-
|
|
180
171
|
async function importDependencies(providerData, fileData) {
|
|
181
172
|
debugMessage(`Saml2Ops.importDependencies: start`);
|
|
182
|
-
|
|
183
173
|
const attrMapperScriptId = _.get(providerData, ['identityProvider', 'assertionProcessing', 'attributeMapper', 'attributeMapperScript']);
|
|
184
|
-
|
|
185
174
|
if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {
|
|
186
175
|
debugMessage(`Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`);
|
|
187
|
-
|
|
188
176
|
const scriptData = _.get(fileData, ['script', attrMapperScriptId]);
|
|
189
|
-
|
|
190
177
|
scriptData.script = convertTextArrayToBase64(scriptData.script);
|
|
191
178
|
await createOrUpdateScript(attrMapperScriptId, scriptData);
|
|
192
179
|
}
|
|
193
|
-
|
|
194
180
|
const idpAdapterScriptId = _.get(providerData, ['identityProvider', 'advanced', 'idpAdapter', 'idpAdapterScript']);
|
|
195
|
-
|
|
196
181
|
if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {
|
|
197
182
|
debugMessage(`Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`);
|
|
198
|
-
|
|
199
183
|
const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);
|
|
200
|
-
|
|
201
184
|
scriptData.script = convertTextArrayToBase64(scriptData.script);
|
|
202
185
|
await createOrUpdateScript(idpAdapterScriptId, scriptData);
|
|
203
186
|
}
|
|
204
|
-
|
|
205
187
|
debugMessage(`Saml2Ops.importDependencies: end`);
|
|
206
188
|
}
|
|
189
|
+
|
|
207
190
|
/**
|
|
208
191
|
* Find provider in import file and return its location
|
|
209
192
|
* @param {String} entityId64 Base64-encoded provider entity id
|
|
210
193
|
* @param {Object} data Import file json data
|
|
211
194
|
* @returns {String} 'hosted' or 'remote' if found, undefined otherwise
|
|
212
195
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
196
|
function getLocation(entityId64, data) {
|
|
216
197
|
if (data.saml.hosted[entityId64]) {
|
|
217
198
|
return Saml2ProiderLocation.HOSTED;
|
|
218
199
|
}
|
|
219
|
-
|
|
220
200
|
if (data.saml.remote[entityId64]) {
|
|
221
201
|
return Saml2ProiderLocation.REMOTE;
|
|
222
202
|
}
|
|
223
|
-
|
|
224
203
|
return undefined;
|
|
225
204
|
}
|
|
205
|
+
|
|
226
206
|
/**
|
|
227
207
|
* Import a SAML entity provider
|
|
228
208
|
* @param {string} entityId Provider entity id
|
|
229
209
|
* @param {Saml2ExportInterface} importData Import data
|
|
230
210
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
211
|
export async function importSaml2Provider(entityId, importData) {
|
|
234
212
|
debugMessage(`Saml2Ops.importSaml2Provider: start`);
|
|
235
213
|
const entityId64 = encode(entityId, false);
|
|
236
214
|
const location = getLocation(entityId64, importData);
|
|
237
|
-
|
|
238
215
|
if (location) {
|
|
239
216
|
const providerData = importData.saml[location][entityId64];
|
|
240
217
|
await importDependencies(providerData, importData);
|
|
241
218
|
let metaData = null;
|
|
242
|
-
|
|
243
219
|
if (location === Saml2ProiderLocation.REMOTE) {
|
|
244
220
|
metaData = convertTextArrayToBase64Url(importData.saml.metadata[entityId64]);
|
|
245
221
|
}
|
|
246
|
-
|
|
247
222
|
await createProvider(location, providerData, metaData);
|
|
248
223
|
} else {
|
|
249
224
|
throw new Error(`Provider ${entityId} not found in import data!`);
|
|
250
225
|
}
|
|
251
|
-
|
|
252
226
|
debugMessage(`Saml2Ops.importSaml2Provider: end`);
|
|
253
227
|
}
|
|
228
|
+
|
|
254
229
|
/**
|
|
255
230
|
* Import SAML entity providers
|
|
256
231
|
* @param {Saml2ExportInterface} importData Import data
|
|
257
232
|
*/
|
|
258
|
-
|
|
259
233
|
export async function importSaml2Providers(importData) {
|
|
260
234
|
debugMessage(`Saml2Ops.importSaml2Providers: start`);
|
|
261
235
|
const myStatus = {
|
|
@@ -264,7 +238,6 @@ export async function importSaml2Providers(importData) {
|
|
|
264
238
|
warnings: 0,
|
|
265
239
|
failures: 0
|
|
266
240
|
};
|
|
267
|
-
|
|
268
241
|
try {
|
|
269
242
|
// find providers in hosted and in remote and map locations
|
|
270
243
|
const hostedIds = Object.keys(importData.saml.hosted);
|
|
@@ -272,13 +245,11 @@ export async function importSaml2Providers(importData) {
|
|
|
272
245
|
const providerIds = hostedIds.concat(remoteIds);
|
|
273
246
|
myStatus.total = providerIds.length;
|
|
274
247
|
createProgressIndicator(providerIds.length, 'Importing providers...');
|
|
275
|
-
|
|
276
248
|
for (const entityId64 of providerIds) {
|
|
277
249
|
debugMessage(`Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`);
|
|
278
250
|
const location = hostedIds.includes(entityId64) ? Saml2ProiderLocation.HOSTED : Saml2ProiderLocation.REMOTE;
|
|
279
251
|
const entityId = decode(entityId64);
|
|
280
252
|
const providerData = importData.saml[location][entityId64];
|
|
281
|
-
|
|
282
253
|
try {
|
|
283
254
|
await importDependencies(providerData, importData);
|
|
284
255
|
} catch (importDependenciesErr) {
|
|
@@ -286,13 +257,10 @@ export async function importSaml2Providers(importData) {
|
|
|
286
257
|
printMessage(`\nWarning importing dependencies for ${entityId}`, 'warn');
|
|
287
258
|
printMessage(importDependenciesErr.response.data, 'error');
|
|
288
259
|
}
|
|
289
|
-
|
|
290
260
|
let metaData = null;
|
|
291
|
-
|
|
292
261
|
if (location === Saml2ProiderLocation.REMOTE) {
|
|
293
262
|
metaData = convertTextArrayToBase64Url(importData.saml.metadata[entityId64]);
|
|
294
263
|
}
|
|
295
|
-
|
|
296
264
|
try {
|
|
297
265
|
await createProvider(location, providerData, metaData);
|
|
298
266
|
myStatus.successes += 1;
|
|
@@ -303,23 +271,22 @@ export async function importSaml2Providers(importData) {
|
|
|
303
271
|
printMessage(createProviderErr, 'error');
|
|
304
272
|
}
|
|
305
273
|
}
|
|
306
|
-
|
|
307
274
|
myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;
|
|
308
275
|
stopProgressIndicator(myStatus.message);
|
|
309
276
|
} catch (error) {
|
|
310
277
|
myStatus.failures += 1;
|
|
311
278
|
printMessage(`\nError importing providers ${error.message}`, 'error');
|
|
312
279
|
}
|
|
313
|
-
|
|
314
280
|
debugMessage(`Saml2Ops.importSaml2Providers: end`);
|
|
315
281
|
return myStatus;
|
|
316
|
-
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future
|
|
317
285
|
|
|
318
286
|
/**
|
|
319
287
|
* Deletes entity provider
|
|
320
288
|
* @param {string} entityId The entity id for the entity to be deleted
|
|
321
289
|
*/
|
|
322
|
-
|
|
323
290
|
export async function deleteSaml2Provider(entityId) {
|
|
324
291
|
try {
|
|
325
292
|
await deleteProvider(entityId);
|
|
@@ -327,10 +294,10 @@ export async function deleteSaml2Provider(entityId) {
|
|
|
327
294
|
printMessage(error.message, 'error');
|
|
328
295
|
}
|
|
329
296
|
}
|
|
297
|
+
|
|
330
298
|
/**
|
|
331
299
|
* Deletes all entity providers.
|
|
332
300
|
*/
|
|
333
|
-
|
|
334
301
|
export async function deleteSaml2Providers() {
|
|
335
302
|
const applicationList = (await getRawProviders()).result;
|
|
336
303
|
const deleteApplicationPromises = [];
|
|
@@ -339,35 +306,34 @@ export async function deleteSaml2Providers() {
|
|
|
339
306
|
deleteApplicationPromises.push(deleteSaml2Provider(item._id));
|
|
340
307
|
});
|
|
341
308
|
const deleteApplicationResult = await Promise.all(deleteApplicationPromises);
|
|
342
|
-
|
|
343
309
|
if (deleteApplicationResult.length == applicationList.length) {
|
|
344
310
|
printMessage('SAML Entity cleanup done', 'info');
|
|
345
311
|
}
|
|
346
312
|
}
|
|
313
|
+
|
|
347
314
|
/**
|
|
348
315
|
* Retrieves all entity providers using the legacy federation enpoints.
|
|
349
316
|
* @returns {Promise} a promise that resolves to an object containing an array of providers
|
|
350
317
|
*/
|
|
351
|
-
|
|
352
318
|
export async function getRawProviders() {
|
|
353
319
|
return _getRawProviders();
|
|
354
320
|
}
|
|
321
|
+
|
|
355
322
|
/**
|
|
356
323
|
* Retrieves all entity providers using the legacy federation enpoints.
|
|
357
324
|
* @param {string} entityId The entity provider id
|
|
358
325
|
* @returns {Promise} a promise that resolves to an object containing an array of providers
|
|
359
326
|
*/
|
|
360
|
-
|
|
361
327
|
export async function getRawProvider(entityId) {
|
|
362
328
|
return _getRawProvider(entityId);
|
|
363
329
|
}
|
|
330
|
+
|
|
364
331
|
/**
|
|
365
332
|
* Stores a new SAML2 entity provider
|
|
366
333
|
* @param {string} entityId The entity provider id
|
|
367
334
|
* @param {string} entityData The actual data containing the entity provider configuration
|
|
368
335
|
* @returns {Promise} Promise that resolves to a provider object
|
|
369
336
|
*/
|
|
370
|
-
|
|
371
337
|
export async function putRawProvider(entityId, entityData) {
|
|
372
338
|
return _putRawProvider(entityId, entityData);
|
|
373
339
|
}
|