Skip to main content

`dworshak-secret` is a light-weight library for local credential access. By adding `dworshak-secret` as a dependency to your Python project, you enable your program or script to leverage secure credentials.

Project description

dworshak-secret is a light-weight library for local credential access. By adding dworshak-secret as a dependency to your Python project, you enable your program or script to leverage secure credentials, typically added with the dworshak-prompt.Obtain().secret() function or managed directly with the dworshak CLI.

All secrets are stored Fernet-encrypted in a SQL database file. No opaque blobs — every entry is meaningful and decryptable via the library.

Example

Typical package inclusion. See below for guidance concerning Termux and iSH Alpine.

uv add "dworshak-secret[crypto]"
from dworshak_secret import DworshakSecret
from dworshak_prompt import Obtain

# Initialize the vault (create key and DB if missing)
client = DworshakSecret()
client.initialize_vault()

# Store and retrieve credentials by prompting the user on their local machine
obtain = Obtain()
username = obtain.secret("rjn_api", "username")
secret = obtain.secret("rjn_api", "password")

# ---

# Alternatively, store secrets with a script ....
## (NOT recommended to keep 'set' calls in your codebase or in system history)
client.set("rjn_api", "username", "davey.davidson")
client.set("rjn_api", "password", "s3cr3t")

## ...and then retrieve credentials in your codebase.
username = client.get("rjn_api", "username")
password = client.get("rjn_api", "password")

# ---

# List stored items
for service, item in client.list_contents():
    print(f"{service}/{item}")

Capture stdout environment variables for bash scripting by using the --emit flag

TESTSET=$(dworshak-secret set "myservice" "myitem" "myvalue" --emit)
echo $TESTSET

TESTGET=$(dworshak-secret get "myservice" "myitem" --emit)
echo $TESTGET

Running dworshak-secret set "myservice" "myitem", without including a value, will prompt the user for input, which will be hidden.

Alternatively, install the dworshak CLI and use:

TESTOBTAIN=$(dworshak prompt obtain secret "myservice" "myitem" --emit)
echo $TESTOBTAIN

This works because the multiplexer will skip the console input and route the user to the web interface or the GUI.


Include Cryptography Library

Here we cover using dworshak-secret as a dependency in your project.

The central question is how to properly include the cryptography package.

On a Termux system, cryptography can (B) be built from source or (A) the precompiled python-cryptography dedicated Termux package can be used.

Termux Installation

A. Use python-cryptography

This is faster but pollutes your local venv with other system site packages.

pkg install python-cryptography
uv venv --system-site-packages
uv add dworshak-secret

B. Allow cryptography to build from source (uv is better at this compared to using pip)

pkg install rust binutils
uv add "dworshak-secret[crypto]"

iSH Alpine installation

apk add py3-cryptography
uv venv --system-site-packages
uv add dworshak-secret

Why Dworshak Over keyring?

Keyring is the go-to for desktop Python apps thanks to native OS backends, but it breaks on Termux because there's no keyring daemon or secure fallback, leaving you with insecure plaintext or install headaches. Dworshak avoids that entirely with a portable, self-contained Fernet-encrypted SQLite vault that works the same on Linux, macOS, Windows, and Termux on Android tablets. You get reliable programmatic access via dworshak_secret.DworshakSecret().get() (or dworshak_prompt.Obtain().secret()). The Dworshak ecosystem is field-ready for real scripting workflows like API pipelines and skip-the-playstore localhost webapps. When keyring isn't viable, Dworshak just works.


CLI

dworshak is the intended CLI layer, but the dworshak-secret CLI can also be used directly.

pipx install "dworshak-secret[typer,crypto]"
dworshak-secret helptree

Screenshot of the Dworshak CLI helptree

helptree is utility function for Typer CLIs, imported from the typer-helptree library.


Sister Projects in the Dworshak Ecosystem

pipx install dworshak
pip install dworshak-secret
pip install dworshak-config
pip install dworshak-env
pip install dworshak-prompt

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

dworshak_secret-1.3.1.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dworshak_secret-1.3.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file dworshak_secret-1.3.1.tar.gz.

File metadata

  • Download URL: dworshak_secret-1.3.1.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dworshak_secret-1.3.1.tar.gz
Algorithm Hash digest
SHA256 536e7c4eabc5cf60f6d17f39cf287c15da89b367e2c310f3961542e55f0ca1e3
MD5 c8a667789a7c7716a1b79db566ddd6de
BLAKE2b-256 4937c2d5313d1b859816d085f12289145e12da0c52460edcf5f21e654c2d11c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_secret-1.3.1.tar.gz:

Publisher: publish.yml on City-of-Memphis-Wastewater/dworshak-secret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dworshak_secret-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: dworshak_secret-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dworshak_secret-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bbfaab5b75749b14372bbd2783d137c6d8af7c6785488d8cb88d06d03c28faf
MD5 f395fc4b819df7a28deb00fbc35b3c14
BLAKE2b-256 2ec43fcd91807b7dac33da315eec64544851c1db7cabef89ac1fef2f0602c8e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_secret-1.3.1-py3-none-any.whl:

Publisher: publish.yml on City-of-Memphis-Wastewater/dworshak-secret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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