opal-security 3.1.1-beta.8ec7545 → 3.1.1-beta.96a5722
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 +36 -18
- package/lib/commands/login.js +6 -2
- package/lib/commands/request/create.d.ts +1 -1
- package/lib/commands/request/create.js +11 -7
- package/lib/commands/whoami.d.ts +8 -0
- package/lib/commands/whoami.js +34 -0
- package/lib/lib/credentials/index.d.ts +2 -1
- package/lib/lib/credentials/index.js +2 -1
- package/lib/lib/requests.d.ts +1 -0
- package/lib/lib/requests.js +17 -10
- package/lib/utils/displays.d.ts +1 -1
- package/lib/utils/displays.js +2 -1
- package/oclif.manifest.json +33 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ $ npm install -g opal-security
|
|
|
22
22
|
$ opal COMMAND
|
|
23
23
|
running command...
|
|
24
24
|
$ opal (--version)
|
|
25
|
-
opal-security/3.1.1-beta.
|
|
25
|
+
opal-security/3.1.1-beta.96a5722 linux-x64 node-v20.19.2
|
|
26
26
|
$ opal --help [COMMAND]
|
|
27
27
|
USAGE
|
|
28
28
|
$ opal COMMAND
|
|
@@ -53,6 +53,7 @@ USAGE
|
|
|
53
53
|
* [`opal ssh copyTo`](#opal-ssh-copyto)
|
|
54
54
|
* [`opal ssh start`](#opal-ssh-start)
|
|
55
55
|
* [`opal version`](#opal-version)
|
|
56
|
+
* [`opal whoami`](#opal-whoami)
|
|
56
57
|
|
|
57
58
|
## `opal autocomplete [SHELL]`
|
|
58
59
|
|
|
@@ -101,7 +102,7 @@ EXAMPLES
|
|
|
101
102
|
$ opal aws:identity
|
|
102
103
|
```
|
|
103
104
|
|
|
104
|
-
_See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
105
|
+
_See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/aws/identity.ts)_
|
|
105
106
|
|
|
106
107
|
## `opal clear-auth-provider`
|
|
107
108
|
|
|
@@ -121,7 +122,7 @@ EXAMPLES
|
|
|
121
122
|
$ opal clear-auth-provider
|
|
122
123
|
```
|
|
123
124
|
|
|
124
|
-
_See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
125
|
+
_See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/clear-auth-provider.ts)_
|
|
125
126
|
|
|
126
127
|
## `opal curl-example`
|
|
127
128
|
|
|
@@ -138,7 +139,7 @@ DESCRIPTION
|
|
|
138
139
|
Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
|
|
139
140
|
```
|
|
140
141
|
|
|
141
|
-
_See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
142
|
+
_See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/curl-example.ts)_
|
|
142
143
|
|
|
143
144
|
## `opal groups get`
|
|
144
145
|
|
|
@@ -159,7 +160,7 @@ EXAMPLES
|
|
|
159
160
|
$ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
|
|
160
161
|
```
|
|
161
162
|
|
|
162
|
-
_See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
163
|
+
_See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/groups/get.ts)_
|
|
163
164
|
|
|
164
165
|
## `opal help [COMMANDS]`
|
|
165
166
|
|
|
@@ -209,7 +210,7 @@ EXAMPLES
|
|
|
209
210
|
$ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
|
|
210
211
|
```
|
|
211
212
|
|
|
212
|
-
_See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
213
|
+
_See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/iam-roles/start.ts)_
|
|
213
214
|
|
|
214
215
|
## `opal kube-roles start`
|
|
215
216
|
|
|
@@ -240,7 +241,7 @@ EXAMPLES
|
|
|
240
241
|
$ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
|
|
241
242
|
```
|
|
242
243
|
|
|
243
|
-
_See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
244
|
+
_See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/kube-roles/start.ts)_
|
|
244
245
|
|
|
245
246
|
## `opal login`
|
|
246
247
|
|
|
@@ -261,7 +262,7 @@ EXAMPLES
|
|
|
261
262
|
$ opal login
|
|
262
263
|
```
|
|
263
264
|
|
|
264
|
-
_See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
265
|
+
_See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/login.ts)_
|
|
265
266
|
|
|
266
267
|
## `opal logout`
|
|
267
268
|
|
|
@@ -281,7 +282,7 @@ EXAMPLES
|
|
|
281
282
|
$ opal logout
|
|
282
283
|
```
|
|
283
284
|
|
|
284
|
-
_See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
285
|
+
_See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/logout.ts)_
|
|
285
286
|
|
|
286
287
|
## `opal postgres-instances start`
|
|
287
288
|
|
|
@@ -318,7 +319,7 @@ EXAMPLES
|
|
|
318
319
|
$ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
|
|
319
320
|
```
|
|
320
321
|
|
|
321
|
-
_See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
322
|
+
_See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/postgres-instances/start.ts)_
|
|
322
323
|
|
|
323
324
|
## `opal resources get`
|
|
324
325
|
|
|
@@ -339,7 +340,7 @@ EXAMPLES
|
|
|
339
340
|
$ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
|
|
340
341
|
```
|
|
341
342
|
|
|
342
|
-
_See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
343
|
+
_See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/resources/get.ts)_
|
|
343
344
|
|
|
344
345
|
## `opal set-auth-provider`
|
|
345
346
|
|
|
@@ -365,7 +366,7 @@ EXAMPLES
|
|
|
365
366
|
$ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
|
|
366
367
|
```
|
|
367
368
|
|
|
368
|
-
_See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
369
|
+
_See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/set-auth-provider.ts)_
|
|
369
370
|
|
|
370
371
|
## `opal set-custom-header`
|
|
371
372
|
|
|
@@ -386,7 +387,7 @@ EXAMPLES
|
|
|
386
387
|
$ opal set-custom-header --header 'cf-access-token: $TOKEN'
|
|
387
388
|
```
|
|
388
389
|
|
|
389
|
-
_See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
390
|
+
_See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/set-custom-header.ts)_
|
|
390
391
|
|
|
391
392
|
## `opal set-token`
|
|
392
393
|
|
|
@@ -406,7 +407,7 @@ EXAMPLES
|
|
|
406
407
|
$ opal set-token
|
|
407
408
|
```
|
|
408
409
|
|
|
409
|
-
_See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
410
|
+
_See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/set-token.ts)_
|
|
410
411
|
|
|
411
412
|
## `opal set-url [URL]`
|
|
412
413
|
|
|
@@ -430,7 +431,7 @@ EXAMPLES
|
|
|
430
431
|
$ opal set-url
|
|
431
432
|
```
|
|
432
433
|
|
|
433
|
-
_See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
434
|
+
_See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/set-url.ts)_
|
|
434
435
|
|
|
435
436
|
## `opal ssh copyFrom`
|
|
436
437
|
|
|
@@ -461,7 +462,7 @@ EXAMPLES
|
|
|
461
462
|
$ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
462
463
|
```
|
|
463
464
|
|
|
464
|
-
_See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
465
|
+
_See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/ssh/copyFrom.ts)_
|
|
465
466
|
|
|
466
467
|
## `opal ssh copyTo`
|
|
467
468
|
|
|
@@ -492,7 +493,7 @@ EXAMPLES
|
|
|
492
493
|
$ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
493
494
|
```
|
|
494
495
|
|
|
495
|
-
_See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
496
|
+
_See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/ssh/copyTo.ts)_
|
|
496
497
|
|
|
497
498
|
## `opal ssh start`
|
|
498
499
|
|
|
@@ -519,7 +520,7 @@ EXAMPLES
|
|
|
519
520
|
$ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
520
521
|
```
|
|
521
522
|
|
|
522
|
-
_See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
523
|
+
_See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/ssh/start.ts)_
|
|
523
524
|
|
|
524
525
|
## `opal version`
|
|
525
526
|
|
|
@@ -540,4 +541,21 @@ FLAG DESCRIPTIONS
|
|
|
540
541
|
```
|
|
541
542
|
|
|
542
543
|
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
|
|
544
|
+
|
|
545
|
+
## `opal whoami`
|
|
546
|
+
|
|
547
|
+
Describes current url set, organization name, and logged in user if applicabled.
|
|
548
|
+
|
|
549
|
+
```
|
|
550
|
+
USAGE
|
|
551
|
+
$ opal whoami [-h]
|
|
552
|
+
|
|
553
|
+
FLAGS
|
|
554
|
+
-h, --help Show CLI help.
|
|
555
|
+
|
|
556
|
+
DESCRIPTION
|
|
557
|
+
Describes current url set, organization name, and logged in user if applicabled.
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
_See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.96a5722/src/commands/whoami.ts)_
|
|
543
561
|
<!-- commandsstop -->
|
package/lib/commands/login.js
CHANGED
|
@@ -88,12 +88,14 @@ class Login extends core_1.Command {
|
|
|
88
88
|
const configData = (0, config_1.getOrCreateConfigData)(configDir);
|
|
89
89
|
let email = flags.email;
|
|
90
90
|
let organizationId;
|
|
91
|
+
let organizationName;
|
|
91
92
|
let clientIDCandidate;
|
|
92
93
|
const existingCreds = await (0, credentials_1.getOpalCredentials)(this, false);
|
|
93
94
|
// Only use the previous email + organizationID if email isn't explicitly specified.
|
|
94
95
|
if (!email) {
|
|
95
96
|
email = existingCreds.email;
|
|
96
97
|
organizationId = existingCreds.organizationID;
|
|
98
|
+
organizationName = existingCreds.organizationName;
|
|
97
99
|
clientIDCandidate = existingCreds.clientIDCandidate;
|
|
98
100
|
}
|
|
99
101
|
await (0, credentials_1.removeOpalCredentials)(this);
|
|
@@ -149,6 +151,7 @@ class Login extends core_1.Command {
|
|
|
149
151
|
if (signInOrganizations && signInOrganizations.length > 0) {
|
|
150
152
|
if (signInOrganizations.length === 1) {
|
|
151
153
|
organizationId = signInOrganizations[0].organizationId;
|
|
154
|
+
organizationName = signInOrganizations[0].organizationName;
|
|
152
155
|
clientIDCandidate = signInOrganizations[0].cliClientId;
|
|
153
156
|
}
|
|
154
157
|
else {
|
|
@@ -164,6 +167,7 @@ class Login extends core_1.Command {
|
|
|
164
167
|
},
|
|
165
168
|
]);
|
|
166
169
|
organizationId = responses.signInOrganization.organizationId;
|
|
170
|
+
organizationName = responses.signInOrganization.organizationName;
|
|
167
171
|
clientIDCandidate = responses.signInOrganization.cliClientId;
|
|
168
172
|
}
|
|
169
173
|
}
|
|
@@ -238,10 +242,10 @@ class Login extends core_1.Command {
|
|
|
238
242
|
if (tokenExchangeError) {
|
|
239
243
|
this.log("WARN: Failed to exchange access token for session in Opal. Falling back to using access token for authenticating requests\n");
|
|
240
244
|
// TODO: consider adding a warn line recommending upgrading Opal to version XYZ, once accompanying PR is pushed to prod
|
|
241
|
-
await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, (tokenSet === null || tokenSet === void 0 ? void 0 : tokenSet.access_token) || "", credentials_1.SecretType.ApiToken);
|
|
245
|
+
await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, (tokenSet === null || tokenSet === void 0 ? void 0 : tokenSet.access_token) || "", credentials_1.SecretType.ApiToken, organizationName);
|
|
242
246
|
}
|
|
243
247
|
else {
|
|
244
|
-
await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, apollo_1.cookieStr, credentials_1.SecretType.Cookie);
|
|
248
|
+
await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, apollo_1.cookieStr, credentials_1.SecretType.Cookie, organizationName);
|
|
245
249
|
}
|
|
246
250
|
// "Representative" authenticated call to check the log-in worked as expected.
|
|
247
251
|
const { resp: authCheckResp, error: authCheckErr } = await (0, handler_1.runQueryDeprecated)({
|
|
@@ -4,7 +4,7 @@ export default class RequestCreate extends Command {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
6
6
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
7
|
-
|
|
7
|
+
assets: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
reason: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
duration: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
};
|
|
@@ -13,9 +13,9 @@ class RequestCreate extends core_1.Command {
|
|
|
13
13
|
(0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
|
|
14
14
|
const { flags } = await this.parse(RequestCreate);
|
|
15
15
|
const metadata = (0, requests_1.initEmptyRequestMetadata)();
|
|
16
|
-
if (flags.
|
|
16
|
+
if (flags.assets) {
|
|
17
17
|
// if IDs are provided, bypass the interactive selection process
|
|
18
|
-
await (0, requests_1.bypassRequestSelection)(this, client, flags.
|
|
18
|
+
await (0, requests_1.bypassRequestSelection)(this, client, flags.assets, metadata);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
(0, displays_1.headerMessage)(this);
|
|
@@ -36,7 +36,9 @@ class RequestCreate extends core_1.Command {
|
|
|
36
36
|
if (flags.reason) {
|
|
37
37
|
metadata.reason = flags.reason;
|
|
38
38
|
}
|
|
39
|
-
else
|
|
39
|
+
else if (!(metadata.requestDefaults.reasonOptional &&
|
|
40
|
+
flags.assets &&
|
|
41
|
+
flags.duration)) {
|
|
40
42
|
await (0, requests_1.promptForReason)(metadata);
|
|
41
43
|
}
|
|
42
44
|
// Step 5: Prompt for expiration
|
|
@@ -48,7 +50,9 @@ class RequestCreate extends core_1.Command {
|
|
|
48
50
|
}
|
|
49
51
|
// Step 6: Display final summary of request
|
|
50
52
|
let canSubmit = true;
|
|
51
|
-
if (!(flags.
|
|
53
|
+
if (!(flags.assets &&
|
|
54
|
+
flags.duration &&
|
|
55
|
+
(metadata.requestDefaults.reasonOptional || flags.reason))) {
|
|
52
56
|
canSubmit = await (0, requests_1.promptRequestSubmission)(this, metadata);
|
|
53
57
|
}
|
|
54
58
|
// Step 7: Prompt for final submission
|
|
@@ -60,10 +64,10 @@ RequestCreate.hidden = true;
|
|
|
60
64
|
RequestCreate.description = "Creates an Opal access request via an interactive form";
|
|
61
65
|
RequestCreate.flags = {
|
|
62
66
|
help: flags_1.SHARED_FLAGS.help,
|
|
63
|
-
|
|
64
|
-
char: "
|
|
67
|
+
assets: core_1.Flags.string({
|
|
68
|
+
char: "a",
|
|
65
69
|
multiple: true,
|
|
66
|
-
description: "The
|
|
70
|
+
description: "The ids of the assets (resource, group) to request access to. Append a role ID using a colon if needed, e.g. `--assets 123:456`.\
|
|
67
71
|
\n If not provided, an interactive selection flow will be available to select assets to request.",
|
|
68
72
|
}),
|
|
69
73
|
reason: core_1.Flags.string({
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const config_1 = require("../lib/config");
|
|
5
|
+
const credentials_1 = require("../lib/credentials");
|
|
6
|
+
const flags_1 = require("../lib/flags");
|
|
7
|
+
class WhoAmI extends core_1.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const opalCreds = await (0, credentials_1.getOpalCredentials)(this, false);
|
|
10
|
+
const organizationName = opalCreds === null || opalCreds === void 0 ? void 0 : opalCreds.organizationName;
|
|
11
|
+
const email = opalCreds === null || opalCreds === void 0 ? void 0 : opalCreds.email;
|
|
12
|
+
const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
|
|
13
|
+
const url = configData[config_1.urlKey];
|
|
14
|
+
if (email) {
|
|
15
|
+
this.log(`User: ${email}`);
|
|
16
|
+
}
|
|
17
|
+
if (organizationName) {
|
|
18
|
+
if (organizationName === "unset-org-id") {
|
|
19
|
+
this.log("Authenticated with Opal API Token.");
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.log(`Organization: ${organizationName}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (url) {
|
|
26
|
+
this.log(`Server: ${url}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
WhoAmI.description = "Describes current url set, organization name, and logged in user if applicabled.";
|
|
31
|
+
WhoAmI.flags = {
|
|
32
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
33
|
+
};
|
|
34
|
+
exports.default = WhoAmI;
|
|
@@ -5,12 +5,13 @@ interface OpalCredentials {
|
|
|
5
5
|
clientIDCandidate?: string;
|
|
6
6
|
secret?: string;
|
|
7
7
|
secretType?: SecretType;
|
|
8
|
+
organizationName?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare enum SecretType {
|
|
10
11
|
Cookie = "COOKIE",
|
|
11
12
|
ApiToken = "API_TOKEN"
|
|
12
13
|
}
|
|
13
|
-
export declare const setOpalCredentials: (command: Command, email: string | undefined, organizationID: string, clientIDCandidate: string | undefined | null, secret: string, secretType: SecretType) => Promise<void>;
|
|
14
|
+
export declare const setOpalCredentials: (command: Command, email: string | undefined, organizationID: string, clientIDCandidate: string | undefined | null, secret: string, secretType: SecretType, organizationName?: string) => Promise<void>;
|
|
14
15
|
export declare const getOpalCredentials: (command: Command, includeAuthSecret?: boolean) => Promise<OpalCredentials>;
|
|
15
16
|
export declare const removeOpalCredentials: (command: Command) => Promise<void>;
|
|
16
17
|
export {};
|
|
@@ -9,13 +9,14 @@ var SecretType;
|
|
|
9
9
|
SecretType["Cookie"] = "COOKIE";
|
|
10
10
|
SecretType["ApiToken"] = "API_TOKEN";
|
|
11
11
|
})(SecretType || (exports.SecretType = SecretType = {}));
|
|
12
|
-
const setOpalCredentials = async (command, email, organizationID, clientIDCandidate, secret, secretType) => {
|
|
12
|
+
const setOpalCredentials = async (command, email, organizationID, clientIDCandidate, secret, secretType, organizationName) => {
|
|
13
13
|
const givenEmail = email || "email-unset";
|
|
14
14
|
const configData = (0, config_1.getOrCreateConfigData)(command.config.configDir);
|
|
15
15
|
configData.creds = {
|
|
16
16
|
clientIDCandidate,
|
|
17
17
|
email,
|
|
18
18
|
organizationID,
|
|
19
|
+
organizationName,
|
|
19
20
|
secretType,
|
|
20
21
|
};
|
|
21
22
|
(0, config_1.writeConfigData)(command.config.configDir, configData);
|
package/lib/lib/requests.d.ts
CHANGED
package/lib/lib/requests.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DISPLAY_LABELS = void 0;
|
|
3
4
|
exports.initEmptyRequestMetadata = initEmptyRequestMetadata;
|
|
4
5
|
exports.selectRequestableItems = selectRequestableItems;
|
|
5
6
|
exports.doneSelectingAssets = doneSelectingAssets;
|
|
@@ -15,7 +16,7 @@ const graphql_1 = require("../graphql");
|
|
|
15
16
|
const graphql_2 = require("../graphql/graphql");
|
|
16
17
|
const displays_1 = require("../utils/displays");
|
|
17
18
|
const config_1 = require("./config");
|
|
18
|
-
const { AutoComplete, Select, prompt, Form
|
|
19
|
+
const { AutoComplete, Select, prompt, Form } = require("enquirer");
|
|
19
20
|
function entityTypeFromString(str) {
|
|
20
21
|
const capStr = str === null || str === void 0 ? void 0 : str.toLocaleUpperCase();
|
|
21
22
|
if (capStr === "RESOURCE") {
|
|
@@ -27,6 +28,10 @@ function entityTypeFromString(str) {
|
|
|
27
28
|
// if type unknown, default to resource
|
|
28
29
|
return graphql_2.EntityType.Resource;
|
|
29
30
|
}
|
|
31
|
+
exports.DISPLAY_LABELS = {
|
|
32
|
+
[graphql_2.EntityType.Resource]: "Resource",
|
|
33
|
+
[graphql_2.EntityType.Group]: "Group",
|
|
34
|
+
};
|
|
30
35
|
function initEmptyRequestMetadata() {
|
|
31
36
|
// Initialize with empty defaults
|
|
32
37
|
const requestDefaults = {
|
|
@@ -238,7 +243,7 @@ async function queryAssetRoles(cmd, client, assetType, assetId) {
|
|
|
238
243
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
239
244
|
try {
|
|
240
245
|
switch (assetType) {
|
|
241
|
-
case
|
|
246
|
+
case graphql_2.EntityType.Resource: {
|
|
242
247
|
const resp = await client.query({
|
|
243
248
|
query: RESOURCE_ROLES_QUERY,
|
|
244
249
|
variables: {
|
|
@@ -267,7 +272,7 @@ async function queryAssetRoles(cmd, client, assetType, assetId) {
|
|
|
267
272
|
}
|
|
268
273
|
return;
|
|
269
274
|
}
|
|
270
|
-
case
|
|
275
|
+
case graphql_2.EntityType.Group: {
|
|
271
276
|
const resp = await client.query({
|
|
272
277
|
query: GROUP_ROLES_QUERY,
|
|
273
278
|
variables: {
|
|
@@ -697,7 +702,7 @@ function appRolesFromEdge(edge) {
|
|
|
697
702
|
value: {
|
|
698
703
|
id: edge.node.id + accessLevel.accessLevelRemoteId,
|
|
699
704
|
name: accessLevel.accessLevelName,
|
|
700
|
-
type: graphql_2.EntityType.Resource,
|
|
705
|
+
type: exports.DISPLAY_LABELS[graphql_2.EntityType.Resource],
|
|
701
706
|
toString: () => accessLevel.accessLevelName,
|
|
702
707
|
},
|
|
703
708
|
}));
|
|
@@ -708,7 +713,7 @@ function appRolesFromEdge(edge) {
|
|
|
708
713
|
value: {
|
|
709
714
|
id: edge.node.id,
|
|
710
715
|
name: (_b = edge.alias) !== null && _b !== void 0 ? _b : edge.node.name,
|
|
711
|
-
type: graphql_2.EntityType.Resource,
|
|
716
|
+
type: exports.DISPLAY_LABELS[graphql_2.EntityType.Resource],
|
|
712
717
|
toString: () => { var _a; return (_a = edge.alias) !== null && _a !== void 0 ? _a : edge.node.name; },
|
|
713
718
|
},
|
|
714
719
|
},
|
|
@@ -717,11 +722,11 @@ function appRolesFromEdge(edge) {
|
|
|
717
722
|
case "Group":
|
|
718
723
|
return [
|
|
719
724
|
{
|
|
720
|
-
message: (_c = edge.alias) !== null && _c !== void 0 ? _c : edge.node.name
|
|
725
|
+
message: `${(_c = edge.alias) !== null && _c !== void 0 ? _c : edge.node.name} ${graphql_2.EntityType.Group}`,
|
|
721
726
|
value: {
|
|
722
727
|
id: edge.node.id,
|
|
723
728
|
name: (_d = edge.alias) !== null && _d !== void 0 ? _d : edge.node.name,
|
|
724
|
-
type: graphql_2.EntityType.Group,
|
|
729
|
+
type: exports.DISPLAY_LABELS[graphql_2.EntityType.Group],
|
|
725
730
|
toString: () => { var _a; return (_a = edge.alias) !== null && _a !== void 0 ? _a : edge.node.name; },
|
|
726
731
|
},
|
|
727
732
|
},
|
|
@@ -1068,8 +1073,10 @@ async function bypassRequestSelection(cmd, client, flagValue, metadata) {
|
|
|
1068
1073
|
var _a, _b;
|
|
1069
1074
|
try {
|
|
1070
1075
|
// Query Catalog Item endpoint to identify what the id belongs to (resource or group)
|
|
1071
|
-
for (const
|
|
1072
|
-
const
|
|
1076
|
+
for (const val of flagValue) {
|
|
1077
|
+
const delimiterIndex = val.indexOf(":");
|
|
1078
|
+
const assetId = val.substring(0, delimiterIndex);
|
|
1079
|
+
const roleName = val.substring(delimiterIndex + 1);
|
|
1073
1080
|
const resp = await client.query({
|
|
1074
1081
|
query: CATALOG_ITEM,
|
|
1075
1082
|
variables: {
|
|
@@ -1096,7 +1103,7 @@ async function bypassRequestSelection(cmd, client, flagValue, metadata) {
|
|
|
1096
1103
|
assets: {},
|
|
1097
1104
|
};
|
|
1098
1105
|
}
|
|
1099
|
-
const assetEntry = metadata.requestMap[appId].assets[
|
|
1106
|
+
const assetEntry = metadata.requestMap[appId].assets[assetId];
|
|
1100
1107
|
if (!assetEntry) {
|
|
1101
1108
|
metadata.requestMap[appId].assets[assetId] = {
|
|
1102
1109
|
assetId: assetId,
|
package/lib/utils/displays.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ApolloQueryResult } from "@apollo/client";
|
|
2
2
|
import type { Command } from "@oclif/core/lib/command";
|
|
3
3
|
import type { GetRequestQuery, GetRequestsQuery } from "../graphql/graphql";
|
|
4
|
-
import type
|
|
4
|
+
import { type RequestMap, type RequestMetadata } from "../lib/requests";
|
|
5
5
|
export declare function headerMessage(cmd: Command): void;
|
|
6
6
|
export declare function treeifyRequestMap(cmd: Command, requestMap: RequestMap): void;
|
|
7
7
|
export declare function displayFinalRequestSummary(cmd: Command, metadata: RequestMetadata): void;
|
package/lib/utils/displays.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getStyledStatus = getStyledStatus;
|
|
|
7
7
|
exports.displayRequestDetails = displayRequestDetails;
|
|
8
8
|
exports.displayRequestListTable = displayRequestListTable;
|
|
9
9
|
const chalk_1 = require("chalk");
|
|
10
|
+
const requests_1 = require("../lib/requests");
|
|
10
11
|
const Table = require("cli-table3");
|
|
11
12
|
const treeify = require("object-treeify").default;
|
|
12
13
|
function headerMessage(cmd) {
|
|
@@ -30,7 +31,7 @@ function treeifyRequestMap(cmd, requestMap) {
|
|
|
30
31
|
for (const [_assetId, assetNode] of Object.entries(appNode.assets)) {
|
|
31
32
|
// If okta/azure asset with no role, change asset name
|
|
32
33
|
const assetName = assetNode.assetName || "No Role (Direct access)";
|
|
33
|
-
const assetKey = `${assetName} ${chalk_1.default.dim(`[${assetNode.type}]`)}`;
|
|
34
|
+
const assetKey = `${assetName} ${chalk_1.default.dim(`[${requests_1.DISPLAY_LABELS[assetNode.type]}]`)}`;
|
|
34
35
|
if (assetNode.roles !== undefined) {
|
|
35
36
|
assetsTree[assetKey] = {};
|
|
36
37
|
for (const [_roleId, roleNode] of Object.entries(assetNode.roles)) {
|
package/oclif.manifest.json
CHANGED
|
@@ -316,6 +316,34 @@
|
|
|
316
316
|
"set-url.js"
|
|
317
317
|
]
|
|
318
318
|
},
|
|
319
|
+
"whoami": {
|
|
320
|
+
"aliases": [],
|
|
321
|
+
"args": {},
|
|
322
|
+
"description": "Describes current url set, organization name, and logged in user if applicabled.",
|
|
323
|
+
"flags": {
|
|
324
|
+
"help": {
|
|
325
|
+
"char": "h",
|
|
326
|
+
"description": "Show CLI help.",
|
|
327
|
+
"name": "help",
|
|
328
|
+
"allowNo": false,
|
|
329
|
+
"type": "boolean"
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
"hasDynamicHelp": false,
|
|
333
|
+
"hiddenAliases": [],
|
|
334
|
+
"id": "whoami",
|
|
335
|
+
"pluginAlias": "opal-security",
|
|
336
|
+
"pluginName": "opal-security",
|
|
337
|
+
"pluginType": "core",
|
|
338
|
+
"strict": true,
|
|
339
|
+
"enableJsonFlag": false,
|
|
340
|
+
"isESM": false,
|
|
341
|
+
"relativePath": [
|
|
342
|
+
"lib",
|
|
343
|
+
"commands",
|
|
344
|
+
"whoami.js"
|
|
345
|
+
]
|
|
346
|
+
},
|
|
319
347
|
"aws:identity": {
|
|
320
348
|
"aliases": [],
|
|
321
349
|
"args": {},
|
|
@@ -606,10 +634,10 @@
|
|
|
606
634
|
"allowNo": false,
|
|
607
635
|
"type": "boolean"
|
|
608
636
|
},
|
|
609
|
-
"
|
|
610
|
-
"char": "
|
|
611
|
-
"description": "The
|
|
612
|
-
"name": "
|
|
637
|
+
"assets": {
|
|
638
|
+
"char": "a",
|
|
639
|
+
"description": "The ids of the assets (resource, group) to request access to. Append a role ID using a colon if needed, e.g. `--assets 123:456`. \n If not provided, an interactive selection flow will be available to select assets to request.",
|
|
640
|
+
"name": "assets",
|
|
613
641
|
"hasDynamicHelp": false,
|
|
614
642
|
"multiple": true,
|
|
615
643
|
"type": "option"
|
|
@@ -1003,5 +1031,5 @@
|
|
|
1003
1031
|
]
|
|
1004
1032
|
}
|
|
1005
1033
|
},
|
|
1006
|
-
"version": "3.1.1-beta.
|
|
1034
|
+
"version": "3.1.1-beta.96a5722"
|
|
1007
1035
|
}
|
package/package.json
CHANGED