Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli/FrodoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {

const { DEFAULT_REALM_KEY, DEPLOYMENT_TYPES } = frodo.utils.constants;

const hostArgument = new Argument(
export const hostArgument = new Argument(
'[host]',
'AM base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'
'AM base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring or alias.'
);

const realmArgument = new Argument(
Expand Down
2 changes: 1 addition & 1 deletion src/cli/app/app-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function setup() {
] +
` List applications using a connection profile (identified by the full AM base URL):\n` +
` $ frodo app list ${s.amBaseUrl}\n`['brightCyan'] +
` List applications using a connection profile (identified by a unique substring of the AM base URL):\n` +
` List applications using a connection profile (identified by a unique substring of the AM base URL or a saved alias):\n` +
` $ frodo app list ${s.connId}\n`['brightCyan']
)
.action(
Expand Down
34 changes: 34 additions & 0 deletions src/cli/conn/conn-alias-add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { frodo } from '@rockcarver/frodo-lib';

import { printError } from '../../utils/Console';
import { FrodoCommand, hostArgument } from '../FrodoCommand';

export default function setup() {
const program = new FrodoCommand('frodo conn alias add', [
'host',
'realm',
'username',
'password',
'type',
'insecure',
'curlirize',
]);

program
.description('Add connection profile alias.')
.argument('alias', 'Alias name for this connection profile.')
.addArgument(hostArgument)
.action(
async (alias: any, host: string, options: any, command: FrodoCommand) => {
command.handleDefaultArgsAndOpts(alias, host, options, command);
try {
frodo.conn.setConnectionProfileAlias(host, alias);

Check failure on line 25 in src/cli/conn/conn-alias-add.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'setConnectionProfileAlias' does not exist on type 'ConnectionProfile'. Did you mean 'getConnectionProfile'?
} catch (error) {
printError(error);
process.exitCode = 1;
}
}
);

return program;
}
29 changes: 29 additions & 0 deletions src/cli/conn/conn-alias-delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { frodo } from '@rockcarver/frodo-lib';

import { printError } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

export default function setup() {
const program = new FrodoCommand('frodo conn alias delete', [
'realm',
'username',
'password',
'type',
'insecure',
'curlirize',
]);

program
.description('Delete connection profile alias.')
.action(async (host: string, options: any, command: FrodoCommand) => {
command.handleDefaultArgsAndOpts(host, options, command);
try {
frodo.conn.deleteConnectionProfileAlias(host);

Check failure on line 21 in src/cli/conn/conn-alias-delete.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'deleteConnectionProfileAlias' does not exist on type 'ConnectionProfile'. Did you mean 'deleteConnectionProfile'?
} catch (error) {
printError(error);
process.exitCode = 1;
}
});

return program;
}
19 changes: 19 additions & 0 deletions src/cli/conn/conn-alias.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { FrodoStubCommand } from '../FrodoCommand';
import AddCmd from './conn-alias-add.js';
import DeleteCmd from './conn-alias-delete.js';

export default function setup() {
const program = new FrodoStubCommand('frodo conn alias');

program.description('Manage connection aliases.');

program.addCommand(
AddCmd().name('add').description('Add connection profile alias.')
);

program.addCommand(
DeleteCmd().name('delete').description('Delete connection profile alias.')
);

return program;
}
14 changes: 14 additions & 0 deletions src/cli/conn/conn-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,28 @@
'Map of headers: {"host":"am.example.com:8081"}.'
)
)
.addOption(
new Option('--alias [name]', 'Alias name for this connection profile.')
)
.addHelpText(
'after',
`Usage Examples:\n` +
` Create a connection profile with a new log API key and secret and a new service account:\n` +
` $ frodo conn save ${s.amBaseUrl} ${s.username} '${s.password}'\n`[
'brightCyan'
] +
` Create a connection profile with a new log API key and secret and a new service account and set an alias:\n` +
` $ frodo conn save --alias ${s.alias} ${s.amBaseUrl} ${s.username} '${s.password}'\n`[
'brightCyan'
] +
` Save an existing service account to an existing or new connection profile:\n` +
` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[
'brightCyan'
] +
` Save an existing service account to an existing or new connection profile and set an alias:\n` +
` $ frodo conn save --alias ${s.alias} --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[
'brightCyan'
] +
` Save an existing service account to an existing connection profile (partial host URL only updates an existing profile):\n` +
` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[
'brightCyan'
Expand Down Expand Up @@ -103,6 +114,9 @@
verboseMessage(
`Saving connection profile for tenant ${state.getHost()}...`
);
if (options.alias) {
state.setAlias(options.alias);

Check failure on line 118 in src/cli/conn/conn-save.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'setAlias' does not exist on type 'State'.
}
// if cloud deployment add service account
if (
options.validate &&
Expand Down
3 changes: 3 additions & 0 deletions src/cli/conn/conn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FrodoStubCommand } from '../FrodoCommand';
import AliasCmd from './conn-alias.js';
import DeleteCmd from './conn-delete.js';
import DescribeCmd from './conn-describe.js';
import ListCmd from './conn-list.js';
Expand All @@ -13,6 +14,8 @@ export default function setup() {

program.addCommand(SaveCmd().name('save'));

program.addCommand(AliasCmd().name('alias'));

program.addCommand(DeleteCmd().name('delete'));

program.addCommand(DescribeCmd().name('describe'));
Expand Down
4 changes: 2 additions & 2 deletions src/cli/info/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default function setup() {
] +
` Show human-readable output and login using a connection profile (identified by the full AM base URL):\n` +
` $ frodo info ${s.amBaseUrl}\n`['brightCyan'] +
` Show human-readable output and login using a connection profile (identified by a unique substring of the AM base URL):\n` +
` Show human-readable output and login using a connection profile (identified by a unique substring of the AM base URL or a saved alias):\n` +
` $ frodo info ${s.connId}\n`['brightCyan'] +
` Show JSON output and login using the AM base URL's unique substring to identify the connection profile:\n` +
` Show JSON output and login using the AM base URL's unique substring or a saved alias to identify the connection profile:\n` +
` $ frodo info --json ${s.connId}\n`['brightCyan']
)
.action(async (host, user, password, options, command) => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/server/server-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function setup() {
.addOption(
new Option(
'-u, --server-url <server-url>',
'Server url. Can be a unique substring of the full url (if not unique, it will error out). If specified, only one server is deleted and the options -a and -A are ignored.'
'Server url. Can be a unique substring of the full url (if not unique, it will error out) or a saved alias. If specified, only one server is deleted and the options -a and -A are ignored.'
)
)
.addOption(new Option('-a, --all', 'Delete all servers. Ignored with -i.'))
Expand Down
2 changes: 1 addition & 1 deletion src/cli/server/server-describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function setup() {
.addOption(
new Option(
'-u, --server-url <server-url>',
'Server url. Can be a unique substring of the full url (if not unique, it will error out).'
'Server url. Can be a unique substring of the full url (if not unique, it will error out) or a saved alias.'
)
)
.action(
Expand Down
2 changes: 1 addition & 1 deletion src/cli/server/server-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function setup() {
.addOption(
new Option(
'-u, --server-url <server-url>',
'Server url. Can be a unique substring of the full url (if not unique, it will error out). If specified, only one server is exported and the options -a and -A are ignored.'
'Server url. Can be a unique substring of the full url (if not unique, it will error out) or a saved alias. If specified, only one server is exported and the options -a and -A are ignored.'
)
)
.addOption(new Option('-f, --file <file>', 'Name of the export file.'))
Expand Down
2 changes: 1 addition & 1 deletion src/cli/server/server-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function setup() {
.addOption(
new Option(
'-u, --server-url <server-url>',
'Server url. Can be a unique substring of the full url (if not unique, it will error out). If specified, only one server is imported and the options -a and -A are ignored.'
'Server url. Can be a unique substring of the full url (if not unique, it will error out) or a saved alias. If specified, only one server is imported and the options -a and -A are ignored.'
)
)
.addOption(new Option('-f, --file <file>', 'Name of the file to import.'))
Expand Down
2 changes: 1 addition & 1 deletion src/cli/shell/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function setup() {
] +
` Launch a frodo shell using a connection profile (identified by the full AM base URL):\n` +
` $ frodo shell ${s.amBaseUrl}\n`['brightCyan'] +
` Launch a frodo shell using a connection profile (identified by a unique substring of the AM base URL):\n` +
` Launch a frodo shell using a connection profile (identified by a unique substring of the AM base URL or a saved alias):\n` +
` $ frodo shell ${s.connId}\n`['brightCyan']
)
.addOption(
Expand Down
1 change: 1 addition & 0 deletions src/help/SampleData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const amBaseUrl = 'https://openam-matrix.id.forgerock.io/am';
export const alias = 'MyConnection';
export const connId = 'matrix';
export const username = '[email protected]';
export const password = 'Blu3P!ll3d';
Expand Down
7 changes: 5 additions & 2 deletions src/ops/ConnectionProfileOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ export function listConnectionProfiles(long: boolean = false): void {
if (long) {
const table = createTable([
'Host',
'Alias',
'Service Account',
'Username',
'Log API Key',
]);
Object.keys(connectionsData).forEach((c) => {
table.push([
c,
connectionsData[c].alias,
connectionsData[c].svcacctName || connectionsData[c].svcacctId,
connectionsData[c].username,
connectionsData[c].logApiKey,
Expand All @@ -51,7 +53,7 @@ export function listConnectionProfiles(long: boolean = false): void {
// getUniqueNames(5, Object.keys(connectionsData));
}
printMessage(
'Any unique substring of a saved host can be used as the value for host parameter in all commands',
'Any unique substring or alias of a saved host can be used as the value for host parameter in all commands',
'info'
);
}
Expand All @@ -63,7 +65,7 @@ export function listConnectionProfiles(long: boolean = false): void {

/**
* Describe connection profile
* @param {string} host Host URL or unique substring
* @param {string} host Host URL, unique substring, or alias
* @param {boolean} showSecrets Whether secrets should be shown in clear text or not
*/
export async function describeConnectionProfile(
Expand Down Expand Up @@ -130,6 +132,7 @@ export async function describeConnectionProfile(
}
const keyMap = {
tenant: 'Host',
alias: 'Alias',
deploymentType: 'Deployment Type',
username: 'Username',
password: 'Password',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
username Username to login with. Must be an admin
user with appropriate rights to manage
authentication journeys/trees.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
2 changes: 1 addition & 1 deletion test/client_cli/en/__snapshots__/agent-delete.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
2 changes: 1 addition & 1 deletion test/client_cli/en/__snapshots__/agent-export.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Arguments:
host AM base URL, e.g.:
https://cdk.iam.example.com/am. To use a
connection profile, just specify a
unique substring.
unique substring or alias.
realm Realm. Specify realm as '/' for the root
realm or 'realm' or '/parent/child'
otherwise. (default: "alpha" for
Expand Down
Loading
Loading