Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"test/**/*.test_.ts",
"tsup.config.ts"
]
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ out

test/fs_tmp/*
!test/fs_tmp/.gitkeep

temp
.vscode/settings.json
18 changes: 13 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "attach",
"name": "Attach Debugger",
"port": 2000,
"restart": true
"request": "launch",
"name": "Debug",
"runtimeExecutable": "C:\\Users\\Devin\\AppData\\Local\\fnm_multishells\\1916_1742404469042\\node.exe",
"args": ["dist/app.cjs", "config-manager", "export", "scripts", "webinar"],
"outFiles": [
"${workspaceFolder}/dist/*.cjs",
],
"sourceMaps": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/dist/*",
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal"
}
]
}
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"replaceall": "^0.1.6",
"resolve": "^1.22.1",
"rimraf": "^6.0.1",
"sanitize-filename": "^1.6.3",
"slugify": "^1.6.5",
"ts-jest": "^29.1.4",
"tsup": "^8.1.0",
Expand Down
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import app from './cli/app/app';
import authn from './cli/authn/authn';
import authz from './cli/authz/authz';
import config from './cli/config/config';
import configManager from './cli/config-manager/config-manager';
import conn from './cli/conn/conn';
import email from './cli/email/email';
import esv from './cli/esv/esv';
Expand Down Expand Up @@ -64,6 +65,7 @@ const { initTokenCache } = frodo.cache;
program.addCommand(authz());
program.addCommand(app());
program.addCommand(config());
program.addCommand(configManager());
program.addCommand(conn());
program.addCommand(email());
program.addCommand(esv());
Expand Down
44 changes: 44 additions & 0 deletions src/cli/config-manager/config-manager-export-access-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { configManagerExportAccessConfig } from '../../configManagerOps/FrConfigAccessConfigOps';
import { getTokens } from '../../ops/AuthenticateOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

const deploymentTypes = ['cloud', 'forgeops'];

export default function setup() {
const program = new FrodoCommand(
'frodo config-manager export access-config',
[],
deploymentTypes
);

program
.description('Export access-config objects.')
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);

if (await getTokens(false, true, deploymentTypes)) {
verboseMessage('Exporting config entity access-config');
const outcome = await configManagerExportAccessConfig(options.envFile);
if (!outcome) process.exitCode = 1;
}
// unrecognized combination of options or no options
else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
46 changes: 46 additions & 0 deletions src/cli/config-manager/config-manager-export-all-static.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { configManagerExportAllStatic } from '../../configManagerOps/FrConfigAllOps';
import { getTokens } from '../../ops/AuthenticateOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

const deploymentTypes = ['cloud', 'forgeops'];

export default function setup() {
const program = new FrodoCommand(
'frodo config-manager export all',
[],
deploymentTypes
);
// TO DO: adding a realm option to export all-static for specific realm
program
.description('Export audit objects.')
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);

if (await getTokens(false, true, deploymentTypes)) {
verboseMessage(
'Exporting config files that fr-config-manager supports.'
);
const outcome = await configManagerExportAllStatic();
if (!outcome) process.exitCode = 1;
}
// unrecognized combination of options or no options
else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
72 changes: 72 additions & 0 deletions src/cli/config-manager/config-manager-export-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Option } from 'commander';

import { configManagerExportAllWithConfigFolder } from '../../configManagerOps/FrConfigAllOps';
import { getTokens } from '../../ops/AuthenticateOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

const deploymentTypes = ['cloud', 'forgeops'];

export default function setup() {
const program = new FrodoCommand(
'frodo config-manager export all',
[],
deploymentTypes
);
// TO DO: Adding a realm option to export all config for a specific realm
program
.description('Export audit objects.')
.addOption(
new Option(
'-F, --config-folder <config-folder-path>',
'Path to the folder containing the config files.\n'
)
)
.addHelpText(
'after',
'The following entities require config files to be exported:\n' +
'- authz-policies\n' +
'- oauth2-agents\n' +
'- saml\n' +
'- service-objects\n\n' +
'Each config file must be named after the command it applies to. For example,\n' +
'the config file for "authz-policies" should be named "authz-policies.json".\n' +
'Please refer to the help message of each command to see an example config file by running:\n' +
'"frodo config-manager export <entity-name> -h"'
)
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);

if (
options.configFolder &&
(await getTokens(false, true, deploymentTypes))
) {
verboseMessage(
'Exporting config files that fr-config-manager supports.'
);
const outcome = await configManagerExportAllWithConfigFolder({
configFolder: options.configFolder,
});
if (!outcome) process.exitCode = 1;
}
// unrecognized combination of options or no options
else {
printMessage(
'You must specify a folder containing the config files.\n' +
'Please refer to the help message for more information.',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
44 changes: 44 additions & 0 deletions src/cli/config-manager/config-manager-export-audit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { configManagerExportAudit } from '../../configManagerOps/FrConfigAuditOps';
import { getTokens } from '../../ops/AuthenticateOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

const deploymentTypes = ['cloud', 'forgeops'];

export default function setup() {
const program = new FrodoCommand(
'frodo config-manager export audit',
[],
deploymentTypes
);

program
.description('Export audit objects.')
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);

if (await getTokens(false, true, deploymentTypes)) {
verboseMessage('Exporting config entity audit');
const outcome = await configManagerExportAudit(options.envFile);
if (!outcome) process.exitCode = 1;
}
// unrecognized combination of options or no options
else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
54 changes: 54 additions & 0 deletions src/cli/config-manager/config-manager-export-authentication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Option } from 'commander';

import { configManagerExportAuthentication } from '../../configManagerOps/FrConfigAuthenticationOps';
import { getTokens } from '../../ops/AuthenticateOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

const deploymentTypes = ['cloud', 'forgeops'];

export default function setup() {
const program = new FrodoCommand(
'frodo config-manager export authentication',
[],
deploymentTypes
);

program
.description('Export authentication objects.')
.addOption(
new Option(
'-r, --realm <realm>',
'Specifies the realm to export from. Only the entity object from this realm will be exported.'
)
)
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (options.realm) {
realm = options.realm;
}
if (await getTokens(false, true, deploymentTypes)) {
verboseMessage('Exporting config entity authentication');
const outcome = await configManagerExportAuthentication(realm);
if (!outcome) process.exitCode = 1;
}
// unrecognized combination of options or no options
else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
Loading