The Thycotic Secret Server Python SDK
Project description
The Thycotic Secret Server Python SDK
The Thycotic Secret Server Python SDK contains classes that interact with Secret Server via the REST API.
Install
python -m pip install python-tss-sdk
Settings
The SDK API requires a username
and password
, and either a base_url
or tenant
.
tenant
simplifies the configuration when using Secret Server Cloud by assuming
the default folder structure and creating the base URL from a template that takes
the tenant
and an optional top-level domain (TLD) that defaults to com
, as
parameters.
When base_url
is used, the default api_path_uri
and token_path_uri
may be
overridden. The defaults values are /api/v1
and /oauth2/token
,
respectively.
Use
Simply instantiate SecretServer
or SecretServerCloud
:
from thycotic.secrets.server import SecretServer
secret_server = SecretServer("https://hostname/SecretServer", "myusername", "mypassword")
Or:
from thycotic.secrets.server import SecretServerCloud
secret_server = SecretServerCloud("mytenant", "myusername", "mypassword")
Then pass an integer id
to get_secret()
which will return the secret as a JSON
encoded string. The SDK API also contains a Secret
@dataclass
containing
a subset of the Secret's attributes and a dictionary of all the fields keyed
by the Secret's slug
.
from thycotic.secrets.dataclasses import Secret
secret = ServerSecret(**secret_server.get_secret(1))
print(f"username: {secret.fields['username'].value}\npassword: {secret.fields['password'].value}")
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-tss-sdk
cd python-tss-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('server_config.json') as f:
config = json.load(f)
They also assume that the user associated with the specified username
and password
can read the secret with ID 1
, and that the Secret itself contains username
and
password
fields.
Create server_config.json
:
{
"username": "app_user",
"password": "Passw0rd!",
"tenant": "mytenant"
}
Finally, run pytest
then build the package:
pytest
python setup.py bdist
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 Distribution
Built Distribution
File details
Details for the file python-tss-sdk-0.0.1.tar.gz
.
File metadata
- Download URL: python-tss-sdk-0.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b1ec8f28b69340ac8e70d825ad6153c53dc6c107d38dbaa8fea97556461f5f0 |
|
MD5 | a1806fdc5dda703eadbdeedd216e3609 |
|
BLAKE2b-256 | ed51263ee91a7d5056a9717924a7e228ff71c23c6444166c269a6bf5c25b76d3 |
Provenance
File details
Details for the file python_tss_sdk-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: python_tss_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26ff125057222a0648b02b93723c514fd70f82d93a5beeb7949e8e16ea11d5b0 |
|
MD5 | 5fc19722f87fad3b56ccf234909ec5f6 |
|
BLAKE2b-256 | ebfcadeaaced2fcb3d71be65174b73b231c86fb944ee174d36963bef9252b086 |