@flowcore/cli-plugin-iam 1.7.0 → 1.8.0

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.
Files changed (46) hide show
  1. package/README.md +396 -7
  2. package/bin/dev.js +2 -2
  3. package/bin/run.js +2 -2
  4. package/dist/commands/assign/policy.d.ts +16 -0
  5. package/dist/commands/assign/policy.js +124 -0
  6. package/dist/commands/assign/role.d.ts +15 -0
  7. package/dist/commands/assign/role.js +98 -0
  8. package/dist/commands/create/policy.d.ts +16 -0
  9. package/dist/commands/create/policy.js +110 -0
  10. package/dist/commands/create/role.d.ts +14 -0
  11. package/dist/commands/create/role.js +78 -0
  12. package/dist/commands/edit/policy.js +3 -3
  13. package/dist/commands/edit/role.js +3 -3
  14. package/dist/commands/get/key-policies.d.ts +13 -0
  15. package/dist/commands/get/key-policies.js +79 -0
  16. package/dist/commands/get/key-roles.d.ts +13 -0
  17. package/dist/commands/get/key-roles.js +75 -0
  18. package/dist/commands/get/user-policies.d.ts +14 -0
  19. package/dist/commands/get/user-policies.js +94 -0
  20. package/dist/commands/get/user-roles.d.ts +14 -0
  21. package/dist/commands/get/user-roles.js +90 -0
  22. package/dist/commands/unassign/policy.d.ts +17 -0
  23. package/dist/commands/unassign/policy.js +143 -0
  24. package/dist/commands/unassign/role.d.ts +16 -0
  25. package/dist/commands/unassign/role.js +117 -0
  26. package/dist/commands/validate/key.d.ts +15 -0
  27. package/dist/commands/validate/key.js +106 -0
  28. package/dist/commands/validate/user.d.ts +15 -0
  29. package/dist/commands/validate/user.js +106 -0
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/resource-types/iam-api-version.js +2 -2
  33. package/dist/resource-types/policy.resource.js +3 -3
  34. package/dist/resource-types/role-binding.resource.d.ts +4 -4
  35. package/dist/resource-types/role.resource.d.ts +3 -3
  36. package/dist/resource-types/role.resource.js +2 -2
  37. package/dist/utils/combine-merge.util.d.ts +1 -1
  38. package/dist/utils/combine-merge.util.js +1 -1
  39. package/dist/utils/error-message.util.d.ts +1 -0
  40. package/dist/utils/error-message.util.js +4 -0
  41. package/dist/utils/fetch-manifest.util.js +2 -2
  42. package/dist/utils/read-pipe.util.js +5 -5
  43. package/oclif.manifest.json +964 -69
  44. package/package.json +18 -11
  45. package/.npmrc +0 -1
  46. package/CHANGELOG.md +0 -132
package/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @flowcore/cli-plugin-iam
18
18
  $ iam COMMAND
19
19
  running command...
20
20
  $ iam (--version)
21
- @flowcore/cli-plugin-iam/1.7.0 linux-x64 node-v20.16.0
21
+ @flowcore/cli-plugin-iam/1.8.0 linux-x64 node-v20.20.0
22
22
  $ iam --help [COMMAND]
23
23
  USAGE
24
24
  $ iam COMMAND
@@ -27,12 +27,152 @@ USAGE
27
27
  <!-- usagestop -->
28
28
  # Commands
29
29
  <!-- commands -->
30
+ * [`iam assign policy POLICY_NAME`](#iam-assign-policy-policy_name)
31
+ * [`iam assign role ROLE_NAME`](#iam-assign-role-role_name)
32
+ * [`iam create policy NAME`](#iam-create-policy-name)
33
+ * [`iam create role NAME`](#iam-create-role-name)
30
34
  * [`iam delete policy NAME`](#iam-delete-policy-name)
31
35
  * [`iam delete role NAME`](#iam-delete-role-name)
32
36
  * [`iam edit policy NAME`](#iam-edit-policy-name)
33
37
  * [`iam edit role NAME`](#iam-edit-role-name)
38
+ * [`iam get key-policies KEY_ID`](#iam-get-key-policies-key_id)
39
+ * [`iam get key-roles KEY_ID`](#iam-get-key-roles-key_id)
34
40
  * [`iam get policy [NAME]`](#iam-get-policy-name)
35
41
  * [`iam get role [NAME]`](#iam-get-role-name)
42
+ * [`iam get user-policies USER_ID`](#iam-get-user-policies-user_id)
43
+ * [`iam get user-roles USER_ID`](#iam-get-user-roles-user_id)
44
+ * [`iam unassign policy POLICY_NAME`](#iam-unassign-policy-policy_name)
45
+ * [`iam unassign role ROLE_NAME`](#iam-unassign-role-role_name)
46
+ * [`iam validate key KEY_ID`](#iam-validate-key-key_id)
47
+ * [`iam validate user USER_ID`](#iam-validate-user-user_id)
48
+
49
+ ## `iam assign policy POLICY_NAME`
50
+
51
+ Assign an IAM policy to a user, API key, or role. Exactly one of --user, --key, or --role must be specified
52
+
53
+ ```
54
+ USAGE
55
+ $ iam assign policy POLICY_NAME -t <value> [--profile <value>] [-j] [--key <value> | --user <value> | --role
56
+ <value>]
57
+
58
+ ARGUMENTS
59
+ POLICY_NAME The name of the policy to assign
60
+
61
+ FLAGS
62
+ -j, --json Output result as JSON
63
+ -t, --tenant=<value> (required) The tenant (organization slug) containing the policy
64
+ --key=<value> The API key ID to assign the policy to
65
+ --profile=<value> Specify the configuration profile to use
66
+ --role=<value> The role name to assign the policy to
67
+ --user=<value> The user ID to assign the policy to
68
+
69
+ DESCRIPTION
70
+ Assign an IAM policy to a user, API key, or role. Exactly one of --user, --key, or --role must be specified
71
+
72
+ EXAMPLES
73
+ $ flowcore iam assign policy read-access --user "auth0|abc123" -t my-org
74
+
75
+ $ flowcore iam assign policy read-access --key "550e8400-e29b-41d4-a716-446655440000" -t my-org
76
+
77
+ $ flowcore iam assign policy read-access --role data-reader -t my-org
78
+
79
+ $ flowcore iam assign policy read-access --user "auth0|abc123" -t my-org -j
80
+ ```
81
+
82
+ _See code: [src/commands/assign/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/assign/policy.ts)_
83
+
84
+ ## `iam assign role ROLE_NAME`
85
+
86
+ Assign an IAM role to a user or API key. Exactly one of --user or --key must be specified
87
+
88
+ ```
89
+ USAGE
90
+ $ iam assign role ROLE_NAME -t <value> [--profile <value>] [-j] [--key <value> | --user <value>]
91
+
92
+ ARGUMENTS
93
+ ROLE_NAME The name of the role to assign
94
+
95
+ FLAGS
96
+ -j, --json Output result as JSON
97
+ -t, --tenant=<value> (required) The tenant (organization slug) containing the role
98
+ --key=<value> The API key ID to assign the role to
99
+ --profile=<value> Specify the configuration profile to use
100
+ --user=<value> The user ID to assign the role to
101
+
102
+ DESCRIPTION
103
+ Assign an IAM role to a user or API key. Exactly one of --user or --key must be specified
104
+
105
+ EXAMPLES
106
+ $ flowcore iam assign role data-reader --user "auth0|abc123" -t my-org
107
+
108
+ $ flowcore iam assign role data-reader --key "550e8400-e29b-41d4-a716-446655440000" -t my-org
109
+
110
+ $ flowcore iam assign role data-reader --user "auth0|abc123" -t my-org -j
111
+ ```
112
+
113
+ _See code: [src/commands/assign/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/assign/role.ts)_
114
+
115
+ ## `iam create policy NAME`
116
+
117
+ Create a new IAM policy with the specified name, version, and policy documents defining resource access rules
118
+
119
+ ```
120
+ USAGE
121
+ $ iam create policy NAME --documents <value> -t <value> --version <value> [--profile <value>] [--description
122
+ <value>] [-j]
123
+
124
+ ARGUMENTS
125
+ NAME The name of the policy to create
126
+
127
+ FLAGS
128
+ -j, --json Output result as JSON
129
+ -t, --tenant=<value> (required) The tenant (organization slug) to create the policy in
130
+ --description=<value> A description of the policy
131
+ --documents=<value> (required) JSON array of policy documents, each with "resource" and "action" fields. Use
132
+ "-" to read from stdin
133
+ --profile=<value> Specify the configuration profile to use
134
+ --version=<value> (required) The version of the policy (e.g. 2024-01-01)
135
+
136
+ DESCRIPTION
137
+ Create a new IAM policy with the specified name, version, and policy documents defining resource access rules
138
+
139
+ EXAMPLES
140
+ $ flowcore iam create policy read-access -t my-org --version "2024-01-01" --documents '[{"resource":"frn::my-org:data-core/*","action":["read","fetch"]}]'
141
+
142
+ $ cat docs.json | flowcore iam create policy read-access -t my-org --version "2024-01-01" --documents -
143
+
144
+ $ flowcore iam create policy admin-access -t my-org --version "2024-01-01" --description "Full admin access" --documents '[{"resource":"frn::my-org:*","action":"*"}]' -j
145
+ ```
146
+
147
+ _See code: [src/commands/create/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/create/policy.ts)_
148
+
149
+ ## `iam create role NAME`
150
+
151
+ Create a new IAM role with the specified name and optional description
152
+
153
+ ```
154
+ USAGE
155
+ $ iam create role NAME -t <value> [--profile <value>] [--description <value>] [-j]
156
+
157
+ ARGUMENTS
158
+ NAME The name of the role to create
159
+
160
+ FLAGS
161
+ -j, --json Output result as JSON
162
+ -t, --tenant=<value> (required) The tenant (organization slug) to create the role in
163
+ --description=<value> A description of the role
164
+ --profile=<value> Specify the configuration profile to use
165
+
166
+ DESCRIPTION
167
+ Create a new IAM role with the specified name and optional description
168
+
169
+ EXAMPLES
170
+ $ flowcore iam create role data-reader -t my-org --description "Read-only data access"
171
+
172
+ $ flowcore iam create role admin -t my-org -j
173
+ ```
174
+
175
+ _See code: [src/commands/create/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/create/role.ts)_
36
176
 
37
177
  ## `iam delete policy NAME`
38
178
 
@@ -55,7 +195,7 @@ DESCRIPTION
55
195
  Delete a policy
56
196
  ```
57
197
 
58
- _See code: [src/commands/delete/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.7.0/src/commands/delete/policy.ts)_
198
+ _See code: [src/commands/delete/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/delete/policy.ts)_
59
199
 
60
200
  ## `iam delete role NAME`
61
201
 
@@ -78,7 +218,7 @@ DESCRIPTION
78
218
  Delete a role
79
219
  ```
80
220
 
81
- _See code: [src/commands/delete/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.7.0/src/commands/delete/role.ts)_
221
+ _See code: [src/commands/delete/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/delete/role.ts)_
82
222
 
83
223
  ## `iam edit policy NAME`
84
224
 
@@ -104,7 +244,7 @@ EXAMPLES
104
244
  $ FC_EDITOR=code flowcore iam edit policy my-policy -t my-tenant
105
245
  ```
106
246
 
107
- _See code: [src/commands/edit/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.7.0/src/commands/edit/policy.ts)_
247
+ _See code: [src/commands/edit/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/edit/policy.ts)_
108
248
 
109
249
  ## `iam edit role NAME`
110
250
 
@@ -130,7 +270,65 @@ EXAMPLES
130
270
  $ FC_EDITOR=code flowcore iam edit role my-role -t my-tenant
131
271
  ```
132
272
 
133
- _See code: [src/commands/edit/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.7.0/src/commands/edit/role.ts)_
273
+ _See code: [src/commands/edit/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/edit/role.ts)_
274
+
275
+ ## `iam get key-policies KEY_ID`
276
+
277
+ List all IAM policies assigned to a specific API key
278
+
279
+ ```
280
+ USAGE
281
+ $ iam get key-policies KEY_ID [--profile <value>] [-j] [-w]
282
+
283
+ ARGUMENTS
284
+ KEY_ID The API key ID to get policies for
285
+
286
+ FLAGS
287
+ -j, --json Output result as JSON
288
+ -w, --wide Show additional columns in table output
289
+ --profile=<value> Specify the configuration profile to use
290
+
291
+ DESCRIPTION
292
+ List all IAM policies assigned to a specific API key
293
+
294
+ EXAMPLES
295
+ $ flowcore iam get key-policies "550e8400-e29b-41d4-a716-446655440000"
296
+
297
+ $ flowcore iam get key-policies "550e8400-e29b-41d4-a716-446655440000" -j
298
+
299
+ $ flowcore iam get key-policies "550e8400-e29b-41d4-a716-446655440000" -w
300
+ ```
301
+
302
+ _See code: [src/commands/get/key-policies.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/get/key-policies.ts)_
303
+
304
+ ## `iam get key-roles KEY_ID`
305
+
306
+ List all IAM roles assigned to a specific API key
307
+
308
+ ```
309
+ USAGE
310
+ $ iam get key-roles KEY_ID [--profile <value>] [-j] [-w]
311
+
312
+ ARGUMENTS
313
+ KEY_ID The API key ID to get roles for
314
+
315
+ FLAGS
316
+ -j, --json Output result as JSON
317
+ -w, --wide Show additional columns in table output
318
+ --profile=<value> Specify the configuration profile to use
319
+
320
+ DESCRIPTION
321
+ List all IAM roles assigned to a specific API key
322
+
323
+ EXAMPLES
324
+ $ flowcore iam get key-roles "550e8400-e29b-41d4-a716-446655440000"
325
+
326
+ $ flowcore iam get key-roles "550e8400-e29b-41d4-a716-446655440000" -j
327
+
328
+ $ flowcore iam get key-roles "550e8400-e29b-41d4-a716-446655440000" -w
329
+ ```
330
+
331
+ _See code: [src/commands/get/key-roles.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/get/key-roles.ts)_
134
332
 
135
333
  ## `iam get policy [NAME]`
136
334
 
@@ -153,7 +351,7 @@ DESCRIPTION
153
351
  Get a policy
154
352
  ```
155
353
 
156
- _See code: [src/commands/get/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.7.0/src/commands/get/policy.ts)_
354
+ _See code: [src/commands/get/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/get/policy.ts)_
157
355
 
158
356
  ## `iam get role [NAME]`
159
357
 
@@ -176,5 +374,196 @@ DESCRIPTION
176
374
  Get a role
177
375
  ```
178
376
 
179
- _See code: [src/commands/get/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.7.0/src/commands/get/role.ts)_
377
+ _See code: [src/commands/get/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/get/role.ts)_
378
+
379
+ ## `iam get user-policies USER_ID`
380
+
381
+ List all IAM policies assigned to a specific user, optionally scoped to a tenant
382
+
383
+ ```
384
+ USAGE
385
+ $ iam get user-policies USER_ID [--profile <value>] [-j] [-t <value>] [-w]
386
+
387
+ ARGUMENTS
388
+ USER_ID The user ID to get policies for (e.g. auth0|abc123)
389
+
390
+ FLAGS
391
+ -j, --json Output result as JSON
392
+ -t, --tenant=<value> Scope results to a specific tenant (organization slug)
393
+ -w, --wide Show additional columns in table output
394
+ --profile=<value> Specify the configuration profile to use
395
+
396
+ DESCRIPTION
397
+ List all IAM policies assigned to a specific user, optionally scoped to a tenant
398
+
399
+ EXAMPLES
400
+ $ flowcore iam get user-policies "auth0|abc123" -t my-org
401
+
402
+ $ flowcore iam get user-policies "auth0|abc123" -j
403
+
404
+ $ flowcore iam get user-policies "auth0|abc123" -t my-org -w
405
+ ```
406
+
407
+ _See code: [src/commands/get/user-policies.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/get/user-policies.ts)_
408
+
409
+ ## `iam get user-roles USER_ID`
410
+
411
+ List all IAM roles assigned to a specific user, optionally scoped to a tenant
412
+
413
+ ```
414
+ USAGE
415
+ $ iam get user-roles USER_ID [--profile <value>] [-j] [-t <value>] [-w]
416
+
417
+ ARGUMENTS
418
+ USER_ID The user ID to get roles for (e.g. auth0|abc123)
419
+
420
+ FLAGS
421
+ -j, --json Output result as JSON
422
+ -t, --tenant=<value> Scope results to a specific tenant (organization slug)
423
+ -w, --wide Show additional columns in table output
424
+ --profile=<value> Specify the configuration profile to use
425
+
426
+ DESCRIPTION
427
+ List all IAM roles assigned to a specific user, optionally scoped to a tenant
428
+
429
+ EXAMPLES
430
+ $ flowcore iam get user-roles "auth0|abc123" -t my-org
431
+
432
+ $ flowcore iam get user-roles "auth0|abc123" -j
433
+
434
+ $ flowcore iam get user-roles "auth0|abc123" -t my-org -w
435
+ ```
436
+
437
+ _See code: [src/commands/get/user-roles.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/get/user-roles.ts)_
438
+
439
+ ## `iam unassign policy POLICY_NAME`
440
+
441
+ Remove an IAM policy assignment from a user, API key, or role. Exactly one of --user, --key, or --role must be specified
442
+
443
+ ```
444
+ USAGE
445
+ $ iam unassign policy POLICY_NAME -t <value> [--profile <value>] [-j] [--key <value> | --user <value> | --role
446
+ <value>] [-y]
447
+
448
+ ARGUMENTS
449
+ POLICY_NAME The name of the policy to unassign
450
+
451
+ FLAGS
452
+ -j, --json Output result as JSON
453
+ -t, --tenant=<value> (required) The tenant (organization slug) containing the policy
454
+ -y, --yes Skip confirmation prompt
455
+ --key=<value> The API key ID to unassign the policy from
456
+ --profile=<value> Specify the configuration profile to use
457
+ --role=<value> The role name to unassign the policy from
458
+ --user=<value> The user ID to unassign the policy from
459
+
460
+ DESCRIPTION
461
+ Remove an IAM policy assignment from a user, API key, or role. Exactly one of --user, --key, or --role must be
462
+ specified
463
+
464
+ EXAMPLES
465
+ $ flowcore iam unassign policy read-access --user "auth0|abc123" -t my-org -y
466
+
467
+ $ flowcore iam unassign policy read-access --key "550e8400-e29b-41d4-a716-446655440000" -t my-org -y
468
+
469
+ $ flowcore iam unassign policy read-access --role data-reader -t my-org -y
470
+
471
+ $ flowcore iam unassign policy read-access --user "auth0|abc123" -t my-org -j -y
472
+ ```
473
+
474
+ _See code: [src/commands/unassign/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/unassign/policy.ts)_
475
+
476
+ ## `iam unassign role ROLE_NAME`
477
+
478
+ Remove an IAM role assignment from a user or API key. Exactly one of --user or --key must be specified
479
+
480
+ ```
481
+ USAGE
482
+ $ iam unassign role ROLE_NAME -t <value> [--profile <value>] [-j] [--key <value> | --user <value>] [-y]
483
+
484
+ ARGUMENTS
485
+ ROLE_NAME The name of the role to unassign
486
+
487
+ FLAGS
488
+ -j, --json Output result as JSON
489
+ -t, --tenant=<value> (required) The tenant (organization slug) containing the role
490
+ -y, --yes Skip confirmation prompt
491
+ --key=<value> The API key ID to unassign the role from
492
+ --profile=<value> Specify the configuration profile to use
493
+ --user=<value> The user ID to unassign the role from
494
+
495
+ DESCRIPTION
496
+ Remove an IAM role assignment from a user or API key. Exactly one of --user or --key must be specified
497
+
498
+ EXAMPLES
499
+ $ flowcore iam unassign role data-reader --user "auth0|abc123" -t my-org -y
500
+
501
+ $ flowcore iam unassign role data-reader --key "550e8400-e29b-41d4-a716-446655440000" -t my-org -y
502
+
503
+ $ flowcore iam unassign role data-reader --user "auth0|abc123" -t my-org -j -y
504
+ ```
505
+
506
+ _See code: [src/commands/unassign/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/unassign/role.ts)_
507
+
508
+ ## `iam validate key KEY_ID`
509
+
510
+ Validate whether an API key has permission to perform an action on one or more resources
511
+
512
+ ```
513
+ USAGE
514
+ $ iam validate key KEY_ID --action <value> --resource <value>... -t <value> [--profile <value>] [-j]
515
+
516
+ ARGUMENTS
517
+ KEY_ID The API key ID to validate access for
518
+
519
+ FLAGS
520
+ -j, --json Output result as JSON
521
+ -t, --tenant=<value> (required) The tenant (organization slug) to validate within
522
+ --action=<value> (required) The action to validate (e.g. read, write, ingest, fetch)
523
+ --profile=<value> Specify the configuration profile to use
524
+ --resource=<value>... (required) The resource FRN to validate against (can be specified multiple times)
525
+
526
+ DESCRIPTION
527
+ Validate whether an API key has permission to perform an action on one or more resources
528
+
529
+ EXAMPLES
530
+ $ flowcore iam validate key "550e8400-e29b-41d4-a716-446655440000" -t my-org --action ingest --resource "frn::my-org:event-type/*"
531
+
532
+ $ flowcore iam validate key "550e8400-e29b-41d4-a716-446655440000" -t my-org --action read --resource "frn::my-org:data-core/my-core" -j
533
+
534
+ $ flowcore iam validate key "550e8400-e29b-41d4-a716-446655440000" -t my-org --action read --resource "frn::my-org:data-core/core1" --resource "frn::my-org:data-core/core2"
535
+ ```
536
+
537
+ _See code: [src/commands/validate/key.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/validate/key.ts)_
538
+
539
+ ## `iam validate user USER_ID`
540
+
541
+ Validate whether a user has permission to perform an action on one or more resources
542
+
543
+ ```
544
+ USAGE
545
+ $ iam validate user USER_ID --action <value> --resource <value>... -t <value> [--profile <value>] [-j]
546
+
547
+ ARGUMENTS
548
+ USER_ID The user ID to validate access for (e.g. auth0|abc123)
549
+
550
+ FLAGS
551
+ -j, --json Output result as JSON
552
+ -t, --tenant=<value> (required) The tenant (organization slug) to validate within
553
+ --action=<value> (required) The action to validate (e.g. read, write, ingest, fetch)
554
+ --profile=<value> Specify the configuration profile to use
555
+ --resource=<value>... (required) The resource FRN to validate against (can be specified multiple times)
556
+
557
+ DESCRIPTION
558
+ Validate whether a user has permission to perform an action on one or more resources
559
+
560
+ EXAMPLES
561
+ $ flowcore iam validate user "auth0|abc123" -t my-org --action read --resource "frn::my-org:data-core/my-core"
562
+
563
+ $ flowcore iam validate user "auth0|abc123" -t my-org --action write --resource "frn::my-org:data-core/*" -j
564
+
565
+ $ flowcore iam validate user "auth0|abc123" -t my-org --action read --resource "frn::my-org:data-core/core1" --resource "frn::my-org:data-core/core2"
566
+ ```
567
+
568
+ _See code: [src/commands/validate/user.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.8.0/src/commands/validate/user.ts)_
180
569
  <!-- commandsstop -->
package/bin/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2
2
 
3
- import {execute} from '@oclif/core'
3
+ import { execute } from "@oclif/core"
4
4
 
5
- await execute({development: true, dir: import.meta.url})
5
+ await execute({ development: true, dir: import.meta.url })
package/bin/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import {execute} from '@oclif/core'
3
+ import { execute } from "@oclif/core"
4
4
 
5
- await execute({dir: import.meta.url})
5
+ await execute({ dir: import.meta.url })
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from "@flowcore/cli-plugin-config";
2
+ export default class AssignPolicy extends BaseCommand<typeof AssignPolicy> {
3
+ static args: {
4
+ POLICY_NAME: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ key: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ role: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,124 @@
1
+ import { BaseCommand, ValidateLogin } from "@flowcore/cli-plugin-config";
2
+ import { ClientFactory } from "@flowcore/cli-plugin-core";
3
+ import { Args, Flags } from "@oclif/core";
4
+ import { tryit } from "radash";
5
+ import { OrganizationService } from "../../services/organization.service.js";
6
+ import { Api as IamApi } from "../../utils/clients/iam/Api.js";
7
+ import { getErrorMessage } from "../../utils/error-message.util.js";
8
+ export default class AssignPolicy extends BaseCommand {
9
+ static args = {
10
+ POLICY_NAME: Args.string({
11
+ description: "The name of the policy to assign",
12
+ required: true,
13
+ }),
14
+ };
15
+ static description = "Assign an IAM policy to a user, API key, or role. Exactly one of --user, --key, or --role must be specified";
16
+ static examples = [
17
+ `$ flowcore iam assign policy read-access --user "auth0|abc123" -t my-org`,
18
+ `$ flowcore iam assign policy read-access --key "550e8400-e29b-41d4-a716-446655440000" -t my-org`,
19
+ "$ flowcore iam assign policy read-access --role data-reader -t my-org",
20
+ `$ flowcore iam assign policy read-access --user "auth0|abc123" -t my-org -j`,
21
+ ];
22
+ static flags = {
23
+ json: Flags.boolean({
24
+ char: "j",
25
+ description: "Output result as JSON",
26
+ required: false,
27
+ }),
28
+ key: Flags.string({
29
+ description: "The API key ID to assign the policy to",
30
+ exclusive: ["user", "role"],
31
+ required: false,
32
+ }),
33
+ role: Flags.string({
34
+ description: "The role name to assign the policy to",
35
+ exclusive: ["user", "key"],
36
+ required: false,
37
+ }),
38
+ tenant: Flags.string({
39
+ char: "t",
40
+ description: "The tenant (organization slug) containing the policy",
41
+ required: true,
42
+ }),
43
+ user: Flags.string({
44
+ description: "The user ID to assign the policy to",
45
+ exclusive: ["key", "role"],
46
+ required: false,
47
+ }),
48
+ };
49
+ async run() {
50
+ const { args, flags } = await this.parse(AssignPolicy);
51
+ if (!flags.user && !flags.key && !flags.role) {
52
+ this.logger.fatal("Exactly one of --user, --key, or --role is required");
53
+ }
54
+ const graphqlClient = await ClientFactory.create(this.cliConfiguration, this.logger, flags.json);
55
+ const organizationService = new OrganizationService(graphqlClient);
56
+ const organizations = await organizationService.getMyOrganizations();
57
+ const iamClient = new IamApi();
58
+ const config = this.cliConfiguration.getConfig();
59
+ const login = new ValidateLogin(config.login.url);
60
+ await login.validate(config, this.cliConfiguration, !flags.json);
61
+ const { auth } = config;
62
+ if (!auth?.accessToken) {
63
+ this.logger.fatal("Not logged in, run 'flowcore login'");
64
+ }
65
+ const organization = organizations.me.organizations.find((org) => org.organization.org === flags.tenant);
66
+ if (!organization) {
67
+ this.logger.fatal(`Organization ${flags.tenant} not found, or you are not a member`);
68
+ }
69
+ const authHeaders = {
70
+ headers: { Authorization: `Bearer ${auth?.accessToken}` },
71
+ };
72
+ // Resolve policy name to ID
73
+ const [policiesErr, policies] = await tryit(iamClient.getApiV1PolicyAssociationsOrganizationByOrganizationId)(organization.organization.id, authHeaders);
74
+ if (policiesErr) {
75
+ this.logger.fatal(`Failed to get policies: ${policiesErr.message}`);
76
+ }
77
+ const policy = policies.data.find((p) => p.name === args.POLICY_NAME);
78
+ if (!policy) {
79
+ this.logger.fatal(`Policy "${args.POLICY_NAME}" not found in tenant: ${flags.tenant}`);
80
+ }
81
+ let result;
82
+ if (flags.user) {
83
+ const [err, response] = await tryit(iamClient.postApiV1PolicyAssociationsUserByUserId)(flags.user, { policyId: policy.id }, authHeaders);
84
+ if (err) {
85
+ this.logger.fatal(`Failed to assign policy to user: ${getErrorMessage(err)}`);
86
+ }
87
+ result = response.data;
88
+ }
89
+ else if (flags.key) {
90
+ const [err, response] = await tryit(iamClient.postApiV1PolicyAssociationsKeyByKeyId)(flags.key, { policyId: policy.id }, authHeaders);
91
+ if (err) {
92
+ this.logger.fatal(`Failed to assign policy to key: ${getErrorMessage(err)}`);
93
+ }
94
+ result = response.data;
95
+ }
96
+ else if (flags.role) {
97
+ // Resolve role name to ID
98
+ const [rolesErr, roles] = await tryit(iamClient.getApiV1RoleAssociationsOrganizationByOrganizationId)(organization.organization.id, authHeaders);
99
+ if (rolesErr) {
100
+ this.logger.fatal(`Failed to get roles: ${rolesErr.message}`);
101
+ }
102
+ const role = roles.data.find((r) => r.name === flags.role);
103
+ if (!role) {
104
+ this.logger.fatal(`Role "${flags.role}" not found in tenant: ${flags.tenant}`);
105
+ }
106
+ const [err, response] = await tryit(iamClient.postApiV1PolicyAssociationsRoleByRoleId)(role.id, { policyId: policy.id }, authHeaders);
107
+ if (err) {
108
+ this.logger.fatal(`Failed to assign policy to role: ${getErrorMessage(err)}`);
109
+ }
110
+ result = response.data;
111
+ }
112
+ if (flags.json) {
113
+ console.log(JSON.stringify(result, null, 2));
114
+ }
115
+ else {
116
+ const target = flags.user
117
+ ? `user ${flags.user}`
118
+ : flags.key
119
+ ? `key ${flags.key}`
120
+ : `role ${flags.role}`;
121
+ this.logger.info(`Policy "${args.POLICY_NAME}" assigned to ${target}`);
122
+ }
123
+ }
124
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from "@flowcore/cli-plugin-config";
2
+ export default class AssignRole extends BaseCommand<typeof AssignRole> {
3
+ static args: {
4
+ ROLE_NAME: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ key: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ };
14
+ run(): Promise<void>;
15
+ }