opal-security 3.2.3 → 4.0.2
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/README.md +46 -61
- package/bin/dev +5 -5
- package/bin/run +2 -4
- package/build/commands/aws/identity.js +16 -0
- package/build/commands/clear-auth-config.d.ts +6 -0
- package/build/commands/clear-auth-config.js +22 -0
- package/{lib → build}/commands/groups/get.js +14 -16
- package/{lib → build}/commands/iam-roles/start.js +28 -30
- package/build/commands/kube-roles/start.js +71 -0
- package/{lib → build}/commands/login.d.ts +1 -0
- package/build/commands/login.js +379 -0
- package/build/commands/logout.js +22 -0
- package/{lib → build}/commands/postgres-instances/start.js +25 -27
- package/{lib → build}/commands/request/create.js +34 -36
- package/{lib → build}/commands/request/get.js +22 -24
- package/{lib → build}/commands/request/list.js +17 -19
- package/{lib → build}/commands/resources/get.js +15 -18
- package/build/commands/set-auth-config.d.ts +11 -0
- package/build/commands/set-auth-config.js +59 -0
- package/build/commands/set-custom-header.js +35 -0
- package/{lib → build}/commands/set-token.js +15 -17
- package/{lib → build}/commands/set-url.js +26 -28
- package/{lib → build}/commands/ssh/copyFrom.js +22 -24
- package/{lib → build}/commands/ssh/copyTo.js +22 -24
- package/{lib → build}/commands/ssh/start.js +30 -33
- package/build/commands/whoami.js +27 -0
- package/{lib → build}/graphql/fragment-masking.d.ts +1 -1
- package/{lib → build}/graphql/fragment-masking.js +3 -8
- package/{lib → build}/graphql/gql.d.ts +1 -1
- package/{lib → build}/graphql/gql.js +2 -5
- package/{lib → build}/graphql/graphql.js +256 -261
- package/build/graphql/index.d.ts +2 -0
- package/build/graphql/index.js +2 -0
- package/{lib → build}/handler.d.ts +1 -1
- package/build/handler.js +36 -0
- package/build/index.js +1 -0
- package/{lib → build}/labels.d.ts +1 -1
- package/build/labels.js +37 -0
- package/{lib → build}/lib/apollo.d.ts +2 -2
- package/{lib → build}/lib/apollo.js +62 -69
- package/build/lib/auth-success-template.d.ts +3 -0
- package/build/lib/auth-success-template.js +149 -0
- package/{lib → build}/lib/aws.js +2 -7
- package/{lib → build}/lib/cmd.d.ts +4 -4
- package/{lib → build}/lib/cmd.js +16 -20
- package/build/lib/config.js +46 -0
- package/{lib → build}/lib/credentials/index.d.ts +3 -2
- package/build/lib/credentials/index.js +85 -0
- package/{lib → build}/lib/credentials/keychain.js +4 -10
- package/{lib → build}/lib/credentials/localEncryption.js +12 -17
- package/{lib → build}/lib/flags.js +7 -10
- package/build/lib/local-auth-server.d.ts +5 -0
- package/build/lib/local-auth-server.js +69 -0
- package/build/lib/request/api/index.d.ts +6 -0
- package/build/lib/request/api/index.js +8 -0
- package/{lib → build}/lib/request/api/mutations/create-request.d.ts +2 -2
- package/{lib → build}/lib/request/api/mutations/create-request.js +3 -6
- package/{lib → build}/lib/request/api/queries/apps.d.ts +1 -1
- package/{lib → build}/lib/request/api/queries/apps.js +3 -6
- package/{lib → build}/lib/request/api/queries/assets.d.ts +2 -2
- package/{lib → build}/lib/request/api/queries/assets.js +7 -11
- package/{lib → build}/lib/request/api/queries/request-defaults.d.ts +2 -2
- package/{lib → build}/lib/request/api/queries/request-defaults.js +3 -6
- package/{lib → build}/lib/request/api/queries/requests.d.ts +3 -3
- package/{lib → build}/lib/request/api/queries/requests.js +10 -16
- package/{lib → build}/lib/request/api/queries/roles.d.ts +1 -1
- package/{lib → build}/lib/request/api/queries/roles.js +14 -18
- package/{lib → build}/lib/request/displays.d.ts +2 -2
- package/{lib → build}/lib/request/displays.js +27 -37
- package/{lib → build}/lib/request/prompts/apps-prompt.d.ts +1 -1
- package/build/lib/request/prompts/apps-prompt.js +33 -0
- package/{lib → build}/lib/request/prompts/asset-prompt.d.ts +1 -1
- package/build/lib/request/prompts/asset-prompt.js +61 -0
- package/{lib → build}/lib/request/prompts/duration-prompt.d.ts +1 -1
- package/{lib → build}/lib/request/prompts/duration-prompt.js +6 -10
- package/build/lib/request/prompts/index.d.ts +7 -0
- package/build/lib/request/prompts/index.js +8 -0
- package/{lib → build}/lib/request/prompts/reason-prompt.d.ts +1 -1
- package/{lib → build}/lib/request/prompts/reason-prompt.js +3 -6
- package/{lib → build}/lib/request/prompts/role-prompt.d.ts +1 -1
- package/build/lib/request/prompts/role-prompt.js +33 -0
- package/{lib → build}/lib/request/prompts/validate-prompt.d.ts +1 -1
- package/{lib → build}/lib/request/prompts/validate-prompt.js +9 -13
- package/{lib → build}/lib/request/request-utils.d.ts +2 -2
- package/{lib → build}/lib/request/request-utils.js +50 -62
- package/{lib → build}/lib/request/types.d.ts +1 -1
- package/build/lib/request/types.js +12 -0
- package/{lib → build}/lib/resources.d.ts +1 -1
- package/{lib → build}/lib/resources.js +18 -23
- package/{lib → build}/lib/sessions.d.ts +1 -1
- package/{lib → build}/lib/sessions.js +57 -32
- package/{lib → build}/lib/ssh.d.ts +1 -1
- package/{lib → build}/lib/ssh.js +6 -11
- package/{lib → build}/lib/util.js +7 -14
- package/{lib → build}/types.js +98 -101
- package/oclif.manifest.json +77 -98
- package/package.json +24 -14
- package/lib/commands/aws/identity.js +0 -18
- package/lib/commands/clear-auth-provider.d.ts +0 -9
- package/lib/commands/clear-auth-provider.js +0 -28
- package/lib/commands/curl-example.d.ts +0 -8
- package/lib/commands/curl-example.js +0 -34
- package/lib/commands/kube-roles/start.js +0 -73
- package/lib/commands/login.js +0 -286
- package/lib/commands/logout.js +0 -23
- package/lib/commands/set-auth-provider.d.ts +0 -11
- package/lib/commands/set-auth-provider.js +0 -44
- package/lib/commands/set-custom-header.js +0 -37
- package/lib/commands/whoami.js +0 -34
- package/lib/graphql/index.d.ts +0 -2
- package/lib/graphql/index.js +0 -5
- package/lib/handler.js +0 -41
- package/lib/index.js +0 -5
- package/lib/labels.js +0 -40
- package/lib/lib/config.js +0 -54
- package/lib/lib/credentials/index.js +0 -67
- package/lib/lib/request/api/index.d.ts +0 -6
- package/lib/lib/request/api/index.js +0 -20
- package/lib/lib/request/prompts/apps-prompt.js +0 -35
- package/lib/lib/request/prompts/asset-prompt.js +0 -81
- package/lib/lib/request/prompts/index.d.ts +0 -8
- package/lib/lib/request/prompts/index.js +0 -20
- package/lib/lib/request/prompts/role-prompt.js +0 -44
- package/lib/lib/request/types.js +0 -15
- /package/{lib → build}/commands/aws/identity.d.ts +0 -0
- /package/{lib → build}/commands/groups/get.d.ts +0 -0
- /package/{lib → build}/commands/iam-roles/start.d.ts +0 -0
- /package/{lib → build}/commands/kube-roles/start.d.ts +0 -0
- /package/{lib → build}/commands/logout.d.ts +0 -0
- /package/{lib → build}/commands/postgres-instances/start.d.ts +0 -0
- /package/{lib → build}/commands/request/create.d.ts +0 -0
- /package/{lib → build}/commands/request/get.d.ts +0 -0
- /package/{lib → build}/commands/request/list.d.ts +0 -0
- /package/{lib → build}/commands/resources/get.d.ts +0 -0
- /package/{lib → build}/commands/set-custom-header.d.ts +0 -0
- /package/{lib → build}/commands/set-token.d.ts +0 -0
- /package/{lib → build}/commands/set-url.d.ts +0 -0
- /package/{lib → build}/commands/ssh/copyFrom.d.ts +0 -0
- /package/{lib → build}/commands/ssh/copyTo.d.ts +0 -0
- /package/{lib → build}/commands/ssh/start.d.ts +0 -0
- /package/{lib → build}/commands/whoami.d.ts +0 -0
- /package/{lib → build}/graphql/graphql.d.ts +0 -0
- /package/{lib → build}/index.d.ts +0 -0
- /package/{lib → build}/lib/aws.d.ts +0 -0
- /package/{lib → build}/lib/config.d.ts +0 -0
- /package/{lib → build}/lib/credentials/keychain.d.ts +0 -0
- /package/{lib → build}/lib/credentials/localEncryption.d.ts +0 -0
- /package/{lib → build}/lib/flags.d.ts +0 -0
- /package/{lib → build}/lib/util.d.ts +0 -0
- /package/{lib → build}/types.d.ts +0 -0
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const displays_1 = require("../../lib/request/displays");
|
|
11
|
-
class GetRequest extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { getClient, printResponse } from "../../lib/apollo.js";
|
|
4
|
+
import { setMostRecentCommand } from "../../lib/cmd.js";
|
|
5
|
+
import { getOrCreateConfigData, urlKey } from "../../lib/config.js";
|
|
6
|
+
import { SHARED_FLAGS } from "../../lib/flags.js";
|
|
7
|
+
import { queryRequest } from "../../lib/request/api/index.js";
|
|
8
|
+
import { displayRequestAgain, displayRequestDetails, } from "../../lib/request/displays.js";
|
|
9
|
+
class GetRequest extends Command {
|
|
12
10
|
async run() {
|
|
13
11
|
var _a;
|
|
14
|
-
|
|
15
|
-
const configData =
|
|
16
|
-
const client = await
|
|
12
|
+
setMostRecentCommand(this);
|
|
13
|
+
const configData = getOrCreateConfigData(this.config.configDir);
|
|
14
|
+
const client = await getClient(this, true);
|
|
17
15
|
// Verify id tag was provided
|
|
18
16
|
const { flags } = await this.parse(GetRequest);
|
|
19
17
|
if (!flags.id) {
|
|
@@ -21,18 +19,18 @@ class GetRequest extends core_1.Command {
|
|
|
21
19
|
this.log("ex. opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4");
|
|
22
20
|
return;
|
|
23
21
|
}
|
|
24
|
-
const resp = await
|
|
22
|
+
const resp = await queryRequest(client, flags.id);
|
|
25
23
|
switch ((_a = resp.data) === null || _a === void 0 ? void 0 : _a.request.__typename) {
|
|
26
24
|
case "RequestResult": {
|
|
27
25
|
if (flags.verbose) {
|
|
28
|
-
|
|
26
|
+
printResponse(this, resp);
|
|
29
27
|
}
|
|
30
28
|
else {
|
|
31
|
-
|
|
29
|
+
displayRequestDetails(this, resp);
|
|
32
30
|
}
|
|
33
|
-
const url = `${configData[
|
|
34
|
-
this.log(`\n💡Link to request details: ${
|
|
35
|
-
|
|
31
|
+
const url = `${configData[urlKey]}/requests/sent/${flags.id}`;
|
|
32
|
+
this.log(`\n💡Link to request details: ${chalk.underline(url)}`);
|
|
33
|
+
displayRequestAgain(this, flags.id);
|
|
36
34
|
return;
|
|
37
35
|
}
|
|
38
36
|
case "RequestNotFoundError":
|
|
@@ -45,9 +43,9 @@ class GetRequest extends core_1.Command {
|
|
|
45
43
|
}
|
|
46
44
|
GetRequest.description = "Fetch details of an access request by request ID";
|
|
47
45
|
GetRequest.flags = {
|
|
48
|
-
help:
|
|
49
|
-
id:
|
|
50
|
-
verbose:
|
|
46
|
+
help: SHARED_FLAGS.help,
|
|
47
|
+
id: SHARED_FLAGS.id,
|
|
48
|
+
verbose: Flags.boolean({
|
|
51
49
|
char: "v",
|
|
52
50
|
description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
|
|
53
51
|
default: false,
|
|
@@ -57,4 +55,4 @@ GetRequest.examples = [
|
|
|
57
55
|
"opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4",
|
|
58
56
|
"opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose",
|
|
59
57
|
];
|
|
60
|
-
|
|
58
|
+
export default GetRequest;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const displays_1 = require("../../lib/request/displays");
|
|
9
|
-
class ListRequests extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { getClient, printResponse } from "../../lib/apollo.js";
|
|
3
|
+
import { setMostRecentCommand } from "../../lib/cmd.js";
|
|
4
|
+
import { SHARED_FLAGS } from "../../lib/flags.js";
|
|
5
|
+
import { queryRequests } from "../../lib/request/api/index.js";
|
|
6
|
+
import { displayRequestListTable } from "../../lib/request/displays.js";
|
|
7
|
+
class ListRequests extends Command {
|
|
10
8
|
async run() {
|
|
11
|
-
|
|
12
|
-
const client = await
|
|
9
|
+
setMostRecentCommand(this);
|
|
10
|
+
const client = await getClient(this, true);
|
|
13
11
|
let pageSize = 10;
|
|
14
12
|
let showPendingOnly = false;
|
|
15
13
|
const { flags } = await this.parse(ListRequests);
|
|
@@ -19,13 +17,13 @@ class ListRequests extends core_1.Command {
|
|
|
19
17
|
if (flags.showPendingOnly) {
|
|
20
18
|
showPendingOnly = flags.showPendingOnly;
|
|
21
19
|
}
|
|
22
|
-
const resp = await
|
|
20
|
+
const resp = await queryRequests(client, pageSize, showPendingOnly);
|
|
23
21
|
//TODO: Make this pretty
|
|
24
22
|
if (flags.verbose) {
|
|
25
|
-
|
|
23
|
+
printResponse(this, resp);
|
|
26
24
|
}
|
|
27
25
|
else {
|
|
28
|
-
|
|
26
|
+
displayRequestListTable(this, resp);
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
}
|
|
@@ -38,8 +36,8 @@ ListRequests.examples = [
|
|
|
38
36
|
];
|
|
39
37
|
ListRequests.aliases = ["request:ls"];
|
|
40
38
|
ListRequests.flags = {
|
|
41
|
-
help:
|
|
42
|
-
n:
|
|
39
|
+
help: SHARED_FLAGS.help,
|
|
40
|
+
n: Flags.integer({
|
|
43
41
|
char: "n",
|
|
44
42
|
multiple: false,
|
|
45
43
|
description: "Defines number of requests to be returned. 1 <= n <= 100.",
|
|
@@ -47,15 +45,15 @@ ListRequests.flags = {
|
|
|
47
45
|
min: 1,
|
|
48
46
|
max: 100,
|
|
49
47
|
}),
|
|
50
|
-
pending:
|
|
48
|
+
pending: Flags.boolean({
|
|
51
49
|
char: "p",
|
|
52
50
|
description: "Show only pending requests. Defaults to false.",
|
|
53
51
|
default: false,
|
|
54
52
|
}),
|
|
55
|
-
verbose:
|
|
53
|
+
verbose: Flags.boolean({
|
|
56
54
|
char: "v",
|
|
57
55
|
description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
|
|
58
56
|
default: false,
|
|
59
57
|
}),
|
|
60
58
|
};
|
|
61
|
-
|
|
59
|
+
export default ListRequests;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const cmd_1 = require("../../lib/cmd");
|
|
8
|
-
const flags_1 = require("../../lib/flags");
|
|
9
|
-
exports.GetResourceDocument = `
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { runQueryDeprecated } from "../../handler.js";
|
|
3
|
+
import { handleError, printResponse } from "../../lib/apollo.js";
|
|
4
|
+
import { setMostRecentCommand } from "../../lib/cmd.js";
|
|
5
|
+
import { SHARED_FLAGS } from "../../lib/flags.js";
|
|
6
|
+
export const GetResourceDocument = `
|
|
10
7
|
query GetResource($id: ResourceId!) {
|
|
11
8
|
resource(input: {id: $id}) {
|
|
12
9
|
__typename
|
|
@@ -40,24 +37,24 @@ query GetResource($id: ResourceId!) {
|
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
}`;
|
|
43
|
-
class GetResource extends
|
|
40
|
+
class GetResource extends Command {
|
|
44
41
|
async run() {
|
|
45
|
-
|
|
42
|
+
setMostRecentCommand(this);
|
|
46
43
|
const { flags } = await this.parse(GetResource);
|
|
47
44
|
if (!flags.id) {
|
|
48
45
|
this.log("Error: Please provide a resource ID using the --id flag.");
|
|
49
46
|
this.log("ex. opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4");
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
|
-
const { resp, error } = await
|
|
49
|
+
const { resp, error } = await runQueryDeprecated({
|
|
53
50
|
command: this,
|
|
54
|
-
query:
|
|
51
|
+
query: GetResourceDocument,
|
|
55
52
|
variables: flags,
|
|
56
53
|
});
|
|
57
54
|
if (error) {
|
|
58
|
-
return
|
|
55
|
+
return handleError(this, error, resp);
|
|
59
56
|
}
|
|
60
|
-
|
|
57
|
+
printResponse(this, resp);
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
GetResource.description = "Get resource info for a particular resource.";
|
|
@@ -65,7 +62,7 @@ GetResource.examples = [
|
|
|
65
62
|
"opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4",
|
|
66
63
|
];
|
|
67
64
|
GetResource.flags = {
|
|
68
|
-
help:
|
|
69
|
-
id:
|
|
65
|
+
help: SHARED_FLAGS.help,
|
|
66
|
+
id: SHARED_FLAGS.id,
|
|
70
67
|
};
|
|
71
|
-
|
|
68
|
+
export default GetResource;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class SetConfig extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
organizationID: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
clientID: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
issuerUrl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import validator from "validator";
|
|
3
|
+
import { getOrCreateConfigData, writeConfigData } from "../lib/config.js";
|
|
4
|
+
import { getOpalCredentials, setOpalCredentials } from "../lib/credentials/index.js";
|
|
5
|
+
class SetConfig extends Command {
|
|
6
|
+
async run() {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
try {
|
|
9
|
+
const { flags } = await this.parse(SetConfig);
|
|
10
|
+
const configData = getOrCreateConfigData(this.config.configDir);
|
|
11
|
+
if (!flags.organizationID && !flags.clientID && !flags.issuerUrl) {
|
|
12
|
+
this.error("Please provide at least one configuration flag: --organizationID, --clientID, or --issuerUrl");
|
|
13
|
+
}
|
|
14
|
+
if (flags.organizationID && !validator.isUUID(flags.organizationID)) {
|
|
15
|
+
throw new Error("Invalid organizationID");
|
|
16
|
+
}
|
|
17
|
+
if (flags.clientID && flags.clientID.trim().length === 0) {
|
|
18
|
+
throw new Error("Invalid clientID");
|
|
19
|
+
}
|
|
20
|
+
if (flags.issuerUrl) {
|
|
21
|
+
if (flags.issuerUrl.trim().length === 0) {
|
|
22
|
+
throw new Error("Invalid issuerURL");
|
|
23
|
+
}
|
|
24
|
+
configData.issuerURL = flags.issuerUrl;
|
|
25
|
+
writeConfigData(this.config.configDir, configData);
|
|
26
|
+
}
|
|
27
|
+
const existingCreds = await getOpalCredentials(this, false);
|
|
28
|
+
await setOpalCredentials(this, existingCreds === null || existingCreds === void 0 ? void 0 : existingCreds.email, (_a = flags.organizationID) !== null && _a !== void 0 ? _a : existingCreds.organizationID, (_b = flags.clientID) !== null && _b !== void 0 ? _b : existingCreds.clientID, (_c = existingCreds.secret) !== null && _c !== void 0 ? _c : "", existingCreds.secretType);
|
|
29
|
+
this.log("Authentication config updated");
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
this.error(String(error));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
SetConfig.description = "Set authentication configuration values";
|
|
37
|
+
SetConfig.examples = [
|
|
38
|
+
"$ opal set-auth-config --clientID=abc123",
|
|
39
|
+
"$ opal set-auth-config --organizationID=org-456",
|
|
40
|
+
"$ opal set-auth-config --issuerUrl=https://auth.example.com",
|
|
41
|
+
"$ opal set-auth-config --clientID=abc123 --issuerUrl=https://auth.example.com",
|
|
42
|
+
"$ opal set-auth-config --organizationID=org-456 --clientID=abc123 --issuerUrl=https://auth.example.com",
|
|
43
|
+
];
|
|
44
|
+
SetConfig.flags = {
|
|
45
|
+
organizationID: Flags.string({
|
|
46
|
+
description: "Organization ID for authentication",
|
|
47
|
+
required: false,
|
|
48
|
+
}),
|
|
49
|
+
clientID: Flags.string({
|
|
50
|
+
description: "OIDC client ID for authentication",
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
issuerUrl: Flags.string({
|
|
54
|
+
description: "OIDC issuer URL for authentication",
|
|
55
|
+
aliases: ["issuerURL"],
|
|
56
|
+
required: false,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
export default SetConfig;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { handleError, initClient } from "../lib/apollo.js";
|
|
3
|
+
import { customHttpHeaderKey, getOrCreateConfigData, writeConfigData, } from "../lib/config.js";
|
|
4
|
+
import { SHARED_FLAGS } from "../lib/flags.js";
|
|
5
|
+
class SetCustomHeader extends Command {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
const { flags } = await this.parse(SetCustomHeader);
|
|
9
|
+
let header;
|
|
10
|
+
if (flags.header) {
|
|
11
|
+
header = flags.header;
|
|
12
|
+
}
|
|
13
|
+
const configData = getOrCreateConfigData(this.config.configDir);
|
|
14
|
+
configData[customHttpHeaderKey] = header;
|
|
15
|
+
writeConfigData(this.config.configDir, configData);
|
|
16
|
+
await initClient(this);
|
|
17
|
+
this.log("Custom HTTP header updated");
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return handleError(this, error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
SetCustomHeader.description = "Sets a custom HTTP header to connect to the Opal server.";
|
|
25
|
+
SetCustomHeader.examples = [
|
|
26
|
+
"$ opal set-custom-header --header 'cf-access-token: $TOKEN'",
|
|
27
|
+
];
|
|
28
|
+
SetCustomHeader.flags = {
|
|
29
|
+
help: SHARED_FLAGS.help,
|
|
30
|
+
header: Flags.string({
|
|
31
|
+
multiple: false,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
SetCustomHeader.args = {};
|
|
35
|
+
export default SetCustomHeader;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const flags_1 = require("../lib/flags");
|
|
9
|
-
const CHECK_AUTH_SESSION_QUERY = (0, graphql_1.graphql)(`
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
import { graphql } from "../graphql/index.js";
|
|
4
|
+
import { getClient, handleError, initClient } from "../lib/apollo.js";
|
|
5
|
+
import { SecretType, getOpalCredentials, setOpalCredentials, } from "../lib/credentials/index.js";
|
|
6
|
+
import { SHARED_FLAGS } from "../lib/flags.js";
|
|
7
|
+
const CHECK_AUTH_SESSION_QUERY = graphql(`
|
|
10
8
|
query CheckAuthSessionQuery {
|
|
11
9
|
organizationSettings {
|
|
12
10
|
... on OrganizationSettingsResult {
|
|
@@ -17,11 +15,11 @@ query CheckAuthSessionQuery {
|
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
17
|
`);
|
|
20
|
-
class SetToken extends
|
|
18
|
+
class SetToken extends Command {
|
|
21
19
|
async run() {
|
|
22
20
|
var _a, _b;
|
|
23
21
|
try {
|
|
24
|
-
await
|
|
22
|
+
await initClient(this, false);
|
|
25
23
|
const { apiToken } = await inquirer.prompt([
|
|
26
24
|
{
|
|
27
25
|
name: "apiToken",
|
|
@@ -31,10 +29,10 @@ class SetToken extends core_1.Command {
|
|
|
31
29
|
},
|
|
32
30
|
]);
|
|
33
31
|
// Overwrite previously-stored credentials from keychain if they exist
|
|
34
|
-
const existingCreds = await
|
|
35
|
-
await
|
|
32
|
+
const existingCreds = await getOpalCredentials(this, false);
|
|
33
|
+
await setOpalCredentials(this, existingCreds === null || existingCreds === void 0 ? void 0 : existingCreds.email, existingCreds === null || existingCreds === void 0 ? void 0 : existingCreds.organizationID, existingCreds === null || existingCreds === void 0 ? void 0 : existingCreds.clientID, apiToken || "", SecretType.ApiToken);
|
|
36
34
|
// "Representative" authenticated call to check the log-in worked as expected.
|
|
37
|
-
const client = await
|
|
35
|
+
const client = await getClient(this, true);
|
|
38
36
|
const resp = await client.query({
|
|
39
37
|
query: CHECK_AUTH_SESSION_QUERY,
|
|
40
38
|
});
|
|
@@ -46,14 +44,14 @@ class SetToken extends core_1.Command {
|
|
|
46
44
|
this.log("🎉 You have successfully authenticated with Opal! You can now run authenticated commands.\n");
|
|
47
45
|
}
|
|
48
46
|
catch (error) {
|
|
49
|
-
this
|
|
47
|
+
handleError(this, error);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
SetToken.description = "Sets an API token to authenticate with the Opal server - alternative auth flow for headless environments.";
|
|
54
52
|
SetToken.examples = ["$ opal set-token"];
|
|
55
53
|
SetToken.flags = {
|
|
56
|
-
help:
|
|
54
|
+
help: SHARED_FLAGS.help,
|
|
57
55
|
};
|
|
58
56
|
SetToken.args = {};
|
|
59
|
-
|
|
57
|
+
export default SetToken;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const flags_1 = require("../lib/flags");
|
|
8
|
-
class SetUrl extends core_1.Command {
|
|
1
|
+
import { Args, Command, Flags } from "@oclif/core";
|
|
2
|
+
import { handleError, initClient } from "../lib/apollo.js";
|
|
3
|
+
import { allowSelfSignedCertsKey, defaultUrl, getOrCreateConfigData, urlKey, writeConfigData, } from "../lib/config.js";
|
|
4
|
+
import { removeOpalCredentials } from "../lib/credentials/index.js";
|
|
5
|
+
import { SHARED_FLAGS } from "../lib/flags.js";
|
|
6
|
+
class SetUrl extends Command {
|
|
9
7
|
async run() {
|
|
10
8
|
try {
|
|
11
9
|
const { flags, args } = await this.parse(SetUrl);
|
|
12
|
-
let url =
|
|
10
|
+
let url = defaultUrl;
|
|
13
11
|
if (args.url) {
|
|
14
12
|
url = args.url;
|
|
15
13
|
}
|
|
@@ -45,41 +43,41 @@ class SetUrl extends core_1.Command {
|
|
|
45
43
|
// Error if URL doesn't match `https://x.y.z` or `http://x.y.z`
|
|
46
44
|
throw new Error("Invalid URL. Please provide only the protocol and domain (e.g. https://app.opal.dev).");
|
|
47
45
|
}
|
|
48
|
-
const configData =
|
|
49
|
-
configData[
|
|
50
|
-
configData[
|
|
46
|
+
const configData = getOrCreateConfigData(this.config.configDir);
|
|
47
|
+
configData[urlKey] = url;
|
|
48
|
+
configData[allowSelfSignedCertsKey] =
|
|
51
49
|
flags.allowSelfSignedCerts !== undefined;
|
|
52
|
-
|
|
53
|
-
const updatedConfigData =
|
|
54
|
-
await
|
|
55
|
-
await
|
|
56
|
-
this.log(`Opal CLI will now make requests to the server at ${updatedConfigData[
|
|
50
|
+
writeConfigData(this.config.configDir, configData);
|
|
51
|
+
const updatedConfigData = getOrCreateConfigData(this.config.configDir);
|
|
52
|
+
await removeOpalCredentials(this);
|
|
53
|
+
await initClient(this);
|
|
54
|
+
this.log(`Opal CLI will now make requests to the server at ${updatedConfigData[urlKey]}`);
|
|
57
55
|
}
|
|
58
56
|
catch (error) {
|
|
59
|
-
this
|
|
57
|
+
handleError(this, error);
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
|
-
SetUrl.description = `Sets the url of the Opal server. Defaults to ${
|
|
61
|
+
SetUrl.description = `Sets the url of the Opal server. Defaults to ${defaultUrl}.`;
|
|
64
62
|
SetUrl.examples = ["$ opal set-url"];
|
|
65
63
|
SetUrl.flags = {
|
|
66
|
-
help:
|
|
67
|
-
allowSelfSignedCerts:
|
|
64
|
+
help: SHARED_FLAGS.help,
|
|
65
|
+
allowSelfSignedCerts: Flags.boolean(),
|
|
68
66
|
// Deprecated
|
|
69
|
-
custom:
|
|
67
|
+
custom: Flags.string({
|
|
70
68
|
multiple: false,
|
|
71
69
|
hidden: true,
|
|
72
70
|
}),
|
|
73
71
|
// Used only internally
|
|
74
|
-
prod:
|
|
75
|
-
demo:
|
|
76
|
-
dev:
|
|
77
|
-
devLocal:
|
|
72
|
+
prod: Flags.boolean({ hidden: true }),
|
|
73
|
+
demo: Flags.boolean({ hidden: true }),
|
|
74
|
+
dev: Flags.boolean({ hidden: true }),
|
|
75
|
+
devLocal: Flags.boolean({ hidden: true }),
|
|
78
76
|
};
|
|
79
77
|
SetUrl.args = {
|
|
80
|
-
url:
|
|
78
|
+
url: Args.string({
|
|
81
79
|
description: "URL of the Opal server to use. If unspecified, defaults to https://app.opal.dev",
|
|
82
80
|
required: false,
|
|
83
81
|
}),
|
|
84
82
|
};
|
|
85
|
-
|
|
83
|
+
export default SetUrl;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const start_1 = require("./start");
|
|
11
|
-
class StartSCPSession extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { handleError } from "../../lib/apollo.js";
|
|
3
|
+
import { runCommandSpawn, setMostRecentCommand } from "../../lib/cmd.js";
|
|
4
|
+
import { SHARED_FLAGS } from "../../lib/flags.js";
|
|
5
|
+
import { DEFAULT_ACCESS_LEVEL } from "../../lib/resources.js";
|
|
6
|
+
import { getOrCreateSession } from "../../lib/sessions.js";
|
|
7
|
+
import { assertSessionManagerPluginExists, selectComputeInstance, } from "../../lib/ssh.js";
|
|
8
|
+
import { Ec2SessionMetadataFragment } from "./start.js";
|
|
9
|
+
class StartSCPSession extends Command {
|
|
12
10
|
async run() {
|
|
13
|
-
|
|
11
|
+
setMostRecentCommand(this);
|
|
14
12
|
const { flags } = await this.parse(StartSCPSession);
|
|
15
|
-
const pluginExists = await
|
|
13
|
+
const pluginExists = await assertSessionManagerPluginExists();
|
|
16
14
|
if (!pluginExists) {
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
@@ -20,14 +18,14 @@ class StartSCPSession extends core_1.Command {
|
|
|
20
18
|
let instanceName = null;
|
|
21
19
|
const sessionId = flags.sessionId;
|
|
22
20
|
if (!instanceId) {
|
|
23
|
-
const selectedInstance = await
|
|
21
|
+
const selectedInstance = await selectComputeInstance(this, "SCP into");
|
|
24
22
|
if (!selectedInstance) {
|
|
25
23
|
return;
|
|
26
24
|
}
|
|
27
25
|
instanceId = selectedInstance.id;
|
|
28
26
|
instanceName = selectedInstance.name;
|
|
29
27
|
}
|
|
30
|
-
const session = await
|
|
28
|
+
const session = await getOrCreateSession(this, instanceId, DEFAULT_ACCESS_LEVEL, sessionId, Ec2SessionMetadataFragment);
|
|
31
29
|
if (!session) {
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
@@ -42,11 +40,11 @@ class StartSCPSession extends core_1.Command {
|
|
|
42
40
|
// Run SCP script
|
|
43
41
|
const scpCmd = `$SCRIPT_PATH/../../scripts/ssh_ssm_scp_from_server.sh ${metadata.ec2InstanceId} ${flags.user} ${flags.src} ${metadata.ec2Region} ${flags.dest}`;
|
|
44
42
|
const outputMessage = `from "${flags.src}" on ${instanceName ? `"${instanceName}" instance` : "instance"} to "${flags.dest}" locally.`;
|
|
45
|
-
|
|
43
|
+
runCommandSpawn(scpCmd, `Copied ${outputMessage}`, `Failed to copy ${outputMessage}`, envVars);
|
|
46
44
|
break;
|
|
47
45
|
}
|
|
48
46
|
default:
|
|
49
|
-
return
|
|
47
|
+
return handleError(this, undefined, session);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -56,25 +54,25 @@ StartSCPSession.examples = [
|
|
|
56
54
|
"opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398",
|
|
57
55
|
];
|
|
58
56
|
StartSCPSession.flags = {
|
|
59
|
-
help:
|
|
60
|
-
src:
|
|
57
|
+
help: SHARED_FLAGS.help,
|
|
58
|
+
src: Flags.string({
|
|
61
59
|
multiple: false,
|
|
62
60
|
required: true,
|
|
63
61
|
description: "The directory or file you would like to copy over SCP. Note we only support one file or directory at a time.",
|
|
64
62
|
}),
|
|
65
|
-
dest:
|
|
63
|
+
dest: Flags.string({
|
|
66
64
|
multiple: false,
|
|
67
65
|
required: false,
|
|
68
66
|
default: ".",
|
|
69
67
|
description: "The directory you want your files to be copied to.",
|
|
70
68
|
}),
|
|
71
|
-
user:
|
|
69
|
+
user: Flags.string({
|
|
72
70
|
multiple: false,
|
|
73
71
|
required: false,
|
|
74
72
|
default: "ssm-user",
|
|
75
73
|
description: "The user you want to run SCP over. Keep in mind not all users will have access to each other's home directory.",
|
|
76
74
|
}),
|
|
77
|
-
id:
|
|
78
|
-
sessionId:
|
|
75
|
+
id: SHARED_FLAGS.id,
|
|
76
|
+
sessionId: SHARED_FLAGS.sessionId,
|
|
79
77
|
};
|
|
80
|
-
|
|
78
|
+
export default StartSCPSession;
|