Skip to main content

The Thycotic DevOps Secrets Vault Python SDK

Project description

The Thycotic DevOps Secrets Vault Python SDK

The Thycotic DevOps Secrets Vault (DSV) Python SDK contains classes that interact with the DSV REST API.

Install

python -m pip install python-dsv-sdk

Settings

The SDK API requires a tenant, client_id, client_secret and optional tld.

The API uses the tenant to create request URLs and it uses the client_id and client_secret to obtain an OAuth2 access_token with which to call the DSV REST API.

The optional top-level domain (TLD) defaults to com.

Use

Simply instantiate SecretsVault:

from thycotic.secrets.vault import SecretsVault

vault = SecretsVault("my_tenant", "my_client_id", "my_client_secret")

Then pass a path to get_secret() which will return the secret as a JSON encoded string. The SDK API also contains a VaultSecret @dataclass containing a the Secret's attributes. The data attribute is a Python Dictionary.

from thycotic.secrets.dataclasses import Secret

secret = VaultSecret(**vault.get_secret("/test/secret"))

print(f"username: {secret.data['username']}\npassword: {secret.data['password']}")

Create a Build Environment (optional)

The SDK requires Python 3.6 or higher, and the Requests library.

First, ensure Python 3.6 is in $PATH then run:

git clone https://github.com/thycotic/python-dsv-sdk
cd python-dsv-sdk
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt

Both example.py and the unit tests pull the settings from a JSON file.

with open('vault_config.json') as f:
    config = json.load(f)

They also assume that the specified client_id and client_secret can read /test/secret, and that the secret.data contains username and password fields.

Create vault_config.json:

{
    "client_id": "359f8c9f-d555-40ff-a036-ce95432e708b",
    "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "tenant": "mytenant"
}

Finally, run pytest then build the package:

pytest
python setup.py bdist

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-dsv-sdk, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size python_dsv_sdk-0.0.1-py3-none-any.whl (9.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size python-dsv-sdk-0.0.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page