opal-security 2.1.0 → 2.1.1
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 +91 -48
- package/lib/commands/aws/identity.js +2 -1
- package/lib/commands/curl-example.js +2 -1
- package/lib/commands/iam-roles/start.d.ts +1 -0
- package/lib/commands/iam-roles/start.js +9 -10
- package/lib/commands/kube-roles/start.d.ts +5 -4
- package/lib/commands/kube-roles/start.js +10 -14
- package/lib/commands/login.js +8 -6
- package/lib/commands/logout.js +2 -1
- package/lib/commands/postgres-instances/start.d.ts +2 -0
- package/lib/commands/postgres-instances/start.js +49 -41
- package/lib/commands/resources/get.d.ts +2 -2
- package/lib/commands/resources/get.js +3 -5
- package/lib/commands/set-custom-header.js +2 -1
- package/lib/commands/set-token.js +2 -1
- package/lib/commands/set-url.js +4 -2
- package/lib/commands/ssh/copyFrom.js +7 -12
- package/lib/commands/ssh/copyTo.js +7 -12
- package/lib/commands/ssh/start.d.ts +4 -3
- package/lib/commands/ssh/start.js +9 -10
- package/lib/lib/apollo.d.ts +1 -1
- package/lib/lib/apollo.js +38 -43
- package/lib/lib/flags.d.ts +8 -0
- package/lib/lib/flags.js +26 -0
- package/lib/lib/resources.js +3 -3
- package/lib/lib/sessions.d.ts +1 -1
- package/lib/lib/sessions.js +28 -17
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- /package/lib/lib/{common.d.ts → util.d.ts} +0 -0
- /package/lib/lib/{common.js → util.js} +0 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ $ npm install -g opal-security
|
|
|
22
22
|
$ opal COMMAND
|
|
23
23
|
running command...
|
|
24
24
|
$ opal (-v|--version|version)
|
|
25
|
-
opal-security/2.1.
|
|
25
|
+
opal-security/2.1.1 darwin-x64 node-v14.16.1
|
|
26
26
|
$ opal --help [COMMAND]
|
|
27
27
|
USAGE
|
|
28
28
|
$ opal COMMAND
|
|
@@ -88,7 +88,7 @@ EXAMPLE
|
|
|
88
88
|
opal aws:identity
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
_See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
91
|
+
_See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/aws/identity.ts)_
|
|
92
92
|
|
|
93
93
|
## `opal curl-example`
|
|
94
94
|
|
|
@@ -102,7 +102,7 @@ OPTIONS
|
|
|
102
102
|
-h, --help show CLI help
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
_See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
105
|
+
_See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/curl-example.ts)_
|
|
106
106
|
|
|
107
107
|
## `opal help [COMMAND]`
|
|
108
108
|
|
|
@@ -131,9 +131,16 @@ USAGE
|
|
|
131
131
|
|
|
132
132
|
OPTIONS
|
|
133
133
|
-h, --help show CLI help
|
|
134
|
-
|
|
134
|
+
|
|
135
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g.
|
|
136
|
+
https://opal.dev/resources/[ID]
|
|
137
|
+
|
|
138
|
+
-r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
|
|
139
|
+
|
|
140
|
+
-s, --sessionId=sessionId The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
141
|
+
web flow.
|
|
142
|
+
|
|
135
143
|
--profileName=profileName Uses a custom AWS profile name for the IAM role. Default value is the role's name.
|
|
136
|
-
--sessionId=sessionId SessionId of a session that has already been created via the web flow.
|
|
137
144
|
|
|
138
145
|
EXAMPLES
|
|
139
146
|
opal iam-roles:start
|
|
@@ -141,7 +148,7 @@ EXAMPLES
|
|
|
141
148
|
opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
|
|
142
149
|
```
|
|
143
150
|
|
|
144
|
-
_See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
151
|
+
_See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/iam-roles/start.ts)_
|
|
145
152
|
|
|
146
153
|
## `opal kube-roles:start`
|
|
147
154
|
|
|
@@ -152,10 +159,17 @@ USAGE
|
|
|
152
159
|
$ opal kube-roles:start
|
|
153
160
|
|
|
154
161
|
OPTIONS
|
|
155
|
-
-
|
|
156
|
-
--
|
|
157
|
-
|
|
158
|
-
--
|
|
162
|
+
-a, --accessLevelRemoteId=accessLevelRemoteId The remote ID of the access level with which to access the resource.
|
|
163
|
+
-h, --help show CLI help
|
|
164
|
+
|
|
165
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g.
|
|
166
|
+
https://opal.dev/resources/[ID]
|
|
167
|
+
|
|
168
|
+
-r, --refresh Starts a new session even if one already exists. Useful if a session is
|
|
169
|
+
about to expire.
|
|
170
|
+
|
|
171
|
+
-s, --sessionId=sessionId The Opal ID of the session to connect to. Uses an existing session that
|
|
172
|
+
was created via the web flow.
|
|
159
173
|
|
|
160
174
|
EXAMPLES
|
|
161
175
|
opal kube-roles:start
|
|
@@ -164,7 +178,7 @@ EXAMPLES
|
|
|
164
178
|
"arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
|
|
165
179
|
```
|
|
166
180
|
|
|
167
|
-
_See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
181
|
+
_See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/kube-roles/start.ts)_
|
|
168
182
|
|
|
169
183
|
## `opal login`
|
|
170
184
|
|
|
@@ -182,7 +196,7 @@ EXAMPLE
|
|
|
182
196
|
$ opal login
|
|
183
197
|
```
|
|
184
198
|
|
|
185
|
-
_See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
199
|
+
_See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/login.ts)_
|
|
186
200
|
|
|
187
201
|
## `opal logout`
|
|
188
202
|
|
|
@@ -199,29 +213,42 @@ EXAMPLE
|
|
|
199
213
|
$ opal logout
|
|
200
214
|
```
|
|
201
215
|
|
|
202
|
-
_See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
216
|
+
_See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/logout.ts)_
|
|
203
217
|
|
|
204
218
|
## `opal postgres-instances:start`
|
|
205
219
|
|
|
206
|
-
Starts a session to
|
|
220
|
+
Starts a session to connect to a Postgres database.
|
|
207
221
|
|
|
208
222
|
```
|
|
209
223
|
USAGE
|
|
210
224
|
$ opal postgres-instances:start
|
|
211
225
|
|
|
212
226
|
OPTIONS
|
|
213
|
-
-
|
|
214
|
-
--
|
|
215
|
-
|
|
216
|
-
--
|
|
227
|
+
-a, --accessLevelRemoteId=accessLevelRemoteId The remote ID of the access level with which to access the resource.
|
|
228
|
+
-h, --help show CLI help
|
|
229
|
+
|
|
230
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g.
|
|
231
|
+
https://opal.dev/resources/[ID]
|
|
232
|
+
|
|
233
|
+
-r, --refresh Starts a new session even if one already exists. Useful if a session is
|
|
234
|
+
about to expire.
|
|
235
|
+
|
|
236
|
+
-s, --sessionId=sessionId The Opal ID of the session to connect to. Uses an existing session that
|
|
237
|
+
was created via the web flow.
|
|
238
|
+
|
|
239
|
+
--action=open|psql|view Method of connecting to the database.
|
|
240
|
+
- open: Open external database app
|
|
241
|
+
- psql: Start psql session in shell
|
|
242
|
+
- view: View connection configuration details
|
|
217
243
|
|
|
218
244
|
EXAMPLES
|
|
219
245
|
opal postgres-instances:start
|
|
220
246
|
opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
221
|
-
opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId
|
|
247
|
+
opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess
|
|
248
|
+
opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
|
|
222
249
|
```
|
|
223
250
|
|
|
224
|
-
_See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
251
|
+
_See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/postgres-instances/start.ts)_
|
|
225
252
|
|
|
226
253
|
## `opal resources:get`
|
|
227
254
|
|
|
@@ -232,14 +259,14 @@ USAGE
|
|
|
232
259
|
$ opal resources:get
|
|
233
260
|
|
|
234
261
|
OPTIONS
|
|
235
|
-
-h, --help
|
|
236
|
-
--id=id
|
|
262
|
+
-h, --help show CLI help
|
|
263
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
|
|
237
264
|
|
|
238
265
|
EXAMPLE
|
|
239
266
|
opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
|
|
240
267
|
```
|
|
241
268
|
|
|
242
|
-
_See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
269
|
+
_See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/resources/get.ts)_
|
|
243
270
|
|
|
244
271
|
## `opal set-custom-header`
|
|
245
272
|
|
|
@@ -257,7 +284,7 @@ EXAMPLE
|
|
|
257
284
|
$ opal set-custom-header --header 'cf-access-token: $TOKEN'
|
|
258
285
|
```
|
|
259
286
|
|
|
260
|
-
_See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
287
|
+
_See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/set-custom-header.ts)_
|
|
261
288
|
|
|
262
289
|
## `opal set-token`
|
|
263
290
|
|
|
@@ -274,7 +301,7 @@ EXAMPLE
|
|
|
274
301
|
$ opal set-token
|
|
275
302
|
```
|
|
276
303
|
|
|
277
|
-
_See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
304
|
+
_See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/set-token.ts)_
|
|
278
305
|
|
|
279
306
|
## `opal set-url [URL]`
|
|
280
307
|
|
|
@@ -295,7 +322,7 @@ EXAMPLE
|
|
|
295
322
|
$ opal set-url
|
|
296
323
|
```
|
|
297
324
|
|
|
298
|
-
_See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
325
|
+
_See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/set-url.ts)_
|
|
299
326
|
|
|
300
327
|
## `opal ssh:copyFrom`
|
|
301
328
|
|
|
@@ -306,23 +333,28 @@ USAGE
|
|
|
306
333
|
$ opal ssh:copyFrom
|
|
307
334
|
|
|
308
335
|
OPTIONS
|
|
309
|
-
-h, --help
|
|
310
|
-
|
|
311
|
-
--id=id The ID of the
|
|
312
|
-
|
|
336
|
+
-h, --help show CLI help
|
|
337
|
+
|
|
338
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g.
|
|
339
|
+
https://opal.dev/resources/[ID]
|
|
340
|
+
|
|
341
|
+
-s, --sessionId=sessionId The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
342
|
+
web flow.
|
|
313
343
|
|
|
314
|
-
--
|
|
315
|
-
support one file or directory at a time.
|
|
344
|
+
--dest=dest [default: .] The directory you want your files to be copied to.
|
|
316
345
|
|
|
317
|
-
--
|
|
318
|
-
|
|
346
|
+
--src=src (required) The directory or file you would like to copy over SCP. Note we only support one
|
|
347
|
+
file or directory at a time.
|
|
348
|
+
|
|
349
|
+
--user=user [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have
|
|
350
|
+
access to each other's home directory.
|
|
319
351
|
|
|
320
352
|
EXAMPLES
|
|
321
353
|
opal ssh:copyFrom --src instance/dir --dest my/dir
|
|
322
354
|
opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
323
355
|
```
|
|
324
356
|
|
|
325
|
-
_See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
357
|
+
_See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/ssh/copyFrom.ts)_
|
|
326
358
|
|
|
327
359
|
## `opal ssh:copyTo`
|
|
328
360
|
|
|
@@ -333,23 +365,28 @@ USAGE
|
|
|
333
365
|
$ opal ssh:copyTo
|
|
334
366
|
|
|
335
367
|
OPTIONS
|
|
336
|
-
-h, --help
|
|
337
|
-
|
|
338
|
-
--id=id The ID of the
|
|
339
|
-
|
|
368
|
+
-h, --help show CLI help
|
|
369
|
+
|
|
370
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g.
|
|
371
|
+
https://opal.dev/resources/[ID]
|
|
340
372
|
|
|
341
|
-
--
|
|
342
|
-
|
|
373
|
+
-s, --sessionId=sessionId The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
374
|
+
web flow.
|
|
343
375
|
|
|
344
|
-
--
|
|
345
|
-
|
|
376
|
+
--dest=dest [default: .] The directory you want your files to be copied to.
|
|
377
|
+
|
|
378
|
+
--src=src (required) The directory or file you would like to copy over SCP. Note we only support one
|
|
379
|
+
file or directory at a time.
|
|
380
|
+
|
|
381
|
+
--user=user [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have
|
|
382
|
+
access to each other's home directory.
|
|
346
383
|
|
|
347
384
|
EXAMPLES
|
|
348
385
|
opal ssh:copyTo --src my/dir --dest instance/dir
|
|
349
386
|
opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
350
387
|
```
|
|
351
388
|
|
|
352
|
-
_See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
389
|
+
_See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/ssh/copyTo.ts)_
|
|
353
390
|
|
|
354
391
|
## `opal ssh:start`
|
|
355
392
|
|
|
@@ -360,14 +397,20 @@ USAGE
|
|
|
360
397
|
$ opal ssh:start
|
|
361
398
|
|
|
362
399
|
OPTIONS
|
|
363
|
-
-h, --help
|
|
364
|
-
|
|
365
|
-
--
|
|
400
|
+
-h, --help show CLI help
|
|
401
|
+
|
|
402
|
+
-i, --id=id The Opal ID of the resource. You can find this from the URL, e.g.
|
|
403
|
+
https://opal.dev/resources/[ID]
|
|
404
|
+
|
|
405
|
+
-r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
|
|
406
|
+
|
|
407
|
+
-s, --sessionId=sessionId The Opal ID of the session to connect to. Uses an existing session that was created via the
|
|
408
|
+
web flow.
|
|
366
409
|
|
|
367
410
|
EXAMPLES
|
|
368
411
|
opal ssh:start
|
|
369
412
|
opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
|
|
370
413
|
```
|
|
371
414
|
|
|
372
|
-
_See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.
|
|
415
|
+
_See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v2.1.1/src/commands/ssh/start.ts)_
|
|
373
416
|
<!-- commandsstop -->
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const command_1 = require("@oclif/command");
|
|
4
4
|
const cmd_1 = require("../../lib/cmd");
|
|
5
|
+
const flags_1 = require("../../lib/flags");
|
|
5
6
|
class Identity extends command_1.Command {
|
|
6
7
|
async run() {
|
|
7
8
|
cmd_1.setMostRecentCommand(this);
|
|
@@ -13,5 +14,5 @@ exports.default = Identity;
|
|
|
13
14
|
Identity.description = 'Gets the current caller identity for the "opal" AWS profile.';
|
|
14
15
|
Identity.examples = ['opal aws:identity'];
|
|
15
16
|
Identity.flags = {
|
|
16
|
-
help:
|
|
17
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
17
18
|
};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const command_1 = require("@oclif/command");
|
|
4
4
|
const config_1 = require("../lib/config");
|
|
5
5
|
const credentials_1 = require("../lib/credentials");
|
|
6
|
+
const flags_1 = require("../lib/flags");
|
|
6
7
|
class CurlExample extends command_1.Command {
|
|
7
8
|
async run() {
|
|
8
9
|
const accessToken = await credentials_1.cred.accessToken;
|
|
@@ -21,5 +22,5 @@ curl -v ${url}/query \\
|
|
|
21
22
|
exports.default = CurlExample;
|
|
22
23
|
CurlExample.description = 'Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.';
|
|
23
24
|
CurlExample.flags = {
|
|
24
|
-
help:
|
|
25
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
25
26
|
};
|
|
@@ -6,6 +6,7 @@ export default class StartIAMRoleSession extends Command {
|
|
|
6
6
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
7
|
id: flags.IOptionFlag<string | undefined>;
|
|
8
8
|
sessionId: flags.IOptionFlag<string | undefined>;
|
|
9
|
+
refresh: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
9
10
|
profileName: flags.IOptionFlag<string | undefined>;
|
|
10
11
|
};
|
|
11
12
|
run(): Promise<void>;
|
|
@@ -8,6 +8,7 @@ const aws_1 = require("../../lib/aws");
|
|
|
8
8
|
const resources_1 = require("../../lib/resources");
|
|
9
9
|
const get_1 = require("../../commands/resources/get");
|
|
10
10
|
const sessions_1 = require("../../lib/sessions");
|
|
11
|
+
const flags_1 = require("../../lib/flags");
|
|
11
12
|
const IamSessionMetadataFragment = `
|
|
12
13
|
... on AwsIamFederatedRoleSession {
|
|
13
14
|
awsAccessKeyId
|
|
@@ -20,6 +21,9 @@ class StartIAMRoleSession extends command_1.Command {
|
|
|
20
21
|
async run() {
|
|
21
22
|
cmd_1.setMostRecentCommand(this);
|
|
22
23
|
const { flags } = this.parse(StartIAMRoleSession);
|
|
24
|
+
if (flags.sessionId && flags.refresh) {
|
|
25
|
+
return apollo_1.handleError(this, 'Cannot use both --sessionId and --refresh');
|
|
26
|
+
}
|
|
23
27
|
let roleId = flags.id;
|
|
24
28
|
let roleName = null;
|
|
25
29
|
const sessionId = flags.sessionId;
|
|
@@ -50,7 +54,7 @@ class StartIAMRoleSession extends command_1.Command {
|
|
|
50
54
|
if (flags.profileName && flags.profileName !== '') {
|
|
51
55
|
roleName = flags.profileName;
|
|
52
56
|
}
|
|
53
|
-
const session = await sessions_1.getOrCreateSession(this, roleId, resources_1.DEFAULT_ACCESS_LEVEL, sessionId, IamSessionMetadataFragment);
|
|
57
|
+
const session = await sessions_1.getOrCreateSession(this, roleId, resources_1.DEFAULT_ACCESS_LEVEL, sessionId, IamSessionMetadataFragment, flags.refresh);
|
|
54
58
|
const metadata = session.metadata;
|
|
55
59
|
switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
|
|
56
60
|
case 'AwsIamFederatedRoleSession': {
|
|
@@ -74,15 +78,10 @@ StartIAMRoleSession.examples = [
|
|
|
74
78
|
'opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"',
|
|
75
79
|
];
|
|
76
80
|
StartIAMRoleSession.flags = {
|
|
77
|
-
help:
|
|
78
|
-
id:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}),
|
|
82
|
-
sessionId: command_1.flags.string({
|
|
83
|
-
multiple: false,
|
|
84
|
-
description: 'SessionId of a session that has already been created via the web flow.',
|
|
85
|
-
}),
|
|
81
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
82
|
+
id: flags_1.SHARED_FLAGS.id,
|
|
83
|
+
sessionId: flags_1.SHARED_FLAGS.sessionId,
|
|
84
|
+
refresh: flags_1.SHARED_FLAGS.refresh,
|
|
86
85
|
profileName: command_1.flags.string({
|
|
87
86
|
multiple: false,
|
|
88
87
|
description: 'Uses a custom AWS profile name for the IAM role. Default value is the role\'s name.',
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Command
|
|
1
|
+
import { Command } from '@oclif/command';
|
|
2
2
|
export default class StartKubeIAMRoleSession extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
-
id: flags.IOptionFlag<string | undefined>;
|
|
8
|
-
accessLevelRemoteId: flags.IOptionFlag<string | undefined>;
|
|
9
|
-
sessionId: flags.IOptionFlag<string | undefined>;
|
|
7
|
+
id: import("@oclif/command/lib/flags").IOptionFlag<string | undefined>;
|
|
8
|
+
accessLevelRemoteId: import("@oclif/command/lib/flags").IOptionFlag<string | undefined>;
|
|
9
|
+
sessionId: import("@oclif/command/lib/flags").IOptionFlag<string | undefined>;
|
|
10
|
+
refresh: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
run(): Promise<void>;
|
|
12
13
|
}
|
|
@@ -6,6 +6,7 @@ const apollo_1 = require("../../lib/apollo");
|
|
|
6
6
|
const aws_1 = require("../../lib/aws");
|
|
7
7
|
const resources_1 = require("../../lib/resources");
|
|
8
8
|
const sessions_1 = require("../../lib/sessions");
|
|
9
|
+
const flags_1 = require("../../lib/flags");
|
|
9
10
|
const EksSessionMetadataFragment = `
|
|
10
11
|
... on AwsIamFederatedEksSession {
|
|
11
12
|
awsAccessKeyId
|
|
@@ -18,6 +19,9 @@ class StartKubeIAMRoleSession extends command_1.Command {
|
|
|
18
19
|
async run() {
|
|
19
20
|
cmd_1.setMostRecentCommand(this);
|
|
20
21
|
const { flags } = this.parse(StartKubeIAMRoleSession);
|
|
22
|
+
if (flags.sessionId && flags.refresh) {
|
|
23
|
+
return apollo_1.handleError(this, 'Cannot use both --sessionId and --refresh');
|
|
24
|
+
}
|
|
21
25
|
let clusterId = flags.id;
|
|
22
26
|
const sessionId = flags.sessionId;
|
|
23
27
|
if (!clusterId) {
|
|
@@ -32,7 +36,7 @@ class StartKubeIAMRoleSession extends command_1.Command {
|
|
|
32
36
|
if (!accessLevel) {
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
|
-
const session = await sessions_1.getOrCreateSession(this, clusterId, accessLevel, sessionId, EksSessionMetadataFragment);
|
|
39
|
+
const session = await sessions_1.getOrCreateSession(this, clusterId, accessLevel, sessionId, EksSessionMetadataFragment, flags.refresh);
|
|
36
40
|
const metadata = session.metadata;
|
|
37
41
|
switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
|
|
38
42
|
case 'AwsIamFederatedEksSession': {
|
|
@@ -58,17 +62,9 @@ StartKubeIAMRoleSession.examples = [
|
|
|
58
62
|
'opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"',
|
|
59
63
|
];
|
|
60
64
|
StartKubeIAMRoleSession.flags = {
|
|
61
|
-
help:
|
|
62
|
-
id:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
accessLevelRemoteId: command_1.flags.string({
|
|
67
|
-
multiple: false,
|
|
68
|
-
description: 'The remote ID of the access level with which to access the cluster.',
|
|
69
|
-
}),
|
|
70
|
-
sessionId: command_1.flags.string({
|
|
71
|
-
multiple: false,
|
|
72
|
-
description: 'SessionId of a session that has already been created via the web flow.',
|
|
73
|
-
}),
|
|
65
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
66
|
+
id: flags_1.SHARED_FLAGS.id,
|
|
67
|
+
accessLevelRemoteId: flags_1.SHARED_FLAGS.accessLevelRemoteId,
|
|
68
|
+
sessionId: flags_1.SHARED_FLAGS.sessionId,
|
|
69
|
+
refresh: flags_1.SHARED_FLAGS.refresh,
|
|
74
70
|
};
|
package/lib/commands/login.js
CHANGED
|
@@ -10,7 +10,8 @@ const credentials_1 = require("../lib/credentials");
|
|
|
10
10
|
const inquirer = require("inquirer");
|
|
11
11
|
const handler_1 = require("../handler");
|
|
12
12
|
const config_1 = require("../lib/config");
|
|
13
|
-
const
|
|
13
|
+
const util_1 = require("../lib/util");
|
|
14
|
+
const flags_1 = require("../lib/flags");
|
|
14
15
|
const ISSUER_PROD = 'https://auth.opal.dev';
|
|
15
16
|
const ISSUER_DEV = 'https://authdev.opal.dev';
|
|
16
17
|
const GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:device_code';
|
|
@@ -59,8 +60,8 @@ class Login extends command_1.Command {
|
|
|
59
60
|
await credentials_1.cred.removeCredentials(-1);
|
|
60
61
|
}
|
|
61
62
|
this.log('Welcome to Opal! ⚡️\n');
|
|
62
|
-
this.log('
|
|
63
|
-
this.log('If this is
|
|
63
|
+
this.log('Connecting to Opal server URL:', configData[config_1.urlKey]);
|
|
64
|
+
this.log('If this is incorrect, please run `opal set-url --help`\n');
|
|
64
65
|
if (email) {
|
|
65
66
|
this.log('Signing in as: ' + email + ' - to use a different account, run `opal login --email [EMAIL]`');
|
|
66
67
|
}
|
|
@@ -80,7 +81,8 @@ class Login extends command_1.Command {
|
|
|
80
81
|
variables: { input: { email } },
|
|
81
82
|
});
|
|
82
83
|
if (error) {
|
|
83
|
-
this.log('
|
|
84
|
+
this.log(''); // Intentional newline
|
|
85
|
+
return apollo_1.handleError(this, 'Could not connect to Opal. Did you set the right URL? (`opal set-url --help`)');
|
|
84
86
|
}
|
|
85
87
|
const signInOrganizations = (_b = (_a = signInOrganizationsResponse === null || signInOrganizationsResponse === void 0 ? void 0 : signInOrganizationsResponse.data) === null || _a === void 0 ? void 0 : _a.signInMethod) === null || _b === void 0 ? void 0 : _b.signInOrganizations;
|
|
86
88
|
if (signInOrganizations && signInOrganizations.length > 0) {
|
|
@@ -133,7 +135,7 @@ class Login extends command_1.Command {
|
|
|
133
135
|
this.log(` User Code: ${handle.user_code}\n`);
|
|
134
136
|
// Wait before opening the browser window to ensure the user has time to
|
|
135
137
|
// see the User Code.
|
|
136
|
-
await
|
|
138
|
+
await util_1.sleep(1000);
|
|
137
139
|
await open(handle.verification_uri_complete, { wait: false });
|
|
138
140
|
const tokenSet = await handle.poll();
|
|
139
141
|
const userInfo = await client.userinfo(tokenSet);
|
|
@@ -160,7 +162,7 @@ exports.default = Login;
|
|
|
160
162
|
Login.description = 'Authenticates you with the Opal server.';
|
|
161
163
|
Login.examples = ['$ opal login'];
|
|
162
164
|
Login.flags = {
|
|
163
|
-
help:
|
|
165
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
164
166
|
email: command_1.flags.string({
|
|
165
167
|
multiple: false,
|
|
166
168
|
description: 'Email address to login with.',
|
package/lib/commands/logout.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const command_1 = require("@oclif/command");
|
|
4
4
|
const credentials_1 = require("../lib/credentials");
|
|
5
|
+
const flags_1 = require("../lib/flags");
|
|
5
6
|
class Logout extends command_1.Command {
|
|
6
7
|
async run() {
|
|
7
8
|
try {
|
|
@@ -17,6 +18,6 @@ exports.default = Logout;
|
|
|
17
18
|
Logout.description = 'Clears locally stored Opal server authentication credentials.';
|
|
18
19
|
Logout.examples = ['$ opal logout'];
|
|
19
20
|
Logout.flags = {
|
|
20
|
-
help:
|
|
21
|
+
help: flags_1.SHARED_FLAGS.help,
|
|
21
22
|
};
|
|
22
23
|
Logout.args = [];
|
|
@@ -7,6 +7,8 @@ export default class StartPostgresInstanceSession extends Command {
|
|
|
7
7
|
id: flags.IOptionFlag<string | undefined>;
|
|
8
8
|
accessLevelRemoteId: flags.IOptionFlag<string | undefined>;
|
|
9
9
|
sessionId: flags.IOptionFlag<string | undefined>;
|
|
10
|
+
refresh: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
|
+
action: flags.IOptionFlag<string | undefined>;
|
|
10
12
|
};
|
|
11
13
|
run(): Promise<void>;
|
|
12
14
|
}
|