Skip to main content

The Delinea DevOps Secret Vault Python SDK

Project description

The Delinea DevOps Secrets Vault Python SDK

Code style: black

PyPI Version License Python Versions

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

Install

python -m pip install python-dsv-sdk

Usage

There are two ways in which you can authorize the SecretsVault class to fetch secrets.

  • Password Authorization (with PasswordGrantAuthorizer)
  • Access Token Authorization (with AccessTokenAuthorizer)

Authorizers

Password Authorization

If using a traditional client_id and a client_secret to authenticate in to your DevOps Secrets Vault, you can pass the PasswordGrantAuthorizer into the SecretsVault class at instantiation. The PasswordGrantAuthorizer requires a base_url, username, and password. It optionally takes a token_path_uri, but defaults to /v1/token.

from delinea.secrets.vault import PasswordGrantAuthorizer

authorizer = PasswordGrantAuthorizer("https://mytenant.secretsvaultcloud.com/", "my_client_id", "my_client_secret")

Access Token Authorization

If you already have a valid access_token, you can pass directly via the AccessTokenAuthorizer.

from delinea.secrets.vault import AccessTokenAuthorizer

authorizer = AccessTokenAuthorizer("YgJ1slfZs8ng9bKsRsB-tic0Kh8I...")

Secrets Vault

Instantiate SecretsVault by passing your base_url and Authorizer as arguments:

from delinea.secrets.vault import SecretsVault

vault = SecretsVault("https://mytenant.secretsvaultcloud.com/", authorizer)

Secrets can be fetched using the get_secret method, which takes the secret_path of the secret and returns a json object. Alternatively, you can use pass the json to VaultSecret which returns a dataclass object representation of the secret:

from delinea.secrets.vault import VaultSecret

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

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

Using Self-Signed Certificates

When using a self-signed certificate for SSL, the REQUESTS_CA_BUNDLE environment variable should be set to the path of the certificate (in .pem format). This will negate the need to ignore SSL certificate verification, which makes your application vunerable. Please reference the requests documentation for further details on the REQUESTS_CA_BUNDLE environment variable, should you require it.

Create a Build Environment (optional)

The SDK requires Python 3.7 or higher.

Assuming that you have a supported version of Python installed, you can clone this repository and set up your environment with:

# Clone the repo
git clone https://github.com/DelineaXPM/python-dsv-sdk
cd python-dsv-sdk

# Create a virtual environment
python -m venv venv
. venv/bin/activate

# Install dependencies
python -m pip install --upgrade pip
pip install -r requirements.txt

Valid credentials are required to run the unit tests. The credentials should be stored in environment variables or in a .env file:

export DSV_CLIENT_ID=""
export DSV_CLIENT_SECRET=""
export DSV_BASE_URL="https://my.secretsvaultcloud.com/"

The tests assume that the client associated with the specified CLIENT_ID can read the secret with the path /test/sdk/simple.

Note: The secret path can be changed manually in test_server.py to a secret path that the client can access.

To run the tests with tox:

tox

To build the package, use Flit:

flit build

Project details


Download files

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

Source Distribution

python-dsv-sdk-1.0.4.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

python_dsv_sdk-1.0.4-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file python-dsv-sdk-1.0.4.tar.gz.

File metadata

  • Download URL: python-dsv-sdk-1.0.4.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for python-dsv-sdk-1.0.4.tar.gz
Algorithm Hash digest
SHA256 eda99948a07d86cfb5e145dd4b0d2c9a61464720af256e37a14548c37866dad3
MD5 c7e8ee4f0dfd0e6990743dc70b07cf46
BLAKE2b-256 32ce7dac17008d380d1a8ad5f55cb905eb63677d426c1c8904f981d39061b417

See more details on using hashes here.

File details

Details for the file python_dsv_sdk-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for python_dsv_sdk-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 afa2561fd79c979b8975b1d163fa10f45a2c12237014673b284ce883e2774733
MD5 1509c31e2dba11169cd4dfa843a6a374
BLAKE2b-256 1f34b28a51819d14754c325f03abcb70c5eb146390ec9a59072362a0e301e020

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page