summaryrefslogtreecommitdiff
path: root/doc/source/cli/cli_usage.rst
blob: ae8ca3240f0eb7bc69a67399beb3caccf77c94ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
CLI Usage
=========

.. code-block:: bash

    usage: barbican [--version] [-v] [--log-file LOG_FILE] [-q] [-h] [--debug]
                    [--no-auth] [--os-identity-api-version <identity-api-version>]
                    [--os-auth-url <auth-url>] [--os-username <auth-user-name>]
                    [--os-user-id <auth-user-id>] [--os-password <auth-password>]
                    [--os-user-domain-id <auth-user-domain-id>]
                    [--os-user-domain-name <auth-user-domain-name>]
                    [--os-tenant-name <auth-tenant-name>]
                    [--os-tenant-id <tenant-id>]
                    [--os-project-id <auth-project-id>]
                    [--os-project-name <auth-project-name>]
                    [--os-project-domain-id <auth-project-domain-id>]
                    [--os-project-domain-name <auth-project-domain-name>]
                    [--os-auth-token <auth-token>]
                    [--endpoint <barbican-url>] [--insecure]
                    [--os-cacert <ca-certificate>] [--os-cert <certificate>]
                    [--os-key <key>] [--timeout <seconds>]


The examples below assume that credentials have been saved to your environment.
If you don't have variables saved to your environment or you wish to use
different credentials than those defined, any of the optional arguments listed
above may be passed to Barbican.

Barbican takes a positional argument <entity>, which specifies whether you wish
to operate on a secret or an order.

Secrets
-------

.. code-block:: bash

    $ barbican secret <action>

A subcommand describing the action to be performed should follow. The
subcommands are mostly the same for secrets and orders, although some optional
arguments only apply to one or the other.

Subcommand actions that a user can take for secrets are:

.. code-block:: bash

    secret delete  Delete a secret by providing its URI.
    secret get     Retrieve a secret by providing its URI.
    secret list    List secrets.
    secret store   Store a secret in Barbican.

Each subcommand takes in a different set of arguments, and the help message
varies from one to another. The help message for **get** can be seen below.

.. code-block:: bash

    $  barbican help secret get
    usage: barbican secret get [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN]
                               [--max-width <integer>] [--fit-width]
                               [--print-empty] [--noindent] [--prefix PREFIX]
                               [--decrypt | --payload | --file <filename>]
                               [--payload_content_type PAYLOAD_CONTENT_TYPE]
                               URI

    Retrieve a secret by providing its URI.

    positional arguments:
      URI                   The URI reference for the secret.

    optional arguments:
      -h, --help            show this help message and exit
      --decrypt, -d         if specified, retrieve the unencrypted secret data.
      --payload, -p         if specified, retrieve the unencrypted secret data.
      --file <filename>, -F <filename>
                            if specified, save the payload to a new file with the
                            given filename.
      --payload_content_type PAYLOAD_CONTENT_TYPE, -t PAYLOAD_CONTENT_TYPE
                            the content type of the decrypted secret (default:
                            text/plain).

    output formatters:
      output formatter options

      -f {shell,table,value}, --format {shell,table,value}
                            the output format, defaults to table
      -c COLUMN, --column COLUMN
                            specify the column(s) to include, can be repeated

    table formatter:
      --max-width <integer>
                            Maximum display width, 0 to disable

    shell formatter:
      a format a UNIX shell can parse (variable="value")

      --prefix PREFIX       add a prefix to all variable names


Secret Create
~~~~~~~~~~~~~

.. code-block:: bash

    $ barbican secret store -n mysecretname -p 'my secret value'

    +---------------+-----------------------------------------------------------------------+
    | Field         | Value                                                                 |
    +---------------+-----------------------------------------------------------------------+
    | Secret href   | http://localhost:9311/v1/secrets/a70a45d8-4076-42a2-b111-8893d3b92a3e |
    | Name          | mysecretname                                                          |
    | Created       | None                                                                  |
    | Status        | None                                                                  |
    | Content types | None                                                                  |
    | Algorithm     | aes                                                                   |
    | Bit length    | 256                                                                   |
    | Mode          | cbc                                                                   |
    | Expiration    | None                                                                  |
    +---------------+-----------------------------------------------------------------------+

Instead of using the :code:`-p` or :code:`--payload` option with the
value of the secret in the command line, the value of
the secret may be stored in a file.  For this method the
:code:`-F <filename>` or :code:`--file <filename>` option can be used.

Secret Get
~~~~~~~~~~

.. code-block:: bash

    $ barbican secret get http://localhost:9311/v1/secrets/a70a45d8-4076-42a2-b111-8893d3b92a3e

    +---------------+-----------------------------------------------------------------------+
    | Field         | Value                                                                 |
    +---------------+-----------------------------------------------------------------------+
    | Secret href   | http://localhost:9311/v1/secrets/a70a45d8-4076-42a2-b111-8893d3b92a3e |
    | Name          | mysecretname                                                          |
    | Created       | 2015-04-16 20:36:40.334696+00:00                                      |
    | Status        | ACTIVE                                                                |
    | Content types | {'default': 'application/octet-stream'}                               |
    | Algorithm     | aes                                                                   |
    | Bit length    | 256                                                                   |
    | Mode          | cbc                                                                   |
    | Expiration    | None                                                                  |
    +---------------+-----------------------------------------------------------------------+

To retrieve only the raw value of the payload we have introduced the :code:`-p`
or :code:`--payload` option paired with the :code:`-f value` cliff formatting
option. (The :code:`--decrypt` option will perform the same action; however,
it will be deprecated)

.. code-block:: bash

    $ barbican secret get http://localhost:9311/v1/secrets/a70a45d8-4076-42a2-b111-8893d3b92a3e --payload -f value
    my secret value

Instead of using the :code:`-p` or :code:`--payload` option with the
value of the secret returned to stdout, the value of
the secret may be written to a file.  For this method the
:code:`-F <filename>` or :code:`--file <filename>` option can be used.

Secret Delete
~~~~~~~~~~~~~

.. code-block:: bash

    $ barbican secret delete http://localhost:9311/v1/secrets/a70a45d8-4076-42a2-b111-8893d3b92a3e

Secret Update
~~~~~~~~~~~~~

.. code-block:: bash

    $ barbican secret update http://localhost:9311/v1/secrets/a70a45d8-4076-42a2-b111-8893d3b92a3e ``my_payload``

In order for a secret to be updated it must have been created without a payload.
``my_payload`` will be added as the secret's payload.

Secret List
~~~~~~~~~~~

.. code-block:: bash

    $ barbican secret list

    +-----------------------------------------------------------------------+------+----------------------------------+--------+-----------------------------------------+-----------+------------+------+------------+
    | Secret href                                                           | Name | Created                          | Status | Content types                           | Algorithm | Bit length | Mode | Expiration |
    +-----------------------------------------------------------------------+------+----------------------------------+--------+-----------------------------------------+-----------+------------+------+------------+
    | http://localhost:9311/v1/secrets/bb3d8c20-8ea5-4bfc-9645-c8da79c8b371 | None | 2015-04-15 20:37:37.501475+00:00 | ACTIVE | {'default': 'application/octet-stream'} | aes       |        256 | cbc  | None       |
    +-----------------------------------------------------------------------+------+----------------------------------+--------+-----------------------------------------+-----------+------------+------+------------+


ACLS
----

.. code-block:: bash

    $ barbican acl <action>

A subcommand describing the action to be performed should follow. The
subcommands are mostly the same for secret and container ACLs.

Subcommand actions that a user can take for ACLs are:

.. code-block:: bash

    acl delete          Delete ACLs for a secret or container as identified by its href.
    acl get             Retrieve ACLs for a secret or container by providing its href.
    acl submit          Submit ACL on a secret or container as identified by its href.
    acl user add        Add ACL users to a secret or container as identified by its href.
    acl user remove     Remove ACL users from a secret or container as identified by its href.

ACL **get** or **delete** subcommand, only takes secret or container href. All
other ACL commands take additional arguments to specify ACL settings data.
Please see help message for both cases of argument. Either secret ref or
container ref is required for all of acl actions.

.. code-block:: bash

    $ barbican help acl get
    usage: barbican acl get [-h] [-f {csv,table,value}] [-c COLUMN]
                            [--max-width <integer>]
                            [--quote {all,minimal,none,nonnumeric}]
                            URI

    Retrieve ACLs for a secret or container by providing its href.

    positional arguments:
      URI                   The URI reference for the secret or container.

    optional arguments:
      -h, --help            show this help message and exit

    output formatters:
      output formatter options

      -f {csv,table,value}, --format {csv,table,value}
                            the output format, defaults to table
      -c COLUMN, --column COLUMN
                            specify the column(s) to include, can be repeated

    table formatter:
      --max-width <integer>
                            Maximum display width, 0 to disable

    CSV Formatter:
      --quote {all,minimal,none,nonnumeric}
                            when to include quotes, defaults to nonnumeric


Following is snippet of related command line options for an ACL modify action
e.g. submit, add or remove.


.. code-block:: bash

    $ barbican help acl submit/user add/user remove
    usage: barbican acl submit [-h] [-f {csv,table,value}] [-c COLUMN]
                               [--max-width <integer>]
                               [--quote {all,minimal,none,nonnumeric}]
                               [--user [USER]]
                               [--project-access | --no-project-access]
                               [--operation-type {read}]
                               URI

    ....
    ....

    positional arguments:
      URI                   The URI reference for the secret or container.

    optional arguments:
      -h, --help            show this help message and exit
      --user [USER], -u [USER]
                            Keystone userid(s) for ACL.
      --project-access      Flag to enable project access behavior.
      --no-project-access   Flag to disable project access behavior.
      --operation-type {read}, -o {read}
                            Type of Barbican operation ACL is set for
    ....
    ....


.. note::

    Default for ``operation-type`` argument is 'read' as that's the only operation
    currently supported by Barbican ACL API. So this argument can be skipped in
    CLI call.


ACLs Get
~~~~~~~~

To get complete ACL setting for a secret or container, use this ACL action.

.. code-block:: bash

    $ barbican acl get http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213

    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                                                    | Created                          | Updated                          | Secret ACL Ref                                                            |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | read           | False          | ['721e27b8505b499e8ab3b38154705b9e', '2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-21 17:52:01.729370+00:00 | 2015-07-28 02:08:02.455276+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+

    $ barbican acl get http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19

    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                | Created                          | Updated                          | Container ACL Ref                                                            |
    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+
    | read           | False          | ['2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-28 01:36:55.791381+00:00 | 2015-07-28 02:05:41.175386+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl |
    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+


Secret or container ref is required. If missing, it will result in error.

.. code-block:: bash

    $ barbican acl get

    usage: barbican acl get [-h] [-f {csv,table,value}] [-c COLUMN]
                            [--max-width <integer>]
                            [--quote {all,minimal,none,nonnumeric}]
                            URI
    barbican acl get: error: too few arguments


ACLs Submit
~~~~~~~~~~~

To submit complete ACL setting for a secret or container, use this ACL action.

.. code-block:: bash

    $ barbican acl submit --user 2d0ee7c681cc4549b6d76769c320d91f --user 721e27b8505b499e8ab3b38154705b9e http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213

    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                                                    | Created                          | Updated                          | Secret ACL Ref                                                            |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | read           | True           | ['721e27b8505b499e8ab3b38154705b9e', '2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-21 17:52:01.729370+00:00 | 2015-08-12 09:53:20.225971+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+


If ``user`` argument is missing or has no value, then empty list is passed for
users and this approach can be used to remove existing ACL users. If project
access argument is not provided, then by default project access is enabled. To
disable project access behavior, just pass ``no-project-access`` argument
without any value.

.. code-block:: bash

    $ barbican acl submit --user --no-project-access http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213

    +----------------+----------------+-------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | Operation Type | Project Access | Users | Created                          | Updated                          | Secret ACL Ref                                                            |
    +----------------+----------------+-------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | read           | False          | []    | 2015-07-21 17:52:01.729370+00:00 | 2015-08-12 09:55:23.043433+00:00 | http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213/acl |
    +----------------+----------------+-------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+

    $ barbican acl submit --user 2d0ee7c681cc4549b6d76769c320d91f --no-project-access http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19

    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                | Created                          | Updated                          | Container ACL Ref                                                            |
    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+
    | read           | False          | ['2d0ee7c681cc4549b6d76769c320d91f'] | 2015-07-29 22:01:00.878270+00:00 | 2015-08-19 05:56:09.930302+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl |
    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+

Following error is returned when both mutually exclusive flags are passed.

.. code-block:: bash

    $ barbican acl submit --project-access --no-project-access http://localhost:9311/v1/secrets/7776adb8-e865-413c-8ccc-4f09c3fe0213
    usage: barbican acl submit [-h] [-f {csv,table,value}] [-c COLUMN]
                               [--max-width <integer>]
                               [--quote {all,minimal,none,nonnumeric}]
                               [--user [USER]]
                               [--project-access | --no-project-access]
                               [--operation-type {read}]
                               URI
    barbican acl submit: error: argument --no-project-access: not allowed with argument --project-access


ACL Add User(s)
~~~~~~~~~~~~~~~

To add ACL users for a secret or container, use this ACL action.

If ``user`` argument is missing or has no value, then no change is made in ACL
users. If project access argument is not provided, then no change is made in
existing project access behavior flag.

.. code-block:: bash

    $ barbican acl user add --user c1d20e4b7e7d4917aee6f0832152269b http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19

    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                                                    | Created                          | Updated                          | Container ACL Ref                                                            |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+
    | read           | False          | ['2d0ee7c681cc4549b6d76769c320d91f', 'c1d20e4b7e7d4917aee6f0832152269b'] | 2015-07-29 22:01:00.878270+00:00 | 2015-08-12 10:08:19.129370+00:00 | http://localhost:9311/v1/containers/83c302c7-86fe-4f07-a277-c4962f121f19/acl |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+------------------------------------------------------------------------------+

.. code-block:: bash

    # Added 2 users for secret (084c2098-66db-4401-8348-d969be0eddaa) earlier via set action.
    $ barbican acl user add --user --no-project-access http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa

    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                                                    | Created                          | Updated                          | Secret ACL Ref                                                            |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | read           | False          | ['721e27b8505b499e8ab3b38154705b9e', '2d0ee7c681cc4549b6d76769c320d91f'] | 2015-08-12 10:09:27.564371+00:00 | 2015-08-12 10:11:09.749980+00:00 | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl |
    +----------------+----------------+--------------------------------------------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+


ACL Remove User(s)
~~~~~~~~~~~~~~~~~~

To remove ACL users for a secret or container, use this ACL action.

If ``user`` argument is missing or has no value, then no change is made in ACL
users. If project access argument is not provided, then no change is made in
existing project access behavior flag.

If provided userid(s) does not exist in ACL, it is simply ignored and only
existing userid(s) are removed from ACL.

.. code-block:: bash

    $ barbican acl user remove --user 2d0ee7c681cc4549b6d76769c320d91f --user invalid_user_id http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa

    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | Operation Type | Project Access | Users                                | Created                          | Updated                          | Secret ACL Ref                                                            |
    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+
    | read           | False          | ['721e27b8505b499e8ab3b38154705b9e'] | 2015-08-12 10:09:27.564371+00:00 | 2015-08-12 10:12:21.842888+00:00 | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl |
    +----------------+----------------+--------------------------------------+----------------------------------+----------------------------------+---------------------------------------------------------------------------+


ACLs Delete
~~~~~~~~~~~

To delete existing ACL setting for a secret or container, use this ACL action.

.. code-block:: bash

    $ barbican acl delete http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa

    $ barbican acl get http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa

    +----------------+----------------+-------+---------+---------+---------------------------------------------------------------------------+
    | Operation Type | Project Access | Users | Created | Updated | Secret ACL Ref                                                            |
    +----------------+----------------+-------+---------+---------+---------------------------------------------------------------------------+
    | read           | True           | []    | None    | None    | http://localhost:9311/v1/secrets/084c2098-66db-4401-8348-d969be0eddaa/acl |
    +----------------+----------------+-------+---------+---------+---------------------------------------------------------------------------+