opal-security 3.1.1-beta.0cf32a6 → 3.1.1-beta.153d5b3
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 +122 -26
- package/lib/commands/login.js +6 -2
- package/lib/commands/request/create.d.ts +6 -1
- package/lib/commands/request/create.js +59 -17
- package/lib/commands/request/get.d.ts +0 -1
- package/lib/commands/request/get.js +1 -4
- package/lib/commands/request/list.d.ts +0 -1
- package/lib/commands/request/list.js +0 -3
- package/lib/commands/whoami.d.ts +8 -0
- package/lib/commands/whoami.js +34 -0
- package/lib/graphql/gql.d.ts +10 -0
- package/lib/graphql/gql.js +2 -0
- package/lib/graphql/graphql.d.ts +85 -0
- package/lib/graphql/graphql.js +539 -1
- package/lib/lib/apollo.js +3 -4
- package/lib/lib/credentials/index.d.ts +2 -1
- package/lib/lib/credentials/index.js +2 -1
- package/lib/lib/flags.js +1 -1
- package/lib/lib/requests.d.ts +22 -15
- package/lib/lib/requests.js +385 -78
- package/lib/utils/displays.d.ts +1 -1
- package/lib/utils/displays.js +9 -3
- package/oclif.manifest.json +71 -14
- 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.153d5b3 linux-x64 node-v20.19.2
|
|
26
26
|
$ opal --help [COMMAND]
|
|
27
27
|
USAGE
|
|
28
28
|
$ opal COMMAND
|
|
@@ -44,6 +44,9 @@ USAGE
|
|
|
44
44
|
* [`opal login`](#opal-login)
|
|
45
45
|
* [`opal logout`](#opal-logout)
|
|
46
46
|
* [`opal postgres-instances start`](#opal-postgres-instances-start)
|
|
47
|
+
* [`opal request create`](#opal-request-create)
|
|
48
|
+
* [`opal request get`](#opal-request-get)
|
|
49
|
+
* [`opal request list`](#opal-request-list)
|
|
47
50
|
* [`opal resources get`](#opal-resources-get)
|
|
48
51
|
* [`opal set-auth-provider`](#opal-set-auth-provider)
|
|
49
52
|
* [`opal set-custom-header`](#opal-set-custom-header)
|
|
@@ -53,6 +56,7 @@ USAGE
|
|
|
53
56
|
* [`opal ssh copyTo`](#opal-ssh-copyto)
|
|
54
57
|
* [`opal ssh start`](#opal-ssh-start)
|
|
55
58
|
* [`opal version`](#opal-version)
|
|
59
|
+
* [`opal whoami`](#opal-whoami)
|
|
56
60
|
|
|
57
61
|
## `opal autocomplete [SHELL]`
|
|
58
62
|
|
|
@@ -101,7 +105,7 @@ EXAMPLES
|
|
|
101
105
|
$ opal aws:identity
|
|
102
106
|
```
|
|
103
107
|
|
|
104
|
-
_See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
108
|
+
_See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/aws/identity.ts)_
|
|
105
109
|
|
|
106
110
|
## `opal clear-auth-provider`
|
|
107
111
|
|
|
@@ -121,7 +125,7 @@ EXAMPLES
|
|
|
121
125
|
$ opal clear-auth-provider
|
|
122
126
|
```
|
|
123
127
|
|
|
124
|
-
_See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
128
|
+
_See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/clear-auth-provider.ts)_
|
|
125
129
|
|
|
126
130
|
## `opal curl-example`
|
|
127
131
|
|
|
@@ -138,7 +142,7 @@ DESCRIPTION
|
|
|
138
142
|
Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
|
|
139
143
|
```
|
|
140
144
|
|
|
141
|
-
_See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
145
|
+
_See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/curl-example.ts)_
|
|
142
146
|
|
|
143
147
|
## `opal groups get`
|
|
144
148
|
|
|
@@ -150,7 +154,7 @@ USAGE
|
|
|
150
154
|
|
|
151
155
|
FLAGS
|
|
152
156
|
-h, --help Show CLI help.
|
|
153
|
-
-i, --id=<value> The Opal ID of the
|
|
157
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
|
|
154
158
|
|
|
155
159
|
DESCRIPTION
|
|
156
160
|
Get group info for a particular group.
|
|
@@ -159,7 +163,7 @@ EXAMPLES
|
|
|
159
163
|
$ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
|
|
160
164
|
```
|
|
161
165
|
|
|
162
|
-
_See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
166
|
+
_See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/groups/get.ts)_
|
|
163
167
|
|
|
164
168
|
## `opal help [COMMANDS]`
|
|
165
169
|
|
|
@@ -191,7 +195,7 @@ USAGE
|
|
|
191
195
|
|
|
192
196
|
FLAGS
|
|
193
197
|
-h, --help Show CLI help.
|
|
194
|
-
-i, --id=<value> The Opal ID of the
|
|
198
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
|
|
195
199
|
https://opal.dev/resources/[ID]
|
|
196
200
|
-r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
|
|
197
201
|
-s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
@@ -209,7 +213,7 @@ EXAMPLES
|
|
|
209
213
|
$ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
|
|
210
214
|
```
|
|
211
215
|
|
|
212
|
-
_See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
216
|
+
_See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/iam-roles/start.ts)_
|
|
213
217
|
|
|
214
218
|
## `opal kube-roles start`
|
|
215
219
|
|
|
@@ -222,7 +226,7 @@ USAGE
|
|
|
222
226
|
FLAGS
|
|
223
227
|
-a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
|
|
224
228
|
-h, --help Show CLI help.
|
|
225
|
-
-i, --id=<value> The Opal ID of the
|
|
229
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
|
|
226
230
|
https://opal.dev/resources/[ID]
|
|
227
231
|
-r, --refresh Starts a new session even if one already exists. Useful if a session is about to
|
|
228
232
|
expire.
|
|
@@ -240,7 +244,7 @@ EXAMPLES
|
|
|
240
244
|
$ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
|
|
241
245
|
```
|
|
242
246
|
|
|
243
|
-
_See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
247
|
+
_See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/kube-roles/start.ts)_
|
|
244
248
|
|
|
245
249
|
## `opal login`
|
|
246
250
|
|
|
@@ -261,7 +265,7 @@ EXAMPLES
|
|
|
261
265
|
$ opal login
|
|
262
266
|
```
|
|
263
267
|
|
|
264
|
-
_See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
268
|
+
_See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/login.ts)_
|
|
265
269
|
|
|
266
270
|
## `opal logout`
|
|
267
271
|
|
|
@@ -281,7 +285,7 @@ EXAMPLES
|
|
|
281
285
|
$ opal logout
|
|
282
286
|
```
|
|
283
287
|
|
|
284
|
-
_See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
288
|
+
_See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/logout.ts)_
|
|
285
289
|
|
|
286
290
|
## `opal postgres-instances start`
|
|
287
291
|
|
|
@@ -294,7 +298,7 @@ USAGE
|
|
|
294
298
|
FLAGS
|
|
295
299
|
-a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
|
|
296
300
|
-h, --help Show CLI help.
|
|
297
|
-
-i, --id=<value> The Opal ID of the
|
|
301
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
|
|
298
302
|
https://opal.dev/resources/[ID]
|
|
299
303
|
-r, --refresh Starts a new session even if one already exists. Useful if a session is about to
|
|
300
304
|
expire.
|
|
@@ -318,7 +322,82 @@ EXAMPLES
|
|
|
318
322
|
$ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
|
|
319
323
|
```
|
|
320
324
|
|
|
321
|
-
_See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
325
|
+
_See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/postgres-instances/start.ts)_
|
|
326
|
+
|
|
327
|
+
## `opal request create`
|
|
328
|
+
|
|
329
|
+
Creates an Opal access request via an interactive form
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
USAGE
|
|
333
|
+
$ opal request create [-h] [-a <value>...] [-r <value>] [-d <value>]
|
|
334
|
+
|
|
335
|
+
FLAGS
|
|
336
|
+
-a, --assets=<value>... The ids of the assets (resource, group) to request access to. Append a role ID using a colon
|
|
337
|
+
if needed, e.g. `--assets 123:456`.
|
|
338
|
+
If not provided, an interactive selection flow will be available to select assets to request.
|
|
339
|
+
-d, --duration=<value> The duration of access for the request in minutes. If not provided, you will be prompted.
|
|
340
|
+
-h, --help Show CLI help.
|
|
341
|
+
-r, --reason=<value> The reason for the request, contained in quotes. If not provided, you will be prompted.
|
|
342
|
+
|
|
343
|
+
DESCRIPTION
|
|
344
|
+
Creates an Opal access request via an interactive form
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
_See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/request/create.ts)_
|
|
348
|
+
|
|
349
|
+
## `opal request get`
|
|
350
|
+
|
|
351
|
+
Lists access requests
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
USAGE
|
|
355
|
+
$ opal request get [-h] [-i <value>] [-v]
|
|
356
|
+
|
|
357
|
+
FLAGS
|
|
358
|
+
-h, --help Show CLI help.
|
|
359
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
|
|
360
|
+
-v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
|
|
361
|
+
|
|
362
|
+
DESCRIPTION
|
|
363
|
+
Lists access requests
|
|
364
|
+
|
|
365
|
+
EXAMPLES
|
|
366
|
+
$ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
|
|
367
|
+
|
|
368
|
+
$ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
_See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/request/get.ts)_
|
|
372
|
+
|
|
373
|
+
## `opal request list`
|
|
374
|
+
|
|
375
|
+
Lists your n recent outgoing access requests
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
USAGE
|
|
379
|
+
$ opal request list [-h] [-n <value>] [-p] [-v]
|
|
380
|
+
|
|
381
|
+
FLAGS
|
|
382
|
+
-h, --help Show CLI help.
|
|
383
|
+
-n, --n=<value> [default: 10] Defines number of requests to be returned. 1 <= n <= 100.
|
|
384
|
+
-p, --pending Show only pending requests. Defaults to false.
|
|
385
|
+
-v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
|
|
386
|
+
|
|
387
|
+
DESCRIPTION
|
|
388
|
+
Lists your n recent outgoing access requests
|
|
389
|
+
|
|
390
|
+
EXAMPLES
|
|
391
|
+
$ opal request list --n 5
|
|
392
|
+
|
|
393
|
+
$ opal request list --n 5 --pending
|
|
394
|
+
|
|
395
|
+
$ opal request list --n 5 --verbose
|
|
396
|
+
|
|
397
|
+
$ opal request list --n 5 --pending --verbose
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
_See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/request/list.ts)_
|
|
322
401
|
|
|
323
402
|
## `opal resources get`
|
|
324
403
|
|
|
@@ -330,7 +409,7 @@ USAGE
|
|
|
330
409
|
|
|
331
410
|
FLAGS
|
|
332
411
|
-h, --help Show CLI help.
|
|
333
|
-
-i, --id=<value> The Opal ID of the
|
|
412
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
|
|
334
413
|
|
|
335
414
|
DESCRIPTION
|
|
336
415
|
Get resource info for a particular resource.
|
|
@@ -339,7 +418,7 @@ EXAMPLES
|
|
|
339
418
|
$ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
|
|
340
419
|
```
|
|
341
420
|
|
|
342
|
-
_See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
421
|
+
_See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/resources/get.ts)_
|
|
343
422
|
|
|
344
423
|
## `opal set-auth-provider`
|
|
345
424
|
|
|
@@ -365,7 +444,7 @@ EXAMPLES
|
|
|
365
444
|
$ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
|
|
366
445
|
```
|
|
367
446
|
|
|
368
|
-
_See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
447
|
+
_See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/set-auth-provider.ts)_
|
|
369
448
|
|
|
370
449
|
## `opal set-custom-header`
|
|
371
450
|
|
|
@@ -386,7 +465,7 @@ EXAMPLES
|
|
|
386
465
|
$ opal set-custom-header --header 'cf-access-token: $TOKEN'
|
|
387
466
|
```
|
|
388
467
|
|
|
389
|
-
_See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
468
|
+
_See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/set-custom-header.ts)_
|
|
390
469
|
|
|
391
470
|
## `opal set-token`
|
|
392
471
|
|
|
@@ -406,7 +485,7 @@ EXAMPLES
|
|
|
406
485
|
$ opal set-token
|
|
407
486
|
```
|
|
408
487
|
|
|
409
|
-
_See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
488
|
+
_See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/set-token.ts)_
|
|
410
489
|
|
|
411
490
|
## `opal set-url [URL]`
|
|
412
491
|
|
|
@@ -430,7 +509,7 @@ EXAMPLES
|
|
|
430
509
|
$ opal set-url
|
|
431
510
|
```
|
|
432
511
|
|
|
433
|
-
_See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
512
|
+
_See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/set-url.ts)_
|
|
434
513
|
|
|
435
514
|
## `opal ssh copyFrom`
|
|
436
515
|
|
|
@@ -442,7 +521,7 @@ USAGE
|
|
|
442
521
|
|
|
443
522
|
FLAGS
|
|
444
523
|
-h, --help Show CLI help.
|
|
445
|
-
-i, --id=<value> The Opal ID of the
|
|
524
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
|
|
446
525
|
https://opal.dev/resources/[ID]
|
|
447
526
|
-s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
448
527
|
web flow.
|
|
@@ -461,7 +540,7 @@ EXAMPLES
|
|
|
461
540
|
$ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
462
541
|
```
|
|
463
542
|
|
|
464
|
-
_See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
543
|
+
_See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/ssh/copyFrom.ts)_
|
|
465
544
|
|
|
466
545
|
## `opal ssh copyTo`
|
|
467
546
|
|
|
@@ -473,7 +552,7 @@ USAGE
|
|
|
473
552
|
|
|
474
553
|
FLAGS
|
|
475
554
|
-h, --help Show CLI help.
|
|
476
|
-
-i, --id=<value> The Opal ID of the
|
|
555
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
|
|
477
556
|
https://opal.dev/resources/[ID]
|
|
478
557
|
-s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
479
558
|
web flow.
|
|
@@ -492,7 +571,7 @@ EXAMPLES
|
|
|
492
571
|
$ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
493
572
|
```
|
|
494
573
|
|
|
495
|
-
_See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
574
|
+
_See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/ssh/copyTo.ts)_
|
|
496
575
|
|
|
497
576
|
## `opal ssh start`
|
|
498
577
|
|
|
@@ -504,7 +583,7 @@ USAGE
|
|
|
504
583
|
|
|
505
584
|
FLAGS
|
|
506
585
|
-h, --help Show CLI help.
|
|
507
|
-
-i, --id=<value> The Opal ID of the
|
|
586
|
+
-i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
|
|
508
587
|
https://opal.dev/resources/[ID]
|
|
509
588
|
-r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
|
|
510
589
|
-s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
@@ -519,7 +598,7 @@ EXAMPLES
|
|
|
519
598
|
$ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
520
599
|
```
|
|
521
600
|
|
|
522
|
-
_See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.
|
|
601
|
+
_See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/ssh/start.ts)_
|
|
523
602
|
|
|
524
603
|
## `opal version`
|
|
525
604
|
|
|
@@ -540,4 +619,21 @@ FLAG DESCRIPTIONS
|
|
|
540
619
|
```
|
|
541
620
|
|
|
542
621
|
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
|
|
622
|
+
|
|
623
|
+
## `opal whoami`
|
|
624
|
+
|
|
625
|
+
Describes current url set, organization name, and logged in user if applicable.
|
|
626
|
+
|
|
627
|
+
```
|
|
628
|
+
USAGE
|
|
629
|
+
$ opal whoami [-h]
|
|
630
|
+
|
|
631
|
+
FLAGS
|
|
632
|
+
-h, --help Show CLI help.
|
|
633
|
+
|
|
634
|
+
DESCRIPTION
|
|
635
|
+
Describes current url set, organization name, and logged in user if applicable.
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
_See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.153d5b3/src/commands/whoami.ts)_
|
|
543
639
|
<!-- 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)({
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
export default class RequestCreate extends Command {
|
|
3
|
-
static hidden: boolean;
|
|
4
3
|
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
|
+
assets: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
reason: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
duration: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
5
10
|
run(): Promise<void>;
|
|
6
11
|
}
|
|
@@ -2,38 +2,80 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const apollo_1 = require("../../lib/apollo");
|
|
5
|
+
const cmd_1 = require("../../lib/cmd");
|
|
6
|
+
const flags_1 = require("../../lib/flags");
|
|
5
7
|
const requests_1 = require("../../lib/requests");
|
|
6
8
|
const displays_1 = require("../../utils/displays");
|
|
7
|
-
const utils_1 = require("../../utils/utils");
|
|
8
9
|
class RequestCreate extends core_1.Command {
|
|
9
10
|
async run() {
|
|
11
|
+
(0, cmd_1.setMostRecentCommand)(this);
|
|
10
12
|
await (0, apollo_1.initClient)(this, true);
|
|
11
13
|
const client = await (0, apollo_1.getClient)(this, true);
|
|
12
|
-
|
|
14
|
+
const { flags } = await this.parse(RequestCreate);
|
|
13
15
|
const metadata = (0, requests_1.initEmptyRequestMetadata)();
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Step 2: Display the selected items in a tree format
|
|
16
|
+
if (flags.assets) {
|
|
17
|
+
// if IDs are provided, bypass the interactive selection process
|
|
18
|
+
await (0, requests_1.bypassRequestSelection)(this, client, flags.assets, metadata);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
20
21
|
(0, displays_1.headerMessage)(this);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
let shouldProceed = false;
|
|
23
|
+
while (!shouldProceed) {
|
|
24
|
+
// Step 1: Select first round of assets from an app
|
|
25
|
+
await (0, requests_1.selectRequestableItems)(this, client, metadata.requestMap);
|
|
26
|
+
// Step 2: Display the selected items in a tree format
|
|
27
|
+
(0, displays_1.headerMessage)(this);
|
|
28
|
+
(0, displays_1.treeifyRequestMap)(this, metadata.requestMap);
|
|
29
|
+
// Step 3: Prompt to add more items, repeat 1-3 if needed
|
|
30
|
+
shouldProceed = await (0, requests_1.doneSelectingAssets)();
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
// Step 4: Set Request Defaults
|
|
26
34
|
await (0, requests_1.setRequestDefaults)(this, client, metadata);
|
|
27
35
|
// Step 4: Prompt for request reason
|
|
28
|
-
|
|
36
|
+
if (flags.reason) {
|
|
37
|
+
metadata.reason = flags.reason;
|
|
38
|
+
}
|
|
39
|
+
else if (!(metadata.requestDefaults.reasonOptional &&
|
|
40
|
+
flags.assets &&
|
|
41
|
+
flags.duration)) {
|
|
42
|
+
await (0, requests_1.promptForReason)(metadata);
|
|
43
|
+
}
|
|
29
44
|
// Step 5: Prompt for expiration
|
|
30
|
-
|
|
45
|
+
if (flags.duration) {
|
|
46
|
+
(0, requests_1.bypassDuration)(this, flags.duration, metadata);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
await (0, requests_1.promptForExpiration)(metadata);
|
|
50
|
+
}
|
|
31
51
|
// Step 6: Display final summary of request
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
let canSubmit = true;
|
|
53
|
+
if (!(flags.assets &&
|
|
54
|
+
flags.duration &&
|
|
55
|
+
(metadata.requestDefaults.reasonOptional || flags.reason))) {
|
|
56
|
+
canSubmit = await (0, requests_1.promptRequestSubmission)(this, metadata);
|
|
57
|
+
}
|
|
58
|
+
// Step 7: Prompt for final submission
|
|
59
|
+
if (canSubmit)
|
|
60
|
+
await (0, requests_1.submitFinalRequest)(this, client, metadata);
|
|
35
61
|
}
|
|
36
62
|
}
|
|
37
|
-
RequestCreate.hidden = true;
|
|
38
63
|
RequestCreate.description = "Creates an Opal access request via an interactive form";
|
|
64
|
+
RequestCreate.flags = {
|
|
65
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
66
|
+
assets: core_1.Flags.string({
|
|
67
|
+
char: "a",
|
|
68
|
+
multiple: true,
|
|
69
|
+
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`.\
|
|
70
|
+
\n If not provided, an interactive selection flow will be available to select assets to request.",
|
|
71
|
+
}),
|
|
72
|
+
reason: core_1.Flags.string({
|
|
73
|
+
char: "r",
|
|
74
|
+
description: "The reason for the request, contained in quotes. If not provided, you will be prompted.",
|
|
75
|
+
}),
|
|
76
|
+
duration: core_1.Flags.integer({
|
|
77
|
+
char: "d",
|
|
78
|
+
description: "The duration of access for the request in minutes. If not provided, you will be prompted.",
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
39
81
|
exports.default = RequestCreate;
|
|
@@ -8,7 +8,6 @@ const cmd_1 = require("../../lib/cmd");
|
|
|
8
8
|
const config_1 = require("../../lib/config");
|
|
9
9
|
const flags_1 = require("../../lib/flags");
|
|
10
10
|
const displays_1 = require("../../utils/displays");
|
|
11
|
-
const utils_1 = require("../../utils/utils");
|
|
12
11
|
const GET_REQUEST = (0, graphql_1.graphql)(`
|
|
13
12
|
query GetRequest(
|
|
14
13
|
$id: RequestId!
|
|
@@ -58,14 +57,13 @@ const GET_REQUEST = (0, graphql_1.graphql)(`
|
|
|
58
57
|
`);
|
|
59
58
|
class GetRequest extends core_1.Command {
|
|
60
59
|
async run() {
|
|
61
|
-
(0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
|
|
62
60
|
(0, cmd_1.setMostRecentCommand)(this);
|
|
63
61
|
const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
|
|
64
62
|
const client = await (0, apollo_1.getClient)(this, true);
|
|
65
63
|
// Verify id tag was provided
|
|
66
64
|
const { flags } = await this.parse(GetRequest);
|
|
67
65
|
if (!flags.id) {
|
|
68
|
-
this.log("Error: Please provide a
|
|
66
|
+
this.log("Error: Please provide a request ID using the --id flag.");
|
|
69
67
|
this.log("ex. opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4");
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
@@ -96,7 +94,6 @@ class GetRequest extends core_1.Command {
|
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
|
-
GetRequest.hidden = true;
|
|
100
97
|
GetRequest.description = "Lists access requests";
|
|
101
98
|
GetRequest.flags = {
|
|
102
99
|
help: flags_1.SHARED_FLAGS.help,
|
|
@@ -6,7 +6,6 @@ const apollo_1 = require("../../lib/apollo");
|
|
|
6
6
|
const cmd_1 = require("../../lib/cmd");
|
|
7
7
|
const flags_1 = require("../../lib/flags");
|
|
8
8
|
const displays_1 = require("../../utils/displays");
|
|
9
|
-
const utils_1 = require("../../utils/utils");
|
|
10
9
|
// Add date filters, search query,
|
|
11
10
|
const GET_REQUESTS = (0, graphql_1.graphql)(`
|
|
12
11
|
query GetRequests($pageSize: Int, $showPendingOnly: Boolean!) {
|
|
@@ -59,7 +58,6 @@ const GET_REQUESTS = (0, graphql_1.graphql)(`
|
|
|
59
58
|
}`);
|
|
60
59
|
class ListRequests extends core_1.Command {
|
|
61
60
|
async run() {
|
|
62
|
-
(0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
|
|
63
61
|
(0, cmd_1.setMostRecentCommand)(this);
|
|
64
62
|
const client = await (0, apollo_1.getClient)(this, true);
|
|
65
63
|
let pageSize = 10;
|
|
@@ -88,7 +86,6 @@ class ListRequests extends core_1.Command {
|
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
ListRequests.hidden = true;
|
|
92
89
|
ListRequests.description = "Lists your n recent outgoing access requests";
|
|
93
90
|
ListRequests.examples = [
|
|
94
91
|
"opal request list --n 5",
|
|
@@ -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 applicable.";
|
|
31
|
+
WhoAmI.flags = {
|
|
32
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
33
|
+
};
|
|
34
|
+
exports.default = WhoAmI;
|