@rockcarver/frodo-lib 0.16.2-9 → 0.17.0
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 +217 -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 +265 -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 +241 -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
package/esm/ops/AdminOps.mjs
CHANGED
|
@@ -10,20 +10,19 @@ import { clientCredentialsGrant } from '../api/OAuth2OIDCApi';
|
|
|
10
10
|
import { printMessage } from './utils/Console';
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import { fileURLToPath } from 'url';
|
|
13
|
-
|
|
14
13
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
|
|
16
14
|
const OAUTH2_CLIENT = JSON.parse(fs.readFileSync(path.resolve(__dirname, './templates/OAuth2ClientTemplate.json'), 'utf8'));
|
|
17
15
|
const GENERIC_EXTENSION_ATTRIBUTES = JSON.parse(fs.readFileSync(path.resolve(__dirname, './templates/cloud/GenericExtensionAttributesTemplate.json'), 'utf8'));
|
|
18
16
|
const protectedClients = ['ui', 'idm-provisioning'];
|
|
19
17
|
const protectedSubjects = ['amadmin', 'autoid-resource-server'];
|
|
20
|
-
const privilegedScopes = ['am-introspect-all-tokens', 'fr:idm:*', 'fr:idc:esv:*'];
|
|
21
|
-
|
|
18
|
+
const privilegedScopes = ['am-introspect-all-tokens', 'fr:idm:*', 'fr:idc:esv:*'];
|
|
19
|
+
// const privilegedUsers = ['openidm-admin'];
|
|
22
20
|
const privilegedRoles = ['internal/role/openidm-authorized', 'internal/role/openidm-admin'];
|
|
23
21
|
const adminScopes = ['fr:idm:*', 'fr:idc:esv:*'];
|
|
24
22
|
const adminDefaultScopes = ['fr:idm:*'];
|
|
25
23
|
const adminRoles = ['internal/role/openidm-authorized', 'internal/role/openidm-admin'];
|
|
26
24
|
const autoIdRoles = ['internal/role/platform-provisioning', 'internal/role/openidm-authorized', 'internal/role/openidm-admin'];
|
|
25
|
+
|
|
27
26
|
/*
|
|
28
27
|
* List all oauth2 clients, which have a corresponding staticUserMapping
|
|
29
28
|
* in the IDM authentication.json:
|
|
@@ -49,7 +48,6 @@ const autoIdRoles = ['internal/role/platform-provisioning', 'internal/role/openi
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
*/
|
|
52
|
-
|
|
53
51
|
export async function listOAuth2CustomClients() {
|
|
54
52
|
let clients = (await getOAuth2Clients()).data.result;
|
|
55
53
|
clients = clients.map(client => client._id).filter(client => !protectedClients.includes(client));
|
|
@@ -58,6 +56,7 @@ export async function listOAuth2CustomClients() {
|
|
|
58
56
|
const adminClients = subjects.filter(subject => clients.includes(subject));
|
|
59
57
|
return adminClients;
|
|
60
58
|
}
|
|
59
|
+
|
|
61
60
|
/*
|
|
62
61
|
* List all oauth2 clients, which have the fr:idm:* scope and a
|
|
63
62
|
* corresponding staticUserMapping in the IDM authentication.json
|
|
@@ -80,12 +79,10 @@ export async function listOAuth2CustomClients() {
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
*/
|
|
83
|
-
|
|
84
82
|
export async function listOAuth2AdminClients() {
|
|
85
83
|
let clients = (await getOAuth2Clients()).data.result;
|
|
86
84
|
clients = clients.filter(client => {
|
|
87
85
|
let isPrivileged = false;
|
|
88
|
-
|
|
89
86
|
if (client.coreOAuth2ClientConfig.scopes) {
|
|
90
87
|
client.coreOAuth2ClientConfig.scopes.forEach(scope => {
|
|
91
88
|
if (privilegedScopes.includes(scope)) {
|
|
@@ -93,13 +90,11 @@ export async function listOAuth2AdminClients() {
|
|
|
93
90
|
}
|
|
94
91
|
});
|
|
95
92
|
}
|
|
96
|
-
|
|
97
93
|
return isPrivileged;
|
|
98
94
|
}).map(client => client._id).filter(client => !protectedClients.includes(client));
|
|
99
95
|
const authentication = await getConfigEntity('authentication');
|
|
100
96
|
const subjects = authentication.rsFilter.staticUserMapping.filter(mapping => {
|
|
101
97
|
let isPrivileged = false;
|
|
102
|
-
|
|
103
98
|
if (mapping.roles) {
|
|
104
99
|
mapping.roles.forEach(role => {
|
|
105
100
|
if (privilegedRoles.includes(role)) {
|
|
@@ -107,12 +102,12 @@ export async function listOAuth2AdminClients() {
|
|
|
107
102
|
}
|
|
108
103
|
});
|
|
109
104
|
}
|
|
110
|
-
|
|
111
105
|
return isPrivileged;
|
|
112
106
|
}).map(mapping => mapping.subject).filter(subject => !protectedSubjects.includes(subject));
|
|
113
107
|
const adminClients = subjects.filter(subject => clients.includes(subject));
|
|
114
108
|
return adminClients;
|
|
115
109
|
}
|
|
110
|
+
|
|
116
111
|
/*
|
|
117
112
|
* List all static user mappings that are not oauth2 clients in authentication.json
|
|
118
113
|
* and are assigned admin privileges:
|
|
@@ -154,14 +149,12 @@ export async function listOAuth2AdminClients() {
|
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
*/
|
|
157
|
-
|
|
158
152
|
export async function listNonOAuth2AdminStaticUserMappings(showProtected) {
|
|
159
153
|
let clients = (await getOAuth2Clients()).data.result;
|
|
160
154
|
clients = clients.map(client => client._id).filter(client => !protectedClients.includes(client));
|
|
161
155
|
const authentication = await getConfigEntity('authentication');
|
|
162
156
|
let subjects = authentication.rsFilter.staticUserMapping.filter(mapping => {
|
|
163
157
|
let isPrivileged = false;
|
|
164
|
-
|
|
165
158
|
if (mapping.roles) {
|
|
166
159
|
mapping.roles.forEach(role => {
|
|
167
160
|
if (privilegedRoles.includes(role)) {
|
|
@@ -169,45 +162,35 @@ export async function listNonOAuth2AdminStaticUserMappings(showProtected) {
|
|
|
169
162
|
}
|
|
170
163
|
});
|
|
171
164
|
}
|
|
172
|
-
|
|
173
165
|
return isPrivileged;
|
|
174
166
|
}).map(mapping => mapping.subject);
|
|
175
|
-
|
|
176
167
|
if (!showProtected) {
|
|
177
168
|
subjects = subjects.filter(subject => !protectedSubjects.includes(subject));
|
|
178
169
|
}
|
|
179
|
-
|
|
180
170
|
const adminSubjects = subjects.filter(subject => !clients.includes(subject));
|
|
181
171
|
return adminSubjects;
|
|
182
172
|
}
|
|
183
|
-
|
|
184
173
|
async function getDynamicClientRegistrationScope() {
|
|
185
174
|
const provider = (await getOAuth2Provider()).data;
|
|
186
175
|
return provider.clientDynamicRegistrationConfig.dynamicClientRegistrationScope;
|
|
187
176
|
}
|
|
188
|
-
|
|
189
177
|
async function addAdminScopes(clientId, client) {
|
|
190
178
|
const modClient = client;
|
|
191
179
|
const allAdminScopes = adminScopes.concat([await getDynamicClientRegistrationScope()]);
|
|
192
180
|
let addScopes = [];
|
|
193
|
-
|
|
194
181
|
if (modClient.coreOAuth2ClientConfig.scopes && modClient.coreOAuth2ClientConfig.scopes.value) {
|
|
195
182
|
addScopes = allAdminScopes.filter(scope => {
|
|
196
183
|
let add = false;
|
|
197
|
-
|
|
198
184
|
if (!modClient.coreOAuth2ClientConfig.scopes.value.includes(scope)) {
|
|
199
185
|
add = true;
|
|
200
186
|
}
|
|
201
|
-
|
|
202
187
|
return add;
|
|
203
188
|
});
|
|
204
189
|
modClient.coreOAuth2ClientConfig.scopes.value = modClient.coreOAuth2ClientConfig.scopes.value.concat(addScopes);
|
|
205
190
|
} else {
|
|
206
191
|
modClient.coreOAuth2ClientConfig.scopes.value = allAdminScopes;
|
|
207
192
|
}
|
|
208
|
-
|
|
209
193
|
let addDefaultScope = false;
|
|
210
|
-
|
|
211
194
|
if (modClient.coreOAuth2ClientConfig.defaultScopes && modClient.coreOAuth2ClientConfig.defaultScopes.value) {
|
|
212
195
|
if (modClient.coreOAuth2ClientConfig.defaultScopes.value.length === 0) {
|
|
213
196
|
addDefaultScope = true;
|
|
@@ -216,20 +199,16 @@ async function addAdminScopes(clientId, client) {
|
|
|
216
199
|
printMessage(`Client "${clientId}" already has default scopes configured, not adding admin default scope.`);
|
|
217
200
|
}
|
|
218
201
|
}
|
|
219
|
-
|
|
220
202
|
if (addScopes.length > 0 || addDefaultScope) {
|
|
221
203
|
printMessage(`Adding admin scopes to client "${clientId}"...`);
|
|
222
204
|
} else {
|
|
223
205
|
printMessage(`Client "${clientId}" already has admin scopes.`);
|
|
224
206
|
}
|
|
225
|
-
|
|
226
207
|
return modClient;
|
|
227
208
|
}
|
|
228
|
-
|
|
229
209
|
function addClientCredentialsGrantType(clientId, client) {
|
|
230
210
|
const modClient = client;
|
|
231
211
|
let modified = false;
|
|
232
|
-
|
|
233
212
|
if (modClient.advancedOAuth2ClientConfig.grantTypes && modClient.advancedOAuth2ClientConfig.grantTypes.value) {
|
|
234
213
|
if (!modClient.advancedOAuth2ClientConfig.grantTypes.value.includes('client_credentials')) {
|
|
235
214
|
modified = true;
|
|
@@ -238,27 +217,21 @@ function addClientCredentialsGrantType(clientId, client) {
|
|
|
238
217
|
} else {
|
|
239
218
|
modClient.advancedOAuth2ClientConfig.grantTypes.value = ['client_credentials'];
|
|
240
219
|
}
|
|
241
|
-
|
|
242
220
|
modClient.advancedOAuth2ClientConfig.grantTypes.inherited = false;
|
|
243
|
-
|
|
244
221
|
if (modified) {
|
|
245
222
|
printMessage(`Adding client credentials grant type to client "${clientId}"...`);
|
|
246
223
|
} else {
|
|
247
224
|
printMessage(`Client "${clientId}" already has client credentials grant type.`);
|
|
248
225
|
}
|
|
249
|
-
|
|
250
226
|
return modClient;
|
|
251
227
|
}
|
|
252
|
-
|
|
253
228
|
async function addAdminStaticUserMapping(name) {
|
|
254
229
|
let authentication = {};
|
|
255
|
-
|
|
256
230
|
try {
|
|
257
231
|
authentication = await getConfigEntity('authentication');
|
|
258
232
|
} catch (error) {
|
|
259
233
|
printMessage(`Error reading IDM authentication configuration: ${error.message}`, 'error');
|
|
260
234
|
}
|
|
261
|
-
|
|
262
235
|
let needsAdminMapping = true;
|
|
263
236
|
let addRoles = [];
|
|
264
237
|
const mappings = authentication['rsFilter']['staticUserMapping'].map(mapping => {
|
|
@@ -266,22 +239,18 @@ async function addAdminStaticUserMapping(name) {
|
|
|
266
239
|
if (mapping.subject !== name) {
|
|
267
240
|
return mapping;
|
|
268
241
|
}
|
|
269
|
-
|
|
270
242
|
needsAdminMapping = false;
|
|
271
243
|
addRoles = adminRoles.filter(role => {
|
|
272
244
|
let add = false;
|
|
273
|
-
|
|
274
245
|
if (!mapping.roles.includes(role)) {
|
|
275
246
|
add = true;
|
|
276
247
|
}
|
|
277
|
-
|
|
278
248
|
return add;
|
|
279
249
|
});
|
|
280
250
|
const newMapping = mapping;
|
|
281
251
|
newMapping.roles = newMapping.roles.concat(addRoles);
|
|
282
252
|
return newMapping;
|
|
283
253
|
});
|
|
284
|
-
|
|
285
254
|
if (needsAdminMapping) {
|
|
286
255
|
printMessage(`Creating static user mapping for client "${name}"...`);
|
|
287
256
|
mappings.push({
|
|
@@ -291,12 +260,9 @@ async function addAdminStaticUserMapping(name) {
|
|
|
291
260
|
roles: adminRoles
|
|
292
261
|
});
|
|
293
262
|
}
|
|
294
|
-
|
|
295
263
|
authentication['rsFilter']['staticUserMapping'] = mappings;
|
|
296
|
-
|
|
297
264
|
if (addRoles.length > 0 || needsAdminMapping) {
|
|
298
265
|
printMessage(`Adding admin roles to static user mapping for client "${name}"...`);
|
|
299
|
-
|
|
300
266
|
try {
|
|
301
267
|
await putConfigEntity('authentication', authentication);
|
|
302
268
|
} catch (putConfigEntityError) {
|
|
@@ -307,6 +273,7 @@ async function addAdminStaticUserMapping(name) {
|
|
|
307
273
|
printMessage(`Static user mapping for client "${name}" already has admin roles.`);
|
|
308
274
|
}
|
|
309
275
|
}
|
|
276
|
+
|
|
310
277
|
/*
|
|
311
278
|
* Add AutoId static user mapping to authentication.json to enable dashboards and other AutoId-based functionality.
|
|
312
279
|
{
|
|
@@ -328,8 +295,6 @@ async function addAdminStaticUserMapping(name) {
|
|
|
328
295
|
}
|
|
329
296
|
}
|
|
330
297
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
298
|
export async function addAutoIdStaticUserMapping() {
|
|
334
299
|
const name = 'autoid-resource-server';
|
|
335
300
|
const authentication = await getConfigEntity('authentication');
|
|
@@ -340,22 +305,18 @@ export async function addAutoIdStaticUserMapping() {
|
|
|
340
305
|
if (mapping.subject !== name) {
|
|
341
306
|
return mapping;
|
|
342
307
|
}
|
|
343
|
-
|
|
344
308
|
needsAdminMapping = false;
|
|
345
309
|
addRoles = autoIdRoles.filter(role => {
|
|
346
310
|
let add = false;
|
|
347
|
-
|
|
348
311
|
if (!mapping.roles.includes(role)) {
|
|
349
312
|
add = true;
|
|
350
313
|
}
|
|
351
|
-
|
|
352
314
|
return add;
|
|
353
315
|
});
|
|
354
316
|
const newMapping = mapping;
|
|
355
317
|
newMapping.roles = newMapping.roles.concat(addRoles);
|
|
356
318
|
return newMapping;
|
|
357
319
|
});
|
|
358
|
-
|
|
359
320
|
if (needsAdminMapping) {
|
|
360
321
|
printMessage(`Creating static user mapping for AutoId client "${name}"...`);
|
|
361
322
|
mappings.push({
|
|
@@ -365,12 +326,9 @@ export async function addAutoIdStaticUserMapping() {
|
|
|
365
326
|
roles: autoIdRoles
|
|
366
327
|
});
|
|
367
328
|
}
|
|
368
|
-
|
|
369
329
|
authentication.rsFilter.staticUserMapping = mappings;
|
|
370
|
-
|
|
371
330
|
if (addRoles.length > 0 || needsAdminMapping) {
|
|
372
331
|
printMessage(`Adding required roles to static user mapping for AutoId client "${name}"...`);
|
|
373
|
-
|
|
374
332
|
try {
|
|
375
333
|
await putConfigEntity('authentication', authentication);
|
|
376
334
|
} catch (putConfigEntityError) {
|
|
@@ -383,73 +341,58 @@ export async function addAutoIdStaticUserMapping() {
|
|
|
383
341
|
}
|
|
384
342
|
export async function grantOAuth2ClientAdminPrivileges(clientId) {
|
|
385
343
|
let client = (await getOAuth2Client(clientId)).data;
|
|
386
|
-
|
|
387
344
|
if (client.coreOAuth2ClientConfig.clientName.value.length === 0) {
|
|
388
345
|
client.coreOAuth2ClientConfig.clientName.value = [clientId];
|
|
389
346
|
}
|
|
390
|
-
|
|
391
347
|
if (client.advancedOAuth2ClientConfig.descriptions.value.length === 0 || client.advancedOAuth2ClientConfig.descriptions.value[0].startsWith('Modified by Frodo') || client.advancedOAuth2ClientConfig.descriptions.value[0].startsWith('Created by Frodo')) {
|
|
392
348
|
client.advancedOAuth2ClientConfig.descriptions.value = [`Modified by Frodo on ${new Date().toLocaleString()}`];
|
|
393
349
|
}
|
|
394
|
-
|
|
395
350
|
client = await addAdminScopes(clientId, client);
|
|
396
351
|
client = addClientCredentialsGrantType(clientId, client);
|
|
397
352
|
await putOAuth2Client(clientId, client);
|
|
398
353
|
await addAdminStaticUserMapping(clientId);
|
|
399
354
|
}
|
|
400
|
-
|
|
401
355
|
async function removeAdminScopes(name, client) {
|
|
402
356
|
const modClient = client;
|
|
403
357
|
const allAdminScopes = adminScopes.concat([await getDynamicClientRegistrationScope()]);
|
|
404
358
|
let finalScopes = [];
|
|
405
|
-
|
|
406
359
|
if (modClient.coreOAuth2ClientConfig.scopes && modClient.coreOAuth2ClientConfig.scopes.value) {
|
|
407
360
|
finalScopes = modClient.coreOAuth2ClientConfig.scopes.value.filter(scope => !allAdminScopes.includes(scope));
|
|
408
361
|
}
|
|
409
|
-
|
|
410
362
|
if (modClient.coreOAuth2ClientConfig.scopes.value.length > finalScopes.length) {
|
|
411
363
|
printMessage(`Removing admin scopes from client "${name}"...`);
|
|
412
364
|
modClient.coreOAuth2ClientConfig.scopes.value = finalScopes;
|
|
413
365
|
} else {
|
|
414
366
|
printMessage(`Client "${name}" has no admin scopes.`);
|
|
415
367
|
}
|
|
416
|
-
|
|
417
368
|
let finalDefaultScopes = [];
|
|
418
|
-
|
|
419
369
|
if (modClient.coreOAuth2ClientConfig.defaultScopes && modClient.coreOAuth2ClientConfig.defaultScopes.value) {
|
|
420
370
|
finalDefaultScopes = modClient.coreOAuth2ClientConfig.defaultScopes.value.filter(scope => !adminDefaultScopes.includes(scope));
|
|
421
371
|
}
|
|
422
|
-
|
|
423
372
|
if (modClient.coreOAuth2ClientConfig.defaultScopes.value.length > finalDefaultScopes.length) {
|
|
424
373
|
printMessage(`Removing admin default scopes from client "${name}"...`);
|
|
425
374
|
modClient.coreOAuth2ClientConfig.defaultScopes.value = finalDefaultScopes;
|
|
426
375
|
} else {
|
|
427
376
|
printMessage(`Client "${name}" has no admin default scopes.`);
|
|
428
377
|
}
|
|
429
|
-
|
|
430
378
|
return modClient;
|
|
431
379
|
}
|
|
432
|
-
|
|
433
380
|
function removeClientCredentialsGrantType(clientId, client) {
|
|
434
381
|
const modClient = client;
|
|
435
382
|
let modified = false;
|
|
436
383
|
let finalGrantTypes = [];
|
|
437
|
-
|
|
438
384
|
if (modClient.advancedOAuth2ClientConfig.grantTypes && modClient.advancedOAuth2ClientConfig.grantTypes.value) {
|
|
439
385
|
finalGrantTypes = modClient.advancedOAuth2ClientConfig.grantTypes.value.filter(grantType => grantType !== 'client_credentials');
|
|
440
386
|
modified = modClient.advancedOAuth2ClientConfig.grantTypes.value.length > finalGrantTypes.length;
|
|
441
387
|
}
|
|
442
|
-
|
|
443
388
|
if (modified) {
|
|
444
389
|
printMessage(`Removing client credentials grant type from client "${clientId}"...`);
|
|
445
390
|
modClient.advancedOAuth2ClientConfig.grantTypes.value = finalGrantTypes;
|
|
446
391
|
} else {
|
|
447
392
|
printMessage(`Client "${clientId}" does not allow client credentials grant type.`);
|
|
448
393
|
}
|
|
449
|
-
|
|
450
394
|
return modClient;
|
|
451
395
|
}
|
|
452
|
-
|
|
453
396
|
async function removeAdminStaticUserMapping(name) {
|
|
454
397
|
const authentication = await getConfigEntity('authentication');
|
|
455
398
|
let finalRoles = [];
|
|
@@ -460,25 +403,20 @@ async function removeAdminStaticUserMapping(name) {
|
|
|
460
403
|
if (mapping.subject !== name) {
|
|
461
404
|
return mapping;
|
|
462
405
|
}
|
|
463
|
-
|
|
464
406
|
finalRoles = mapping.roles.filter(role => !adminRoles.includes(role));
|
|
465
407
|
const newMapping = mapping;
|
|
466
408
|
removeMapping = finalRoles.length === 0; // if there are no more roles left on this mapping, flag it for removal
|
|
467
|
-
|
|
468
409
|
modified = mapping.roles.length > finalRoles.length; // if there were roles removed, set modified flag
|
|
469
|
-
|
|
470
410
|
newMapping.roles = finalRoles;
|
|
471
411
|
return newMapping;
|
|
472
412
|
}).filter(mapping => mapping.subject !== name || !removeMapping);
|
|
473
413
|
authentication.rsFilter.staticUserMapping = mappings;
|
|
474
|
-
|
|
475
414
|
if (modified || removeMapping) {
|
|
476
415
|
if (removeMapping) {
|
|
477
416
|
printMessage(`Removing static user mapping for client "${name}"...`);
|
|
478
417
|
} else {
|
|
479
418
|
printMessage(`Removing admin roles from static user mapping for client "${name}"...`);
|
|
480
419
|
}
|
|
481
|
-
|
|
482
420
|
try {
|
|
483
421
|
await putConfigEntity('authentication', authentication);
|
|
484
422
|
} catch (putConfigEntityError) {
|
|
@@ -489,18 +427,14 @@ async function removeAdminStaticUserMapping(name) {
|
|
|
489
427
|
printMessage(`Static user mapping for client "${name}" has no admin roles.`);
|
|
490
428
|
}
|
|
491
429
|
}
|
|
492
|
-
|
|
493
430
|
export async function revokeOAuth2ClientAdminPrivileges(clientId) {
|
|
494
431
|
let client = (await getOAuth2Client(clientId)).data;
|
|
495
|
-
|
|
496
432
|
if (client.coreOAuth2ClientConfig.clientName.value.length === 0) {
|
|
497
433
|
client.coreOAuth2ClientConfig.clientName.value = [clientId];
|
|
498
434
|
}
|
|
499
|
-
|
|
500
435
|
if (client.advancedOAuth2ClientConfig.descriptions.value.length === 0 || client.advancedOAuth2ClientConfig.descriptions.value[0].startsWith('Modified by Frodo') || client.advancedOAuth2ClientConfig.descriptions.value[0].startsWith('Created by Frodo')) {
|
|
501
436
|
client.advancedOAuth2ClientConfig.descriptions.value = [`Modified by Frodo on ${new Date().toLocaleString()}`];
|
|
502
437
|
}
|
|
503
|
-
|
|
504
438
|
client = await removeAdminScopes(clientId, client);
|
|
505
439
|
client = removeClientCredentialsGrantType(clientId, client);
|
|
506
440
|
await putOAuth2Client(clientId, client);
|
|
@@ -511,7 +445,6 @@ export async function createOAuth2ClientWithAdminPrivileges(clientId, clientSecr
|
|
|
511
445
|
client.coreOAuth2ClientConfig.userpassword = clientSecret;
|
|
512
446
|
client.coreOAuth2ClientConfig.clientName.value = [clientId];
|
|
513
447
|
client.advancedOAuth2ClientConfig.descriptions.value = [`Created by Frodo on ${new Date().toLocaleString()}`];
|
|
514
|
-
|
|
515
448
|
try {
|
|
516
449
|
client = await addAdminScopes(clientId, client);
|
|
517
450
|
await putOAuth2Client(clientId, client);
|
|
@@ -523,21 +456,20 @@ export async function createOAuth2ClientWithAdminPrivileges(clientId, clientSecr
|
|
|
523
456
|
export async function createLongLivedToken(clientId, clientSecret, scope, secret, lifetime) {
|
|
524
457
|
// get oauth2 client
|
|
525
458
|
const client = (await getOAuth2Client(clientId)).data;
|
|
526
|
-
client.userpassword = clientSecret;
|
|
527
|
-
|
|
528
|
-
const rememberedLifetime = client.coreOAuth2ClientConfig.accessTokenLifetime.value || 3600;
|
|
529
|
-
|
|
459
|
+
client.userpassword = clientSecret;
|
|
460
|
+
// remember current lifetime
|
|
461
|
+
const rememberedLifetime = client.coreOAuth2ClientConfig.accessTokenLifetime.value || 3600;
|
|
462
|
+
// set long token lifetime
|
|
530
463
|
client.coreOAuth2ClientConfig.accessTokenLifetime.value = lifetime;
|
|
531
464
|
await putOAuth2Client(clientId, client);
|
|
532
465
|
const response = (await clientCredentialsGrant(clientId, clientSecret, scope)).data;
|
|
533
466
|
const expires = new Date().getTime() + 1000 * response.expires_in;
|
|
534
|
-
response.expires_on = new Date(expires).toLocaleString();
|
|
535
|
-
|
|
467
|
+
response.expires_on = new Date(expires).toLocaleString();
|
|
468
|
+
// reset token lifetime
|
|
536
469
|
client.coreOAuth2ClientConfig.accessTokenLifetime.value = rememberedLifetime;
|
|
537
|
-
await putOAuth2Client(clientId, client);
|
|
538
|
-
|
|
470
|
+
await putOAuth2Client(clientId, client);
|
|
471
|
+
// create secret with token as value
|
|
539
472
|
const description = 'Long-lived admin token';
|
|
540
|
-
|
|
541
473
|
try {
|
|
542
474
|
await putSecret(secret, response.access_token, description);
|
|
543
475
|
response.secret = secret;
|
|
@@ -549,7 +481,6 @@ export async function createLongLivedToken(clientId, clientSecret, scope, secret
|
|
|
549
481
|
response.secret = newSecret;
|
|
550
482
|
}
|
|
551
483
|
}
|
|
552
|
-
|
|
553
484
|
delete response.access_token;
|
|
554
485
|
return response;
|
|
555
486
|
}
|
|
@@ -560,16 +491,13 @@ export async function removeStaticUserMapping(subject) {
|
|
|
560
491
|
// find the subject and flag it
|
|
561
492
|
if (mapping.subject === subject) {
|
|
562
493
|
removeMapping = true;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
494
|
+
}
|
|
495
|
+
// ignore mappings for other subjects
|
|
566
496
|
return mapping.subject !== subject;
|
|
567
497
|
});
|
|
568
498
|
authentication.rsFilter.staticUserMapping = mappings;
|
|
569
|
-
|
|
570
499
|
if (removeMapping) {
|
|
571
500
|
printMessage(`Removing static user mapping for subject "${subject}"...`);
|
|
572
|
-
|
|
573
501
|
try {
|
|
574
502
|
await putConfigEntity('authentication', authentication);
|
|
575
503
|
} catch (putConfigEntityError) {
|
|
@@ -588,12 +516,11 @@ export async function hideGenericExtensionAttributes(includeCustomized, dryRun)
|
|
|
588
516
|
if (object.name !== getRealmManagedUser()) {
|
|
589
517
|
return object;
|
|
590
518
|
}
|
|
591
|
-
|
|
592
519
|
propertyNames.forEach(name => {
|
|
593
520
|
if (isEqualJson(GENERIC_EXTENSION_ATTRIBUTES[name], object.schema.properties[name], ['viewable', 'usageDescription']) || includeCustomized) {
|
|
594
521
|
if (object.schema.properties[name].viewable) {
|
|
595
|
-
printMessage(`${name}: hide`);
|
|
596
|
-
|
|
522
|
+
printMessage(`${name}: hide`);
|
|
523
|
+
// eslint-disable-next-line no-param-reassign
|
|
597
524
|
object.schema.properties[name].viewable = false;
|
|
598
525
|
} else {
|
|
599
526
|
printMessage(`${name}: ignore (already hidden)`);
|
|
@@ -605,7 +532,6 @@ export async function hideGenericExtensionAttributes(includeCustomized, dryRun)
|
|
|
605
532
|
return object;
|
|
606
533
|
});
|
|
607
534
|
managed.objects = updatedObjects;
|
|
608
|
-
|
|
609
535
|
if (dryRun) {
|
|
610
536
|
printMessage('Dry-run only. Changes are not saved.');
|
|
611
537
|
} else {
|
|
@@ -625,12 +551,11 @@ export async function showGenericExtensionAttributes(includeCustomized, dryRun)
|
|
|
625
551
|
if (object.name !== getRealmManagedUser()) {
|
|
626
552
|
return object;
|
|
627
553
|
}
|
|
628
|
-
|
|
629
554
|
propertyNames.forEach(name => {
|
|
630
555
|
if (isEqualJson(GENERIC_EXTENSION_ATTRIBUTES[name], object.schema.properties[name], ['viewable', 'usageDescription']) || includeCustomized) {
|
|
631
556
|
if (!object.schema.properties[name].viewable) {
|
|
632
|
-
printMessage(`${name}: show`);
|
|
633
|
-
|
|
557
|
+
printMessage(`${name}: show`);
|
|
558
|
+
// eslint-disable-next-line no-param-reassign
|
|
634
559
|
object.schema.properties[name].viewable = true;
|
|
635
560
|
} else {
|
|
636
561
|
printMessage(`${name}: ignore (already showing)`);
|
|
@@ -642,7 +567,6 @@ export async function showGenericExtensionAttributes(includeCustomized, dryRun)
|
|
|
642
567
|
return object;
|
|
643
568
|
});
|
|
644
569
|
managed.objects = updatedObjects;
|
|
645
|
-
|
|
646
570
|
if (dryRun) {
|
|
647
571
|
printMessage('Dry-run only. Changes are not saved.');
|
|
648
572
|
} else {
|
|
@@ -654,7 +578,6 @@ export async function showGenericExtensionAttributes(includeCustomized, dryRun)
|
|
|
654
578
|
}
|
|
655
579
|
}
|
|
656
580
|
}
|
|
657
|
-
|
|
658
581
|
async function repairOrgModelUser(dryRun) {
|
|
659
582
|
const managed = await getConfigEntity('managed');
|
|
660
583
|
const RDVPs = ['memberOfOrgIDs'];
|
|
@@ -664,12 +587,11 @@ async function repairOrgModelUser(dryRun) {
|
|
|
664
587
|
if (object.name !== getRealmManagedUser()) {
|
|
665
588
|
return object;
|
|
666
589
|
}
|
|
667
|
-
|
|
668
590
|
printMessage(`${object.name}: checking...`);
|
|
669
591
|
RDVPs.forEach(name => {
|
|
670
592
|
if (!object.schema.properties[name].queryConfig.flattenProperties) {
|
|
671
|
-
printMessage(`- ${name}: repairing - needs flattening`, 'warn');
|
|
672
|
-
|
|
593
|
+
printMessage(`- ${name}: repairing - needs flattening`, 'warn');
|
|
594
|
+
// eslint-disable-next-line no-param-reassign
|
|
673
595
|
object.schema.properties[name].queryConfig.flattenProperties = true;
|
|
674
596
|
repairData = true;
|
|
675
597
|
} else {
|
|
@@ -679,7 +601,6 @@ async function repairOrgModelUser(dryRun) {
|
|
|
679
601
|
return object;
|
|
680
602
|
});
|
|
681
603
|
managed.objects = updatedObjects;
|
|
682
|
-
|
|
683
604
|
if (!dryRun) {
|
|
684
605
|
try {
|
|
685
606
|
await putConfigEntity('managed', managed);
|
|
@@ -688,10 +609,8 @@ async function repairOrgModelUser(dryRun) {
|
|
|
688
609
|
printMessage(`Error: ${putConfigEntityError}`, 'error');
|
|
689
610
|
}
|
|
690
611
|
}
|
|
691
|
-
|
|
692
612
|
return repairData;
|
|
693
613
|
}
|
|
694
|
-
|
|
695
614
|
async function repairOrgModelOrg(dryRun) {
|
|
696
615
|
const managed = await getConfigEntity('managed');
|
|
697
616
|
const RDVPs = ['adminIDs', 'ownerIDs', 'parentAdminIDs', 'parentOwnerIDs', 'parentIDs'];
|
|
@@ -701,12 +620,11 @@ async function repairOrgModelOrg(dryRun) {
|
|
|
701
620
|
if (object.name !== getRealmManagedOrganization()) {
|
|
702
621
|
return object;
|
|
703
622
|
}
|
|
704
|
-
|
|
705
623
|
printMessage(`${object.name}: checking...`);
|
|
706
624
|
RDVPs.forEach(name => {
|
|
707
625
|
if (!object.schema.properties[name].queryConfig.flattenProperties) {
|
|
708
|
-
printMessage(`- ${name}: repairing - needs flattening`, 'warn');
|
|
709
|
-
|
|
626
|
+
printMessage(`- ${name}: repairing - needs flattening`, 'warn');
|
|
627
|
+
// eslint-disable-next-line no-param-reassign
|
|
710
628
|
object.schema.properties[name].queryConfig.flattenProperties = true;
|
|
711
629
|
repairData = true;
|
|
712
630
|
} else {
|
|
@@ -716,7 +634,6 @@ async function repairOrgModelOrg(dryRun) {
|
|
|
716
634
|
return object;
|
|
717
635
|
});
|
|
718
636
|
managed.objects = updatedObjects;
|
|
719
|
-
|
|
720
637
|
if (!dryRun) {
|
|
721
638
|
try {
|
|
722
639
|
await putConfigEntity('managed', managed);
|
|
@@ -725,40 +642,37 @@ async function repairOrgModelOrg(dryRun) {
|
|
|
725
642
|
printMessage(`Error: ${putConfigEntityError}`, 'error');
|
|
726
643
|
}
|
|
727
644
|
}
|
|
728
|
-
|
|
729
645
|
return repairData;
|
|
730
646
|
}
|
|
731
|
-
|
|
732
647
|
async function repairOrgModelData(dryRun = false) {
|
|
733
|
-
if (!dryRun) {
|
|
648
|
+
if (!dryRun) {
|
|
649
|
+
// const rootOrgs = await findRootOrganizations();
|
|
734
650
|
}
|
|
735
651
|
}
|
|
736
|
-
|
|
737
652
|
async function extendOrgModelPermissins(dryRun = false) {
|
|
738
|
-
if (!dryRun) {
|
|
653
|
+
if (!dryRun) {
|
|
654
|
+
// const rootOrgs = await findRootOrganizations();
|
|
739
655
|
}
|
|
740
656
|
}
|
|
741
|
-
|
|
742
657
|
export async function repairOrgModel(excludeCustomized, extendPermissions, dryRun) {
|
|
743
658
|
let repairData = false;
|
|
744
659
|
repairData = repairData || (await repairOrgModelUser(dryRun));
|
|
745
660
|
repairData = repairData || (await repairOrgModelOrg(dryRun));
|
|
746
|
-
|
|
747
|
-
|
|
661
|
+
if (excludeCustomized) {
|
|
662
|
+
//
|
|
748
663
|
}
|
|
749
|
-
|
|
750
664
|
if (repairData) {
|
|
751
665
|
await repairOrgModelData(dryRun);
|
|
752
666
|
}
|
|
753
|
-
|
|
754
667
|
if (extendPermissions) {
|
|
755
668
|
await extendOrgModelPermissins(dryRun);
|
|
756
669
|
}
|
|
757
|
-
|
|
758
670
|
if (dryRun) {
|
|
759
671
|
printMessage('Dry-run only. Changes are not saved.', 'warn');
|
|
760
672
|
}
|
|
761
|
-
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// suggested by John K.
|
|
762
676
|
// export async function removeRealmNameFromManagedObjectLabels() {}
|
|
763
677
|
// export async function addRealmNameToManagedObjectLabels() {}
|
|
764
678
|
// export async function cleanUpPostmanArtifacts() {}
|