Client library for Barbican API.
Go to file
ricolin a80f7ea7a1 Remove py26 support
As of mitaka, the infra team won't have the resources available to
reasonably test py26, also the oslo team is dropping py26 support
from their libraries. sine we rely on oslo for a lot of our work,
and depend on infra for our CI, we should drop py26 support too.
Closes-Bug: 1519510
Depends-On: Ic8241e55b5f4e3d567156d4c1e8bf8a0303f6d29

Change-Id: I4386dc70e3d467e31963d852726af78fbdbbba38
2015-12-02 23:54:06 +08:00
barbicanclient Merge "Make CLI Order's type field a required argument" 2015-11-18 16:50:13 +00:00
doc/source Part 2: Adding ACL support for CLI commands and docs 2015-09-29 12:22:43 -07:00
etc Merge "Use functional_test.conf for devstack gate" 2015-03-13 17:13:55 +00:00
functionaltests Remove invalid skipping of tests 2015-11-02 11:15:51 +02:00
tools Migrate to pbr 2014-01-03 11:42:56 -05:00
.coveragerc Adding new tests to cover failure scenarios 2015-05-07 13:36:08 -05:00
.gitignore port tests to testtools, add branch coverage, omit openstack common 2014-03-20 09:30:12 -04:00
.gitreview Fix the gitreview 2014-05-31 23:42:42 -07:00
.mailmap Add mailmap file. 2013-12-03 22:34:13 -06:00
.testr.conf Initial directory changes and files for python-babricanclient functional tests 2015-01-30 12:11:40 -06:00
CONTRIBUTING.rst Workflow documentation is now in infra-manual 2014-12-05 03:30:39 +00:00
LICENSE Adding Apache license 2013-05-09 08:42:55 -05:00
MANIFEST.in First stab at packaging 2013-05-30 09:42:04 -05:00
README.rst Merge "Update Readme to include new/updated CLI commands" 2015-11-16 08:47:15 +00:00
clientrc Fix the clientrc file to match defaults and add docs 2015-04-17 10:24:26 -05:00
requirements.txt Updated from global requirements 2015-11-29 02:37:18 +00:00
setup.cfg Remove py26 support 2015-12-02 23:54:06 +08:00
setup.py Updated from global requirements 2015-10-05 23:04:50 +00:00
test-requirements.txt Updated from global requirements 2015-11-19 15:52:04 +00:00
tox.ini Remove py26 support 2015-12-02 23:54:06 +08:00

README.rst

python-barbicanclient

Latest Version

Downloads

This is a client for the Barbican Key Management API. There is a Python library for accessing the API (barbicanclient module), and a command-line script (barbican).

Installation

The client is pip installable as follows:

pip install python-barbicanclient

barbicanclient - Python Library

The full api is documented in the official OpenStack documentation site.

Here's an example of storing a secret in barbican using the python library with keystone authentication:

>>> from keystoneclient.auth import identity
>>> from keystoneclient import session
>>> from barbicanclient import client

>>> # We'll use Keystone API v3 for authentication
>>> auth = identity.v3.Password(auth_url=u'http://localhost:5000/v3',
...                             username=u'admin_user',
...                             user_domain_name=u'Default',
...                             password=u'password',
...                             project_name=u'demo',
...                             project_domain_name=u'Default')

>>> # Next we'll create a Keystone session using the auth plugin we just created
>>> sess = session.Session(auth=auth)

>>> # Now we use the session to create a Barbican client
>>> barbican = client.Client(session=sess)

>>> # Let's create a Secret to store some sensitive data
>>> secret = barbican.secrets.create(name=u'Self destruction sequence',
...                                  payload=u'the magic words are squeamish ossifrage')

>>> # Now let's store the secret by using its store() method. This will send the secret data
>>> # to Barbican, where it will be encrypted and stored securely in the cloud.
>>> secret.store()
u'http://localhost:9311/v1/secrets/85b220fd-f414-483f-94e4-2f422480f655'

>>> # The URI returned by store() uniquely identifies your secret in the Barbican service.
>>> # After a secret is stored, the URI is also available by accessing
>>> # the secret_ref attribute.
>>> print(secret.secret_ref)
http://localhost:9311/v1/secrets/091adb32-4050-4980-8558-90833c531413

>>> # When we need to retrieve our secret at a later time, we can use the secret_ref
>>> retrieved_secret = barbican.secrets.get(u'http://localhost:9311/v1/secrets/091adb32-4050-4980-8558-90833c531413')
>>> # We can access the secret payload by using the payload attribute.
>>> # Barbican decrypts the secret and sends it back.
>>> print(retrieved_secret.payload)
the magic words are squeamish ossifrage

Note

In order for the example above to work Barbican must be running and configured to use the Keystone Middleware. For more information on setting this up please visit: http://docs.openstack.org/developer/barbican/setup/keystone.html1

barbican - Command Line Client

The command line client is self-documenting. Use the --help flag to access the usage options

$ barbican --help
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>]
                [--endpoint <barbican-url>] [--insecure]
                [--os-cacert <ca-certificate>] [--os-cert <certificate>]
                [--os-key <key>] [--timeout <seconds>]

Command-line interface to the Barbican API.

optional arguments:
  --version             show program's version number and exit
  -v, --verbose         Increase verbosity of output. Can be repeated.
  --log-file LOG_FILE   Specify a file to log output. Disabled by default.
  -q, --quiet           suppress output except warnings and errors
  -h, --help            show this help message and exit
  --debug               show trace backs on errors
  --no-auth, -N         Do not use authentication.
  --os-identity-api-version <identity-api-version>
                        Specify Identity API version to use. Defaults to
                        env[OS_IDENTITY_API_VERSION] or 3.

  --os-auth-url <auth-url>, -A <auth-url>
                        Defaults to env[OS_AUTH_URL].
  --os-username <auth-user-name>, -U <auth-user-name>
                        Defaults to env[OS_USERNAME].
  --os-user-id <auth-user-id>
                        Defaults to env[OS_USER_ID].
  --os-password <auth-password>, -P <auth-password>
                        Defaults to env[OS_PASSWORD].
  --os-user-domain-id <auth-user-domain-id>
                        Defaults to env[OS_USER_DOMAIN_ID].
  --os-user-domain-name <auth-user-domain-name>
                        Defaults to env[OS_USER_DOMAIN_NAME].
  --os-tenant-name <auth-tenant-name>, -T <auth-tenant-name>
                        Defaults to env[OS_TENANT_NAME].
  --os-tenant-id <tenant-id>, -I <tenant-id>
                        Defaults to env[OS_TENANT_ID].
  --os-project-id <auth-project-id>
                        Another way to specify tenant ID. This option is
                        mutually exclusive with --os-tenant-id. Defaults to
                        env[OS_PROJECT_ID].
  --os-project-name <auth-project-name>
                        Another way to specify tenant name. This option is
                        mutually exclusive with --os-tenant-name. Defaults to
                        env[OS_PROJECT_NAME].
  --os-project-domain-id <auth-project-domain-id>
                        Defaults to env[OS_PROJECT_DOMAIN_ID].
  --os-project-domain-name <auth-project-domain-name>
                        Defaults to env[OS_PROJECT_DOMAIN_NAME].
  --endpoint <barbican-url>, -E <barbican-url>
  --endpoint <barbican-url>, -E <barbican-url>
                        Defaults to env[BARBICAN_ENDPOINT].
  --insecure            Explicitly allow client to perform "insecure" TLS
                        (https) requests. The server's certificate will not be
                        verified against any certificate authorities. This
                        option should be used with caution.
  --os-cacert <ca-certificate>
                        Specify a CA bundle file to use in verifying a TLS
                        (https) server certificate. Defaults to
                        env[OS_CACERT].
  --os-cert <certificate>
                        Defaults to env[OS_CERT].
  --os-key <key>        Defaults to env[OS_KEY].
  --timeout <seconds>   Set request timeout (in seconds).

See "barbican help COMMAND" for help on a specific command.

Commands:
  acl get                  Retrieve ACLs for a secret or container by providing its href.
  acl delete               Delete ACLs for a secret or container as identified by 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.
  ca get                   Retrieve a CA by providing its URI.
  ca list                  List cas.
  complete                 print bash completion command
  secret container create  Store a container in Barbican.
  secret container delete  Delete a container by providing its href.
  secret container get     Retrieve a container by providing its URI.
  secret container list    List containers.
  help                     print detailed help for another command
  secret order create      Create a new order.
  secret order delete      Delete an order by providing its href.
  secret order get         Retrieve an order by providing its URI.
  secret order list        List orders.
  secret delete            Delete an secret by providing its href.
  secret get               Retrieve a secret by providing its URI.
  secret list              List secrets.
  secret store             Store a secret in Barbican
  secret update            Update a secret with no payload in Barbican.

  1. Documentation in this link is currently incomplete. Please use the devstack setup.↩︎