Skip to main content
Latest Version

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 keystoneauth1 import session
>>> from barbicanclient import client

>>> # We'll use Keystone API v3 for authentication
>>> auth = identity.v3.Password(auth_url='http://localhost:5000/v3',
...                             username='admin_user',
...                             user_domain_name='Default',
...                             password='password',
...                             project_name='demo',
...                             project_domain_name='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='Self destruction sequence',
...                                  payload='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()
'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('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

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.

Release files for python-barbicanclient 7.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-barbicanclient 7.6.0
File Size Uploaded
python_barbicanclient-7.6.0.tar.gz 131.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-barbicanclient 7.6.0
File Interpreter ABI Platform
python_barbicanclient-7.6.0-py3-none-any.whl Python 3 none any Details

Total release size:222.1 kB

Release files / python_barbicanclient-7.6.0.tar.gz

Download URL python_barbicanclient-7.6.0.tar.gz
Size 131.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d2a79dfe49e0f7ab7412911b62147c7941dd9f9770323eb050a53c31b9322821
BLAKE2b-256 checksum
How to use checksums
d0a5db5f8c3f831155c7f44720ae917cbba23aab8a482790ffb221f4674fa3eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / python_barbicanclient-7.6.0-py3-none-any.whl

Download URL python_barbicanclient-7.6.0-py3-none-any.whl
Size 90.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50e8f988c6712a98ff6b1b37b92b5a16c60a5b4d587c857b48659285ddbcae5b
BLAKE2b-256 checksum
How to use checksums
b612bf04fdb80180d6995bde9d19c48c2a3be4b808ac7f6534b6f61dc65c8eb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

7.6.0 This release

2 release files

7.5.0

2 release files

7.4.0

2 release files

7.3.0

2 release files

7.2.0

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.0.0

2 release files

5.7.0

2 release files

5.6.1

2 release files

5.6.0

2 release files

5.5.0

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.10.0

2 release files

4.9.0

2 release files

4.8.1

2 release files

4.8.0

2 release files

4.7.2

2 release files

4.7.1

2 release files

4.7.0

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.3

2 release files

4.5.2

2 release files

4.5.1

2 release files

4.5.0

2 release files

4.4.0

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.1

2 release files

2.1.0

1 release file

2.0.0

1 release file

1.0.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page