Skip to main content

Thycotic Secret Server Reader

This Python module allows to retrive secrets from Thycotic Secret Server. It utilizes the REST API

see: https://docs.thycotic.com/ss/10.8.0/api-scripting/rest-api-reference-download

License

MIT

Installation

Installation with PyPi:

pip install secread

Installation with poetry:

poetry add secread

Configuration

To configure the module use following environment variables. It is also possible to provide the file '.env' with the settings

# copy the template as environment file
cp .env.example .env

# Edit configuration file
vi .env
#############################################################################
# Settings for Thycotic Secret Server Reader

SECRET_SERVER_SITE='https://pw.example.com/SecretServer'
SECRET_SERVER_AUTH_API='/oauth2/token'
SECRET_SERVER_USERNAME='apiuser'
SECRET_SERVER_PASSWORD='my_password_for_apiuser'

# Values for SECRET_SERVER_SSL_VERIFY
# - True    server certificate will be verified (Default)
# - False   server certificate will be ignored; warning
# - Path    path to trusted cerificate bundle e.g. '/etc/ssl/certs/ca-bundle.trust.crt'
SECRET_SERVER_SSL_VERIFY='/etc/ssl/certs/ca-bundle.trust.crt'

# Default field-items to extract from result.
SECRET_SERVER_DEFAULT_SLUGS='["id", "url", "username", "password"]'

# SECRET_SERVER_IS_DUMMY (Default: False)
# - False: Secert-Server-API is active
# - True: The API will not be used. SECRET_SERVER_TEST_DUMMY_RESULT will be returned
# SECRET_SERVER_IS_DUMMY=False

SECRET_SERVER_TEST_DUMMY_RESULT='{"id": "12345", username": "testuser", "password": "testpassword", "url": "https://localhost/SecretServer"}'

# 'name' of the secret that is used for testing on live server
# TEST_SECRET_NAME='GitLab Token netsearch-ro'

Development

The installation instruction for poetry is here: https://python-poetry.org/docs/#installation

git clone https://github.com/jifox/secret-server-reader.git
cd secret-server-reader

# Set python environment to use for development
# poetry env use python3.8

# Install the module
poetry install

# Execute tests (be sure to configure the system before)
poetry run pytest -v

Update pypi

Before updating pypi, the version number must be incremented in following files:

  • pyproject.toml
  • secread/init.py
  • secread/tests/test_secread.py
poetry build
poetry publish

Examples

"""Tests for module secread"""
import os
import pytest
from secread import __version__, SecretServer


def test_version():
    assert __version__ == "0.1.1"


@pytest.fixture
def sec_server():
    return SecretServer()


def test_default_slugs_is_a_list(sec_server: SecretServer):
    slugs = sec_server.SECRET_SERVER_DEFAULT_SLUGS
    assert isinstance(slugs, list)


def test_secretserver(sec_server: SecretServer):
    token = sec_server.getAuthToken()
    assert len(token) > 0, "Token could not be read"


def test_get_secret_response_by_name(sec_server: SecretServer):
    secname = os.getenv("TEST_SECRET_NAME", "GitLab Token netsearch-ro")
    res = sec_server.searchSecretResponse(secname)
    fields = sec_server.getFieldItemWithSlug(res)
    assert "username" in fields.keys(), "Missing username"
    assert "password" in fields.keys(), "Missing password"


def test_get_secret_by_name(sec_server: SecretServer):
    secname = os.getenv("TEST_SECRET_NAME", "GitLab Token netsearch-ro")
    res = sec_server.searchSecret(secname)
    assert "username" in res.keys(), "Missing username"
    assert "password" in res.keys(), "Missing password"

Metadata

Release files for secread 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for secread 0.1.4
File Size Uploaded Provenance Actions
secread-0.1.4.tar.gz 8.4 kB Without provenance Details for secread-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for secread 0.1.4
File Interpreter ABI Platform Actions
secread-0.1.4-py3-none-any.whl Python 3 none any Details for secread-0.1.4-py3-none-any.whl

Total release size: 16.7 kB

Release files / secread-0.1.4.tar.gz

Download URL secread-0.1.4.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
13e4d93543a1b7d6b5057e6836cb8a7432343837e344ee9ae1a38e53a3014332
BLAKE2b-256 checksum
How to use checksums
83a009cd90755b437cfbcf6457e877a89a494422aadfb597f6ef00fe78b286ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.8.10 Linux/3.10.0-1160.45.1.el7.x86_64

Release files / secread-0.1.4-py3-none-any.whl

Download URL secread-0.1.4-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61597fe714c863ceea150ced0ae2e29241246838e31c865376cc5459e1b7f0da
BLAKE2b-256 checksum
How to use checksums
f8899593589ebb16b2e38d3ac25e5689b26791284a5fb9a8228e8c8f9ac8785b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.8.10 Linux/3.10.0-1160.45.1.el7.x86_64

Security for secread 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page