Python client for the SecretHub Secrets Management API
Project description
SecretHub Client for Python BETA
This repository provides a Python client for the SecretHub Secrets Management API.
SecretHub is a secrets management tool that works for every engineer and allows you to securely provision passwords and keys throughout your entire stack with just a few lines of code.
Table of Contents
Installation
To install the SecretHub package from PyPi, run the following command:
python -m pip install secrethub
The package supports Linux, Windows (32 and 64 bit) and MacOS. It is built for CPython versions 3.5 and above.
Make sure you have created a SecretHub account and set up a credential on your system before using the library. See the Credential section for more info.
Note that passphrase protected credentials are not supported by the Python client.
Usage
Before doing any calls to the library, you need to import the secrethub package and create a client:
import secrethub
client = secrethub.Client()
After you have your client, you can call the following methods:
read_string(path)
Retrieve a secret value as a string.
secret = client.read_string("path/to/secret")
read(path)
Retrieve a secret, including all its metadata.
secret = client.read("path/to/secret");
The returned object is of the secrethub.SecretVersion type and it represents a version of a secret with the sensitive value stored in the data field.
It provides the following fields:
- secret_version_id
- secret
- version
- data
- created_at
- status
exists(path)
Check if a secret exists at path.
secret_exists = client.exists("path/to/secret")
write(path, secret)
Write a secret value to a given path.
client.write("path/to/secret", "secret_value")
remove(path)
Delete the secret found at path.
client.remove("path/to/secret")
resolve(ref)
Resolve a secret reference tag of the format secrethub://<path> and return the corresponding secret value. If ref is not a valid reference tag, it returns otherwise it returns ref unchanged.
resolved_ref = client.resolve("secrethub://path/to/secret")
resolve_env()
Return a dictionary containing the OS environment with all secret references (secrethub://<path>) replaced by their corresponding secret values.
Example
os.environ['MY_SECRET'] = 'secrethub://path/to/secret'
os.environ['OTHER_VARIABLE'] = 'some other value'
resolved_env = client.resolve_env()
print(resolved_env)
# Prints all environment variables with any secret references resolved to their corresponding value
# {
# 'MY_SECRET': 'the value of the secret stored at path/to/secret',
# 'OTHER_VARIABLE': 'some other value'
# }
export_env(env)
Adds the environment variables defined in the env dictionary to the environment of the process.
If any of them are already present in the environment, they will be overwritten.
This method can be used together with resolve_env to resolve all environment variables with secret references and set them to their corresponding secret value. Note that we recommend you use client.resolve_env() for most cases, but if your code reads its configuration from the environment and cannot be adapted to use the result of client.resolve_env() directly you can use it together with export_env().
Example
os.environ['MY_SECRET'] = 'secrethub://path/to/secret'
client.export_env(client.resolve_env());
print("secret: " + os.environ['MY_SECRET']);
# Prints the value of the secret stored at path/to/secret.
Exceptions
Any error encountered by the SecretHub client will be thrown as a RuntimeError with the full error message as an associated string value.
try:
client.read('path/to/secret')
except Exception as e:
print(e)
Credential
To use the SecretHub Python client, you need to provide a credential for your SecretHub account. You can sign up for a free developer account here.
After signup, the credential is located at $HOME/.secrethub/credential by default.
secrethub.Client() automatically uses this credential.
You can also provide a credential through the SECRETHUB_CREDENTIAL environment variable.
Getting Help
Come chat with us on Discord or email us at support@secrethub.io
BETA
This project is currently in beta and we'd love your feedback! Check out the issues and feel free suggest cool ideas, use cases, or improvements.
Because it's still in beta, you can expect to see some changes introduced. Pull requests are very welcome.
For support, send us a message on Discord or send an email to support@secrethub.io
Developing
Note that most of the code in this repository is automatically generated from the SecretHub XGO project, which wraps the secrethub-go client with cgo exported functions so it can be called form other languages, e.g. C, C#, Python, Ruby, NodeJS, and Java. To generate the code SWIG is used.
See the SecretHub XGO repository for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secrethub-0.1.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 9.7 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87d7067332b9e9819cd9717bc78ae60cd6980de01568cdc9290cd09ab3f059dd
|
|
| MD5 |
db0fd85d50624b3f321979f1101949fe
|
|
| BLAKE2b-256 |
c46c3c5410797f892c38dc6105cc349a47463d3b7cd919a92567ee2e9a3ae32d
|
File details
Details for the file secrethub-0.1.1-cp39-cp39-win32.whl.
File metadata
- Download URL: secrethub-0.1.1-cp39-cp39-win32.whl
- Upload date:
- Size: 9.4 MB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd116d5188908f490dbfec75061863ef5312e3e8666f7fcf9d2d71ec371a91b4
|
|
| MD5 |
76094c794cab2a9189da94b0753fc1a4
|
|
| BLAKE2b-256 |
41d570170945074d9e589ab00f144897a8407b10841ca79df2eaa89b0fb43b48
|
File details
Details for the file secrethub-0.1.1-cp39-cp39-manylinux2014_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp39-cp39-manylinux2014_x86_64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23e0933c0bda9792d1e4fa6d5498e56b09647aedf50f3ce0b8a5f32ed2ef8641
|
|
| MD5 |
8774fff107090f729499cee99a54844f
|
|
| BLAKE2b-256 |
38077f73c47e896d87a726a75bc5e6e5be147cf086a6ef9b454e2e7b41d9c1ae
|
File details
Details for the file secrethub-0.1.1-cp39-cp39-macosx_10_14_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
398cf2798d786a6f32bb3f18c55401dca7bad980b7ba60e13efe2b6250da8cca
|
|
| MD5 |
355ef8931f70bd83a55f5de9f772c730
|
|
| BLAKE2b-256 |
68f4793b3513cf3ba76318c2b2fe099bd0ecee079e1bc89ab955e817d680ad25
|
File details
Details for the file secrethub-0.1.1-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 9.7 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65b0fbaedc5e01cf28e46015c5b694424d1dc1e419702f9c0cf609fd64aec42b
|
|
| MD5 |
460607368f0dec211ac48eefa5d9f2c0
|
|
| BLAKE2b-256 |
bd0e812a8c951b1686a6d3eda4ad61fc74ee2f47bf657490fd45171c4a361bd3
|
File details
Details for the file secrethub-0.1.1-cp38-cp38-win32.whl.
File metadata
- Download URL: secrethub-0.1.1-cp38-cp38-win32.whl
- Upload date:
- Size: 9.4 MB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5339108c11fa95261aadaca9cc580f18bc5f94b38bcd25c5482e485698d53dc
|
|
| MD5 |
0563f23d55ca65b5cfdddf57fd3f3701
|
|
| BLAKE2b-256 |
66f683e5eb33ed28f42005033567b287757e0e4d6501569bed6f390a0ca19868
|
File details
Details for the file secrethub-0.1.1-cp38-cp38-manylinux2014_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dd93a05ae5060bfb708804bf6e753e04e8a974851a5c797d4c42f3855c4d169
|
|
| MD5 |
332f8e18864957e1f63f3dcd6e1108c3
|
|
| BLAKE2b-256 |
92bca2227217e8841761e0e45bb864bf089a472da09c0fd6bacc19ff52e42b4c
|
File details
Details for the file secrethub-0.1.1-cp38-cp38-macosx_10_14_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.8, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
344ee43e9e75ba822ff3e4247a4eef91253cae53a1bcd3e0631be0c3a8dad5dc
|
|
| MD5 |
523f05aa736f95f3a66f2c0d250df0b8
|
|
| BLAKE2b-256 |
d4b87d2e1c80232a53cf751304fe897b8ed6ff93edf3b573dd67635b4f68e74b
|
File details
Details for the file secrethub-0.1.1-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 9.7 MB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b6325bfe9906be15f0d56ed776ca16bd301071ad24046e46abce10b7d635e11
|
|
| MD5 |
084db5a14ef6b43b520195d34557fecd
|
|
| BLAKE2b-256 |
f53eed60a8155073ecd410ce07c906024c634668225ee26fadd170699961f8d9
|
File details
Details for the file secrethub-0.1.1-cp37-cp37m-win32.whl.
File metadata
- Download URL: secrethub-0.1.1-cp37-cp37m-win32.whl
- Upload date:
- Size: 9.4 MB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6218a3058c10bc1636fc04f6427d150fdfbeb110ca146239428fb42ff1be36ec
|
|
| MD5 |
e4a3db32f4ab3b565dfadeee9651c977
|
|
| BLAKE2b-256 |
eb6335a7bbf5595b24b7ac9b4805e644d2f97398d3fa433e7b79bf4c14a56ecc
|
File details
Details for the file secrethub-0.1.1-cp37-cp37m-manylinux2014_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp37-cp37m-manylinux2014_x86_64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57544082efb35ddc7fad6e5c845363c8a9468d106deb71bd48697a25301645d8
|
|
| MD5 |
37b3d6efa5e915ea2e735154be86771c
|
|
| BLAKE2b-256 |
fd956bf8aefbdd7a3f71aa334784fae40058393f83a6d55529bbf6af49645f16
|
File details
Details for the file secrethub-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a007faf7d36742fc7530fe50d89fa0b8dcd3cbb76c322f8dc8fac7fbbf7b0a97
|
|
| MD5 |
407e2b244bbb645e5f973b7bedaa8ed6
|
|
| BLAKE2b-256 |
8e37fff395c97fe601f1cb38436ce963ba946263679652950ec0569a08be2507
|
File details
Details for the file secrethub-0.1.1-cp36-cp36m-win_amd64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 9.7 MB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2f11280667c163a0ef85765d0d30fbca3292a1d160243477d0f71f29ebce839
|
|
| MD5 |
31adacc4f9d09d18c52eab49f6f238f3
|
|
| BLAKE2b-256 |
c0850fdc7e4a7f2f4f4a658a9005b0c6702cf16120e2f0f0cd445f0fb14a01be
|
File details
Details for the file secrethub-0.1.1-cp36-cp36m-win32.whl.
File metadata
- Download URL: secrethub-0.1.1-cp36-cp36m-win32.whl
- Upload date:
- Size: 9.4 MB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bed30f29c0205a633f3fec85c0af74848af5c7705312e983e88ea3f20502800
|
|
| MD5 |
e0546acbf198c97bcfcf2f7db7ba6222
|
|
| BLAKE2b-256 |
e93757a04ba72bf96a395df1b4e3e8f333a6069261f2d9df8d1632a1f759f334
|
File details
Details for the file secrethub-0.1.1-cp36-cp36m-manylinux2014_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp36-cp36m-manylinux2014_x86_64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
498191bc612418c877a6c48d0446e392e2ef82aba2739b34b08713ac2c1cdd51
|
|
| MD5 |
de0eda28508cc76cd9b4d010d1e9b228
|
|
| BLAKE2b-256 |
438a41e419be57678472131b528ecc0db420ca30f30b8e8073bfb1f4c8a5b846
|
File details
Details for the file secrethub-0.1.1-cp36-cp36m-macosx_10_14_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.6m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e51ef9b0546250a06109222a72fdcd3533a3156ce05d8dac0488562b9f6d4333
|
|
| MD5 |
2af6020d10d7ef55ba71cbb0807e96a1
|
|
| BLAKE2b-256 |
40801422a3d8c79309d952dcf61af4f50fcf67e4bfe22c71dcc4e06ee684ace9
|
File details
Details for the file secrethub-0.1.1-cp35-cp35m-win_amd64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 9.7 MB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e6beafca0eb017fdc7d661acbf6dfd4557445576148b714dd4147f64f78bad9
|
|
| MD5 |
0d8da3aaed8c2abb2f75bd532c159f94
|
|
| BLAKE2b-256 |
250de5547ca119314039d57ca8ae0af163289bdd2f519ffe267dd3f90389a67c
|
File details
Details for the file secrethub-0.1.1-cp35-cp35m-win32.whl.
File metadata
- Download URL: secrethub-0.1.1-cp35-cp35m-win32.whl
- Upload date:
- Size: 9.4 MB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
429b67e8f07c01523811cc0e915579792df404ad6f57270f964b7fdc47032617
|
|
| MD5 |
c27cab07e16fbfccc4f1202672455108
|
|
| BLAKE2b-256 |
82400707dc3b540ab2ceef209d13bd3a772c2345b83d8114332771ca1beac03d
|
File details
Details for the file secrethub-0.1.1-cp35-cp35m-manylinux2014_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp35-cp35m-manylinux2014_x86_64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
024d2b66ea5b20d151fef88fdde0157485b05c51ac3255c3bf3681a8c88732e4
|
|
| MD5 |
1c29ddb287d9a1e0291b88e447c29004
|
|
| BLAKE2b-256 |
2ed15438c8e843a80fc515974ac9523d9a00996a8cc4667f943437e30eb310dc
|
File details
Details for the file secrethub-0.1.1-cp35-cp35m-macosx_10_14_x86_64.whl.
File metadata
- Download URL: secrethub-0.1.1-cp35-cp35m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.5m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31f3c5e848098c25a25a6acf6ec351ba2bbab8e3765608eb2d4ea435a6686f95
|
|
| MD5 |
5580ff56f7ae011d43380fd7cb39ff8b
|
|
| BLAKE2b-256 |
f04ab2f40cb15c6f96697717d3159263d059d852b5c9f06ca3b6583d89667416
|