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(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 sensitive data.
It provides the following fields:
- secret_version_id
- secret
- version
- data
- created_at
- status
read_string(path)
Retrieve a secret as a string.
secret = client.read_string("path/to/secret")
exists(path)
Check if a secret exists at path
.
secret_exists = client.exists("path/to/secret")
write(path, secret)
Write a secret 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)
Fetch the value of a secret from SecretHub, when the ref
has the format secrethub://<path>
, 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.
For example, if the following two environment variables are set:
MY_SECRET=secrethub://path/to/secret
OTHER_VARIABLE=some-other-value
Then the following call to ResolveEnv()
resolved_env = client.resolve_env()
would lead to the resolvedEnv
containing the following contents:
{
'MY_SECRET': 'the value of the secret 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 secret references in the environment:
client.export_env(client.resolve_env());
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
Hashes for secrethub-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81e6707ada455b5459784b9f2b77c1aa7d4e9fe488ecec24d32da701bbef76ec |
|
MD5 | ba549d8bd7044d6f12025229580eb672 |
|
BLAKE2b-256 | c727aee1a04a27b91c7a7442c46029adf8ff4d32f58eaa102763f019252e9fc4 |
Hashes for secrethub-0.1.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb16b5260c80f10fe1d6f15219406d96e46b0c459b30f58046d9260dc1f21728 |
|
MD5 | 5442e78bce4775006bfdc9693cd352bb |
|
BLAKE2b-256 | 95f551aefee98c3cc44ce65b694ab55fdd0ae54f173fbe72c0cefd2b78070b7d |
Hashes for secrethub-0.1.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe62c62f3d8a0449bd945b79a773d010b99b33ededeabbf32e54342d3943e21 |
|
MD5 | 54e163afd566752da81ace68bd22511d |
|
BLAKE2b-256 | 7bf883c0fba767994181b76bb012e0bb78118d93d7ff87d033f85458d37faff9 |
Hashes for secrethub-0.1.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 317534007091a6298cf12ed1e3187ebdbbe81f36c48568e1fc0c6024897d90f9 |
|
MD5 | f767bf32d31f232c88388044af04f123 |
|
BLAKE2b-256 | 120b6fc697ca44b0964a601c13a21b47b6034f8340c320dc02e88f6805eb4993 |
Hashes for secrethub-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4591b42fe1aa7807d1384748eaa0b7e046e99b1a1b424ac61e1afdd1c6d816e3 |
|
MD5 | e08257b060044b6fb04d90bdebfdbca8 |
|
BLAKE2b-256 | 1ae023c064657d49c4d7bafb0c557dd22db4ed291269a4ec425b92e035b2e777 |
Hashes for secrethub-0.1.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55ca2e8cc1e3a91052a76f3423711998ebb239f3475b5bbb98de896a4c7b6e7e |
|
MD5 | d6d185468153a9720c18732575cc088b |
|
BLAKE2b-256 | 4816246f4fc4a8d5637a4bb3a66bd88d801468a76121e7f4ed61295329021efb |
Hashes for secrethub-0.1.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b535e8cfd1867e305d02c094e32de085d83cc1f3094988fab50bf5eb7dec572 |
|
MD5 | c4a340ac53628145cfc52cabf801eb8d |
|
BLAKE2b-256 | 858706c560253fd5324708dea425ae057ab675dc27885e4cef7539113ec874bc |
Hashes for secrethub-0.1.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0948cd5650c131f31ea4536624de1262403afde6dca5d1c6a822108442d9fe54 |
|
MD5 | 087bd4fc4e085916849de299a789b157 |
|
BLAKE2b-256 | e71185d59b246eb0beb98eb167d3d5d32b8a9e7dbbca0974df50a2f4709c4008 |
Hashes for secrethub-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33109623e38899e1e92382e749bf93bee0bb6ed0367a9bec21fb56a2160e0907 |
|
MD5 | 37334c0c5fa48d1c21c5357ccd020b38 |
|
BLAKE2b-256 | 40d13c87256ea45f32617d6ec29cfe0850c63ffd8e9732d35bd19225250cf205 |
Hashes for secrethub-0.1.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2334a73d1361ccc1c607d1af3e4c455e56d888005d4b29c75fd20f11dad5d2 |
|
MD5 | f2d28e856bc1583fb7006257940874af |
|
BLAKE2b-256 | 606fd17913fe318fe46b82ae4fba9e73b4e0dd8c346f0db7648161d3fcf761a6 |
Hashes for secrethub-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38e1b5fec887c364f6b02b99ea758200aa66c1bc45e56f28d2bd3a78ff279799 |
|
MD5 | 54c0c7a3e07de087d0c947cd5f7c73b4 |
|
BLAKE2b-256 | 73afb6ef3076d151bb8ccdebcfc9e10a28e0d2902f85df6accc3999e74a6e249 |
Hashes for secrethub-0.1.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abec60dcd67f6c581069844fc406b8a918944331f7a5e8954ea3f9fef72fb9eb |
|
MD5 | bc580f95f96018ccdb73bcd5fd491090 |
|
BLAKE2b-256 | b5f79e0fe572c615466bcac0c50e67cd0dcfeb16ed68bcd07212e72e0d21a990 |
Hashes for secrethub-0.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08685bd067f33df7674625766cc9b0c3db1b88a3c0ad4ea7a66446399715bd5e |
|
MD5 | 9e6ebb2b61d4f895b6e7d91a8c173c49 |
|
BLAKE2b-256 | c450e64883a55182c38eca4a6c99493e157a437ee226591feb17bf0205e6e191 |
Hashes for secrethub-0.1.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3eabd2cc34bfd19a08a4c6b587d8ddd0a3f620df9c5f88c6e203462e9332299 |
|
MD5 | 1a96a921771468543c651f176265dacf |
|
BLAKE2b-256 | a6b4609a7e3125817d9a622839e7b2d6112fd8a613858b841e470d5ee3e138ae |
Hashes for secrethub-0.1.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4668903dbb990000d5514d0fd50b2f30e7618faa58708a585052d87ccba56812 |
|
MD5 | f3cb9ce1f61b1db2a21a6c14fed9f543 |
|
BLAKE2b-256 | 14578828edc63c6bed7c6364d19872380e64a7b76c2de47072c272e8b0d9ee35 |
Hashes for secrethub-0.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9910c0f30a0633270fd8ad285161a0bbda2d353155f435c241cd2aec51966c2b |
|
MD5 | 704ddb21401a0476e397d3191ebc1ddd |
|
BLAKE2b-256 | 97e6406b436cfb15298f8f63efdc9c318275079fb0bf1f1b166c9e32a52ca374 |
Hashes for secrethub-0.1.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a14a183701d82da8c7fe25fc4b123955f803803c51743ac495accf815d9f35c |
|
MD5 | d328380fa46067b86781d4ce05ef3967 |
|
BLAKE2b-256 | 4f2a87c994a09d32a29ebd6ea921de11117b096c8350e57fca7d0cf2bf5adf8a |
Hashes for secrethub-0.1.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1fb0ca3b6f1a5b79611a2dac2485422993d59e7666cf9928f2542273261c2cc |
|
MD5 | 3466a79d38278364809f9886c9edd1cf |
|
BLAKE2b-256 | f4b98c6f4010668e6a3ea58e86348e53586f1bb025819aa392e1e38c41e62a03 |
Hashes for secrethub-0.1.0-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc9dc82705c907346964e1f2330848bf5fc698e49c060be9604568aed8ede9d2 |
|
MD5 | 3cc2f9b4d8b0e13ada1c5ac16cc5f7a7 |
|
BLAKE2b-256 | 8049a831a55affadeddcebc58adcaaf9f0c0bb82348d6bbd202d09a2684032f3 |
Hashes for secrethub-0.1.0-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd165102750e0711759c8540d5762e840f75e8cf2170c09b320429307b09d4d1 |
|
MD5 | 491684fdbed04490143cf9030cc38fe3 |
|
BLAKE2b-256 | 510d1556d96608a0fcedd16f339b0d5dc58b4cdca6210dacf8597c8d481a4b63 |