@rockcarver/frodo-cli 0.18.2-5 → 0.18.2-7
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 +9 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +4 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +4 -1
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +4 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +4 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +4 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +4 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +4 -1
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +4 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/cmd_common.js +4 -4
- package/esm/cli/cmd_common.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +4 -1
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +4 -1
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +4 -1
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +40 -0
- package/esm/cli/saml/saml-delete.js.map +1 -0
- package/esm/cli/saml/saml-describe.js +6 -5
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +36 -25
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +37 -21
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +13 -7
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +7 -6
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/saml/saml.js +1 -0
- package/esm/cli/saml/saml.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +19 -19
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +23 -23
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +26 -28
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +4 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/Saml2Ops.js +502 -2
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/Saml2Ops.test_.js.map +1 -0
- package/esm/utils/Console.js +19 -0
- package/esm/utils/Console.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-import.js","names":["Command","Option","Authenticate","Theme","state","
|
|
1
|
+
{"version":3,"file":"theme-import.js","names":["Command","Option","common","Authenticate","Theme","state","printMessage","getTokens","importFirstThemeFromFile","importThemeById","importThemeByName","importThemesFromFile","importThemesFromFiles","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","file","themeName","getRealm","themeId","all","allSeparate","help","parse"],"sources":["cli/theme/theme-import.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport * as common from '../cmd_common';\nimport { Authenticate, Theme, state } from '@rockcarver/frodo-lib';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\n\nconst {\n importFirstThemeFromFile,\n importThemeById,\n importThemeByName,\n importThemesFromFile,\n importThemesFromFiles,\n} = Theme;\n\nconst program = new Command('frodo theme import');\n\nprogram\n .description('Import themes.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-n, --theme-name <name>',\n 'Name of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-i, --theme-id <uuid>',\n 'Uuid of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the theme(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the themes from single file. Ignored with -n or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n // import by name\n if (options.file && options.themeName && (await getTokens())) {\n printMessage(\n `Importing theme with name \"${\n options.themeName\n }\" into realm \"${state.default.session.getRealm()}\"...`\n );\n importThemeByName(options.themeName, options.file);\n }\n // import by id\n else if (options.file && options.themeId && (await getTokens())) {\n printMessage(\n `Importing theme with id \"${\n options.themeId\n }\" into realm \"${state.default.session.getRealm()}\"...`\n );\n importThemeById(options.themeId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n printMessage(\n `Importing all themes from a single file (${options.file})...`\n );\n importThemesFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n printMessage(\n 'Importing all themes from separate files in current directory...'\n );\n importThemesFromFiles();\n }\n // import single theme from file\n else if (options.file && (await getTokens())) {\n printMessage(\n `Importing first theme from file \"${\n options.file\n }\" into realm \"${state.default.session.getRealm()}\"...`\n );\n importFirstThemeFromFile(options.file);\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\n program.help();\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,SAASC,YAAT,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA2C,uBAA3C;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBJ,YAAtB;AAEA,MAAM;EACJK,wBADI;EAEJC,eAFI;EAGJC,iBAHI;EAIJC,oBAJI;EAKJC;AALI,IAMFR,KANJ;AAQA,MAAMS,OAAO,GAAG,IAAIb,OAAJ,CAAY,oBAAZ,CAAhB;AAEAa,OAAO,CACJC,WADH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,CAACsB,OAAO,CAACiB,IAAT,CAApB;EACD,CALI,CAML;EANK,KAOA,IAAIjB,OAAO,CAACsB,WAAR,IAAuB,CAACtB,OAAO,CAACiB,IAAhC,KAAyC,MAAM3C,SAAS,EAAxD,CAAJ,EAAiE;IACpED,YAAY,CACV,kEADU,CAAZ;IAGAM,qBAAqB;EACtB,CALI,CAML;EANK,KAOA,IAAIqB,OAAO,CAACiB,IAAR,KAAiB,MAAM3C,SAAS,EAAhC,CAAJ,EAAyC;IAC5CD,YAAY,CACT,oCACC2B,OAAO,CAACiB,IACT,iBAAgB7C,KAAK,CAAC6B,OAAN,CAAcC,OAAd,CAAsBiB,QAAtB,EAAiC,MAHxC,CAAZ;IAKA5C,wBAAwB,CAACyB,OAAO,CAACiB,IAAT,CAAxB;EACD,CAPI,CAQL;EARK,KASA;IACH5C,YAAY,CAAC,sDAAD,CAAZ;IACAO,OAAO,CAAC2C,IAAR;EACD;AACF,CArGL,CAsGI;AAtGJ;AAyGA3C,OAAO,CAAC4C,KAAR"}
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
listThemes
|
|
10
10
|
} = Theme;
|
|
11
11
|
const program = new Command('frodo theme list');
|
|
12
|
-
program.description('List themes.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(new Option('-l, --long', 'Long with more fields.').default(false, 'false')).action( // implement command logic inside action handler
|
|
12
|
+
program.description('List themes.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-l, --long', 'Long with more fields.').default(false, 'false')).action( // implement command logic inside action handler
|
|
13
13
|
async (host, realm, user, password, options) => {
|
|
14
14
|
state.default.session.setTenant(host);
|
|
15
15
|
state.default.session.setRealm(realm);
|
|
@@ -17,6 +17,9 @@ async (host, realm, user, password, options) => {
|
|
|
17
17
|
state.default.session.setPassword(password);
|
|
18
18
|
state.default.session.setDeploymentType(options.type);
|
|
19
19
|
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
20
|
+
state.default.session.setVerbose(options.verbose);
|
|
21
|
+
state.default.session.setDebug(options.debug);
|
|
22
|
+
state.default.session.setCurlirize(options.curlirize);
|
|
20
23
|
|
|
21
24
|
if (await getTokens()) {
|
|
22
25
|
printMessage(`Listing themes in realm "${state.default.session.getRealm()}"...`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-list.js","names":["Command","Option","Authenticate","Theme","state","common","printMessage","getTokens","listThemes","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","getRealm","long","parse"],"sources":["cli/theme/theme-list.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { Authenticate, Theme, state } from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { listThemes } = Theme;\n\nconst program = new Command('frodo theme list');\n\nprogram\n .description('List themes.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n if (await getTokens()) {\n printMessage(\n `Listing themes in realm \"${state.default.session.getRealm()}\"...`\n );\n listThemes(options.long);\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SAASC,YAAT,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA2C,uBAA3C;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBL,YAAtB;AACA,MAAM;EAAEM;AAAF,IAAiBL,KAAvB;AAEA,MAAMM,OAAO,GAAG,IAAIT,OAAJ,CAAY,kBAAZ,CAAhB;AAEAS,OAAO,CACJC,WADH,CACe,cADf,EAEGC,UAFH,CAEc,YAFd,EAE4B,MAF5B,EAGGC,kBAHH,GAIGC,WAJH,CAIeR,MAAM,CAACS,aAJtB,EAKGD,WALH,CAKeR,MAAM,CAACU,aALtB,EAMGF,WANH,CAMeR,MAAM,CAACW,YANtB,EAOGH,WAPH,CAOeR,MAAM,CAACY,gBAPtB,EAQGC,SARH,CAQab,MAAM,CAACc,gBARpB,EASGD,SATH,CASab,MAAM,CAACe,cATpB,EAUGF,SAVH,
|
|
1
|
+
{"version":3,"file":"theme-list.js","names":["Command","Option","Authenticate","Theme","state","common","printMessage","getTokens","listThemes","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","getRealm","long","parse"],"sources":["cli/theme/theme-list.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { Authenticate, Theme, state } from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { listThemes } = Theme;\n\nconst program = new Command('frodo theme list');\n\nprogram\n .description('List themes.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (await getTokens()) {\n printMessage(\n `Listing themes in realm \"${state.default.session.getRealm()}\"...`\n );\n listThemes(options.long);\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SAASC,YAAT,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA2C,uBAA3C;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBL,YAAtB;AACA,MAAM;EAAEM;AAAF,IAAiBL,KAAvB;AAEA,MAAMM,OAAO,GAAG,IAAIT,OAAJ,CAAY,kBAAZ,CAAhB;AAEAS,OAAO,CACJC,WADH,CACe,cADf,EAEGC,UAFH,CAEc,YAFd,EAE4B,MAF5B,EAGGC,kBAHH,GAIGC,WAJH,CAIeR,MAAM,CAACS,aAJtB,EAKGD,WALH,CAKeR,MAAM,CAACU,aALtB,EAMGF,WANH,CAMeR,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T,4BAA2BF,KAAK,CAACoB,OAAN,CAAcO,OAAd,CAAsBe,QAAtB,EAAiC,MADnD,CAAZ;IAGAtC,UAAU,CAACsB,OAAO,CAACiB,IAAT,CAAV;EACD;AACF,CAlCL,CAmCI;AAnCJ;AAsCAtC,OAAO,CAACuC,KAAR"}
|
package/esm/ops/Saml2Ops.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Saml2, ExportImportUtils } from '@rockcarver/frodo-lib';
|
|
4
|
+
import { createObjectTable, createProgressBar, createTable, debugMessage, printMessage, showSpinner, stopProgressBar, stopSpinner, updateProgressBar } from '../utils/Console';
|
|
2
5
|
const {
|
|
3
|
-
roleMap
|
|
6
|
+
roleMap,
|
|
7
|
+
exportSaml2Provider,
|
|
8
|
+
exportSaml2Providers,
|
|
9
|
+
getSaml2ProviderStubs,
|
|
10
|
+
getProviderByLocationAndId,
|
|
11
|
+
getProviderMetadata,
|
|
12
|
+
getProviderMetadataUrl,
|
|
13
|
+
getSaml2ProviderStub,
|
|
14
|
+
getRawProviders,
|
|
15
|
+
getRawProvider,
|
|
16
|
+
importSaml2Provider,
|
|
17
|
+
importSaml2Providers,
|
|
18
|
+
putRawProvider
|
|
4
19
|
} = Saml2;
|
|
20
|
+
const {
|
|
21
|
+
getTypedFilename,
|
|
22
|
+
saveJsonToFile,
|
|
23
|
+
saveTextToFile,
|
|
24
|
+
getRealmString,
|
|
25
|
+
saveToFile,
|
|
26
|
+
validateImport
|
|
27
|
+
} = ExportImportUtils;
|
|
5
28
|
/**
|
|
6
29
|
* Get a one-line description of the saml2 provider object
|
|
7
30
|
* @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe
|
|
@@ -49,4 +72,481 @@ export function getTableRowMd(saml2ProviderObj) {
|
|
|
49
72
|
const row = `| ${saml2ProviderObj.entityId} | ${saml2ProviderObj.entityLocation} | ${roles.length ? roles.join(', ') : ''} |`;
|
|
50
73
|
return row;
|
|
51
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* List entity providers
|
|
77
|
+
* @param {boolean} long Long list format with details
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
export async function listSaml2Providers(long = false) {
|
|
81
|
+
const providerList = await getSaml2ProviderStubs();
|
|
82
|
+
providerList.sort((a, b) => a._id.localeCompare(b._id));
|
|
83
|
+
|
|
84
|
+
if (!long) {
|
|
85
|
+
for (const provider of providerList) {
|
|
86
|
+
printMessage(`${provider.entityId}`, 'data');
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
const table = createTable(['Entity Id'['brightCyan'], 'Location'['brightCyan'], 'Role(s)'['brightCyan']]);
|
|
90
|
+
|
|
91
|
+
for (const provider of providerList) {
|
|
92
|
+
table.push([provider.entityId, provider.location, provider.roles.map(role => roleMap[role]).join(', ')]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
printMessage(table.toString());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Describe an entity provider's configuration
|
|
100
|
+
* @param {String} entityId Provider entity id
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
export async function describeSaml2Provider(entityId) {
|
|
104
|
+
try {
|
|
105
|
+
const stub = await getSaml2ProviderStub(entityId);
|
|
106
|
+
printMessage(stub);
|
|
107
|
+
const {
|
|
108
|
+
location
|
|
109
|
+
} = stub;
|
|
110
|
+
const id = stub._id;
|
|
111
|
+
const roles = stub.roles.map(role => roleMap[role]).join(', ');
|
|
112
|
+
const rawProviderData = await getProviderByLocationAndId(location, id);
|
|
113
|
+
delete rawProviderData._id;
|
|
114
|
+
delete rawProviderData._rev;
|
|
115
|
+
rawProviderData.location = location;
|
|
116
|
+
rawProviderData.roles = roles;
|
|
117
|
+
rawProviderData.metadataUrl = getProviderMetadataUrl(entityId);
|
|
118
|
+
const table = createObjectTable(rawProviderData);
|
|
119
|
+
printMessage(table.toString());
|
|
120
|
+
} catch (error) {
|
|
121
|
+
printMessage(error.message, 'error');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Export provider metadata to file
|
|
126
|
+
* @param {String} entityId Provider entity id
|
|
127
|
+
* @param {String} file Optional filename
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
export async function exportSaml2MetadataToFile(entityId, file = null) {
|
|
131
|
+
let fileName = file;
|
|
132
|
+
|
|
133
|
+
if (!fileName) {
|
|
134
|
+
fileName = getTypedFilename(entityId, 'metadata', 'xml');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
createProgressBar(1, `Exporting metadata for: ${entityId}`);
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
updateProgressBar(`Writing file ${fileName}`);
|
|
141
|
+
const metaData = await getProviderMetadata(entityId);
|
|
142
|
+
saveTextToFile(metaData, fileName);
|
|
143
|
+
stopProgressBar(`Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
stopProgressBar(`${error}`);
|
|
146
|
+
printMessage(error, 'error');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Export a single entity provider to file
|
|
151
|
+
* @param {String} entityId Provider entity id
|
|
152
|
+
* @param {String} file Optional filename
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
export async function exportSaml2ProviderToFile(entityId, file = null) {
|
|
156
|
+
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`);
|
|
157
|
+
let fileName = file;
|
|
158
|
+
|
|
159
|
+
if (!fileName) {
|
|
160
|
+
fileName = getTypedFilename(entityId, 'saml');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
createProgressBar(1, `Exporting provider ${entityId}`);
|
|
165
|
+
const fileData = await exportSaml2Provider(entityId);
|
|
166
|
+
saveJsonToFile(fileData, fileName);
|
|
167
|
+
stopProgressBar(`Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`);
|
|
168
|
+
} catch (err) {
|
|
169
|
+
stopProgressBar(`${err}`);
|
|
170
|
+
printMessage(err, 'error');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${fileName}]`);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Export all entity providers to one file
|
|
177
|
+
* @param {String} file Optional filename
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
export async function exportSaml2ProvidersToFile(file = null) {
|
|
181
|
+
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);
|
|
182
|
+
let fileName = file;
|
|
183
|
+
|
|
184
|
+
if (!fileName) {
|
|
185
|
+
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'saml');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
const exportData = await exportSaml2Providers();
|
|
190
|
+
saveJsonToFile(exportData, fileName);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
var _error$response;
|
|
193
|
+
|
|
194
|
+
printMessage(error.message, 'error');
|
|
195
|
+
printMessage(`exportSaml2ProvidersToFile: ${(_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status}`, 'error');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Export all entity providers to individual files
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
export async function exportSaml2ProvidersToFiles() {
|
|
205
|
+
const stubs = await getSaml2ProviderStubs();
|
|
206
|
+
|
|
207
|
+
if (stubs.length > 0) {
|
|
208
|
+
createProgressBar(stubs.length, 'Exporting providers');
|
|
209
|
+
|
|
210
|
+
for (const stub of stubs) {
|
|
211
|
+
updateProgressBar(`Exporting provider ${stub.entityId}`);
|
|
212
|
+
const fileName = getTypedFilename(stub.entityId, 'saml');
|
|
213
|
+
const fileData = await exportSaml2Provider(stub.entityId);
|
|
214
|
+
saveJsonToFile(fileData, fileName);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
stopProgressBar(`${stubs.length} providers exported.`);
|
|
218
|
+
} else {
|
|
219
|
+
printMessage('No entity providers found.', 'info');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Import a SAML entity provider by entity id from file
|
|
224
|
+
* @param {String} entityId Provider entity id
|
|
225
|
+
* @param {String} file Import file name
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
export async function importSaml2ProviderFromFile(entityId, file) {
|
|
229
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
230
|
+
if (err) throw err;
|
|
231
|
+
const fileData = JSON.parse(data);
|
|
232
|
+
|
|
233
|
+
if (validateImport(fileData.meta)) {
|
|
234
|
+
showSpinner(`Importing ${entityId}...`);
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
await importSaml2Provider(entityId, fileData);
|
|
238
|
+
stopSpinner(`Imported ${entityId}.`);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
stopSpinner(`Error importing ${entityId}: ${error.message}`);
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
printMessage('Import validation failed...', 'error');
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Import a SAML entity provider by entity id from file
|
|
249
|
+
* @param {String} file Import file name
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
export async function importFirstSaml2ProviderFromFile(file) {
|
|
253
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
254
|
+
if (err) throw err;
|
|
255
|
+
const fileData = JSON.parse(data); // pick the first provider and run with it
|
|
256
|
+
|
|
257
|
+
const entityId = Object.keys(fileData.saml.remote)[0] || Object.keys(fileData.saml.hosted)[0];
|
|
258
|
+
|
|
259
|
+
if (validateImport(fileData.meta)) {
|
|
260
|
+
showSpinner(`Importing ${entityId}...`);
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
await importSaml2Provider(entityId, fileData);
|
|
264
|
+
stopSpinner(`Imported ${entityId}.`);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
stopSpinner(`Error importing ${entityId}: ${error.message}`);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
printMessage('Import validation failed...', 'error');
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Import all SAML entity providers from file
|
|
275
|
+
* @param {String} file Import file name
|
|
276
|
+
*/
|
|
277
|
+
|
|
278
|
+
export async function importSaml2ProvidersFromFile(file) {
|
|
279
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
280
|
+
if (err) throw err;
|
|
281
|
+
const fileData = JSON.parse(data);
|
|
282
|
+
|
|
283
|
+
if (validateImport(fileData.meta)) {
|
|
284
|
+
await importSaml2Providers(fileData);
|
|
285
|
+
} else {
|
|
286
|
+
printMessage('Import validation failed...', 'error');
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Import all SAML entity providers from all *.saml.json files in the current directory
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
export async function importSaml2ProvidersFromFiles() {
|
|
295
|
+
const names = fs.readdirSync('.');
|
|
296
|
+
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.saml.json'));
|
|
297
|
+
createProgressBar(jsonFiles.length, 'Importing providers...');
|
|
298
|
+
const totalStatus = {
|
|
299
|
+
total: 0,
|
|
300
|
+
successes: 0,
|
|
301
|
+
warnings: 0,
|
|
302
|
+
failures: 0
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
for (const file of jsonFiles) {
|
|
306
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
307
|
+
const fileData = JSON.parse(data);
|
|
308
|
+
|
|
309
|
+
if (validateImport(fileData.meta)) {
|
|
310
|
+
const myStatus = await importSaml2Providers(fileData);
|
|
311
|
+
totalStatus.total += myStatus.total;
|
|
312
|
+
totalStatus.successes += myStatus.successes;
|
|
313
|
+
totalStatus.warnings += myStatus.warnings;
|
|
314
|
+
totalStatus.failures += myStatus.failures;
|
|
315
|
+
updateProgressBar(`Imported ${myStatus.successes}/${myStatus.total} provider(s) from ${file}.`);
|
|
316
|
+
} else {
|
|
317
|
+
printMessage(`Validation of ${file} failed!`, 'error');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
stopProgressBar(`Imported ${totalStatus.successes} of ${totalStatus.total} provider(s) from ${jsonFiles.length} file(s).`);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* List entity providers
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
export async function listRawSaml2Providers() {
|
|
328
|
+
const providerList = (await getRawProviders()).result;
|
|
329
|
+
providerList.sort((a, b) => a._id.localeCompare(b._id));
|
|
330
|
+
|
|
331
|
+
for (const provider of providerList) {
|
|
332
|
+
printMessage(`${provider._id}`, 'data');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Exports a RAW SAML entity, which means the raw xml is included.
|
|
337
|
+
* @param {string} entityId Reference to the entity for export
|
|
338
|
+
* @param {string} file Optional filename for the exported file
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
export async function exportRawSaml2ProviderToFile(entityId, file = null) {
|
|
342
|
+
printMessage(`Exporting raw SAML entity provider ${entityId}`, 'info');
|
|
343
|
+
let fileName = file;
|
|
344
|
+
|
|
345
|
+
if (!file) {
|
|
346
|
+
fileName = getTypedFilename(`${entityId}`, 'raw.saml');
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
createProgressBar(1, `Exporting raw entity provider: ${entityId}`);
|
|
350
|
+
|
|
351
|
+
try {
|
|
352
|
+
const rawData = await getRawProvider(entityId);
|
|
353
|
+
updateProgressBar(`Writing file ${fileName}`);
|
|
354
|
+
saveTextToFile(JSON.stringify(rawData, null, 2), fileName);
|
|
355
|
+
stopProgressBar(`Exported raw entity provider ${entityId} to ${fileName}.`);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
var _error$response2;
|
|
358
|
+
|
|
359
|
+
stopProgressBar(`Error exporting raw entity ${entityId}: ${error.message}`);
|
|
360
|
+
printMessage((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data, 'error');
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Export all entity providers raw to one file
|
|
365
|
+
* @param {String} file Optional filename
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
export async function exportRawSaml2ProvidersToFile(file = null) {
|
|
369
|
+
let fileName = file;
|
|
370
|
+
|
|
371
|
+
if (!fileName) {
|
|
372
|
+
fileName = getTypedFilename(`all${getRealmString()}ProvidersRaw`, 'raw.saml');
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
try {
|
|
376
|
+
const samlApplicationList = (await getRawProviders()).result;
|
|
377
|
+
saveToFile('application', samlApplicationList, '_id', fileName);
|
|
378
|
+
printMessage(`All RAW saml entity providers exported to: ${fileName}`, 'info');
|
|
379
|
+
} catch (error) {
|
|
380
|
+
var _error$response3;
|
|
381
|
+
|
|
382
|
+
printMessage(error.message, 'error');
|
|
383
|
+
printMessage(`exportRawSaml2ProvidersToFile: ${(_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status}`, 'error');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Export all entity providers to individual files
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
export async function exportRawSaml2ProvidersToFiles() {
|
|
391
|
+
const samlApplicationList = (await getRawProviders()).result;
|
|
392
|
+
let hasError = false;
|
|
393
|
+
createProgressBar(samlApplicationList.length, 'Exporting RAW providers');
|
|
394
|
+
let exportedAmount = 0;
|
|
395
|
+
|
|
396
|
+
for (const item of samlApplicationList) {
|
|
397
|
+
updateProgressBar(`Exporting provider ${item.entityId}`);
|
|
398
|
+
|
|
399
|
+
try {
|
|
400
|
+
const samlApplicationData = await getRawProvider(item._id);
|
|
401
|
+
const fileName = getTypedFilename(`${item._id}${getRealmString()}ProviderRaw`, 'raw.saml');
|
|
402
|
+
saveToFile('application', [samlApplicationData], '_id', fileName);
|
|
403
|
+
exportedAmount++;
|
|
404
|
+
} catch (error) {
|
|
405
|
+
hasError = true;
|
|
406
|
+
printMessage(`Unable to export: ${item._id}`, 'error');
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
stopProgressBar(`${exportedAmount} providers exported.`);
|
|
411
|
+
|
|
412
|
+
if (!hasError) {
|
|
413
|
+
printMessage('All entities exported.', 'info');
|
|
414
|
+
} else {
|
|
415
|
+
printMessage('All other entities exported.', 'info');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Imports a raw SAML export file (containing one entity).
|
|
420
|
+
* @param {string} file The import file
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
export async function importRawSaml2ProviderFromFile( // entityId: string,
|
|
424
|
+
file) {
|
|
425
|
+
printMessage(`Importing SAML Entity ${file}...`, 'info');
|
|
426
|
+
|
|
427
|
+
if (file.indexOf('.raw.saml.json') > -1) {
|
|
428
|
+
const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
429
|
+
|
|
430
|
+
if (validateImport(samlEntityData.meta)) {
|
|
431
|
+
for (const id in samlEntityData.application) {
|
|
432
|
+
// remove the "_rev" data before PUT
|
|
433
|
+
delete samlEntityData.application[id]._rev;
|
|
434
|
+
|
|
435
|
+
try {
|
|
436
|
+
await putRawProvider(id, samlEntityData.application[id]);
|
|
437
|
+
} catch (error) {
|
|
438
|
+
printMessage(`Unable to import: ${id}`, 'error');
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
printMessage(`Imported ${id}`, 'info');
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
printMessage('Import validation failed...', 'error');
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Import first raw SAML entity provider from file
|
|
450
|
+
* @param {String} file Import file name
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
export async function importFirstRawSaml2ProviderFromFile(file) {
|
|
454
|
+
printMessage(`Importing SAML Entity ${file}...`, 'info');
|
|
455
|
+
|
|
456
|
+
if (file.indexOf('.raw.saml.json') > -1) {
|
|
457
|
+
const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
458
|
+
|
|
459
|
+
if (validateImport(samlEntityData.meta)) {
|
|
460
|
+
for (const id in samlEntityData.application) {
|
|
461
|
+
// remove the "_rev" data before PUT
|
|
462
|
+
delete samlEntityData.application[id]._rev;
|
|
463
|
+
|
|
464
|
+
try {
|
|
465
|
+
await putRawProvider(id, samlEntityData.application[id]);
|
|
466
|
+
} catch (error) {
|
|
467
|
+
printMessage(`Unable to import: ${id}`, 'error');
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
printMessage(`Imported ${id}`, 'info');
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
printMessage('Import validation failed...', 'error');
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Imports the RAW provider info from a single file.
|
|
480
|
+
* @param file Import file name
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
export async function importRawSaml2ProvidersFromFile(file) {
|
|
484
|
+
fs.readFile(file, 'utf8', async function (err, data) {
|
|
485
|
+
if (err) throw err;
|
|
486
|
+
const samlEntityData = JSON.parse(data);
|
|
487
|
+
let amountOfEntities = 0;
|
|
488
|
+
|
|
489
|
+
for (const id in samlEntityData.application) {
|
|
490
|
+
if (id.length) {
|
|
491
|
+
amountOfEntities++;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (validateImport(samlEntityData.meta)) {
|
|
496
|
+
createProgressBar(amountOfEntities, 'Importing providers...');
|
|
497
|
+
|
|
498
|
+
for (const id in samlEntityData.application) {
|
|
499
|
+
// remove the "_rev" data before PUT
|
|
500
|
+
delete samlEntityData.application[id]._rev;
|
|
501
|
+
await putRawProvider(id, samlEntityData.application[id]).then(result => {
|
|
502
|
+
if (result === null) {
|
|
503
|
+
printMessage(`Import validation failed for ${id}`, 'error');
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
updateProgressBar(`Imported ${id}...`);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
stopProgressBar(`Import done`);
|
|
510
|
+
} else {
|
|
511
|
+
printMessage('Import validation failed...', 'error');
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Whenever the SAML RAW file were exported using the exportRAW functionality this function
|
|
517
|
+
* is used to read them back in. Only files with the .samlRaw.json extension will be imported.
|
|
518
|
+
* @param {string} directory The directory from which to import the files
|
|
519
|
+
*/
|
|
520
|
+
|
|
521
|
+
export async function importRawSaml2ProvidersFromFiles(directory) {
|
|
522
|
+
const files = fs.readdirSync(directory);
|
|
523
|
+
const filesToImport = files.filter(file => file.indexOf('.samlRaw.json') > -1);
|
|
524
|
+
|
|
525
|
+
if (filesToImport.length > 0) {
|
|
526
|
+
createProgressBar(filesToImport.length, 'Importing providers...');
|
|
527
|
+
filesToImport.forEach(async file => {
|
|
528
|
+
const filePathAbsolute = path.join(directory, file);
|
|
529
|
+
filesToImport.push(file);
|
|
530
|
+
const samlEntityData = JSON.parse(fs.readFileSync(filePathAbsolute, 'utf8'));
|
|
531
|
+
|
|
532
|
+
if (validateImport(samlEntityData.meta)) {
|
|
533
|
+
for (const id in samlEntityData.application) {
|
|
534
|
+
// remove the "_rev" data before PUT
|
|
535
|
+
delete samlEntityData.application[id]._rev;
|
|
536
|
+
await putRawProvider(id, samlEntityData.application[id]).then(result => {
|
|
537
|
+
if (result === null) {
|
|
538
|
+
printMessage(`Import validation failed for ${id}`, 'error');
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
updateProgressBar(`Imported ${id}...`);
|
|
542
|
+
}
|
|
543
|
+
} else {
|
|
544
|
+
printMessage('Import validation failed...', 'error');
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
stopProgressBar(`Import done`);
|
|
548
|
+
} else {
|
|
549
|
+
printMessage('Import failed, no files to import. (check extension to be .samlRaw.json)', 'warn');
|
|
550
|
+
}
|
|
551
|
+
}
|
|
52
552
|
//# sourceMappingURL=Saml2Ops.js.map
|