Skip to main content

Python SDK for Hush secret access via SPIFFE mTLS

Project description

hush-am-sdk-python

Python SDK for fetching secrets from the Hush access-manager via SPIFFE mTLS.

Requirements

  • Hush-am access-manager deployed in the cluster.
  • A SPIRE agent reachable in the pod (provides the SPIFFE SVID for mTLS).
  • The pod's workload identity is bound to a Hush policy granting access to the requested secrets.

Error handling

All SDK errors derive from HushError. Catch the base class for a generic fallback, or the specific subclasses where the caller can do something useful:

from husham import HushClient, HushSecretNotFoundError, HushError

try:
    with HushClient() as hush:
        creds = hush.get_secret("secret_name")
except HushSecretNotFoundError:
    ...  # secret missing or no access
except HushError as e:
    ...  # any other SDK failure

End-to-end example

The snippet below needs a Hush-am-instrumented runtime to actually fetch a secret — it cannot run from your laptop because there is no local SPIRE agent.

  1. Create a Hush-am policy that:

    • Includes an SDK delivery config that maps a secret to <secret_name> and maps the fields you intend to read (e.g. username, password, host).
    • Adds an attestation rule for the pod that will run the SDK, so its workload identity is bound to the policy.
  2. Install the SDK in the pod image:

    pip install hush-am-sdk
    
  3. Run this snippet inside the pod:

import sys
from husham import HushClient, HushError


def main() -> int:
    try:
        with HushClient() as hush:
            secret = hush.get_secret("<secret_name>")
            print(f"username: {secret['username']}")
            print(f"password: {secret['password']}")

            # Or fetch a single field directly:
            host = hush.get_secret_field("<secret_name>", "host")
            print(f"host: {host}")
    except HushError as exc:
        print(f"{type(exc).__name__}: {exc}", file=sys.stderr)
        return 1
    return 0


if __name__ == "__main__":
    sys.exit(main())

Additional features

Bearer token for user-claims filtering

Pass an optional bearer token to scope the request to a specific user's claims:

hush.get_secret("secret_name", token=user_jwt)
hush.get_secret_field("secret_name", "password", token=user_jwt)

Module-level helpers

Module-level convenience helpers backed by a singleton client are also available, so you don't need to manage a HushClient instance yourself:

from husham import get_secret, get_secret_field

creds = get_secret("secret_name")
password = get_secret_field("secret_name", "password")

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

hush_am_sdk-0.3.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

hush_am_sdk-0.3.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file hush_am_sdk-0.3.1.tar.gz.

File metadata

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

File hashes

Hashes for hush_am_sdk-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c8439d51ecba51b007186ee6eaff10aba83fe3cbc851f03eab37cec2af511fa9
MD5 cb759d729077ba52e9a34b6955fd8288
BLAKE2b-256 eae200451ef561638812920aca221488f4425950bea2290d3c17ab9ba36d0b5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hush_am_sdk-0.3.1.tar.gz:

Publisher: publish.yml on hushsecurity/hush-am-sdk-python

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

File details

Details for the file hush_am_sdk-0.3.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for hush_am_sdk-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62a964c96363e06ab8508be755b1783414f0f5c55716391d15c5bcf851990af9
MD5 33425d43a2654d582baf668163fffc22
BLAKE2b-256 923c408dea9e010b25e5a55df4be3e12702478ec2cf68ca8fe19c43cd7450031

See more details on using hashes here.

Provenance

The following attestation bundles were made for hush_am_sdk-0.3.1-py3-none-any.whl:

Publisher: publish.yml on hushsecurity/hush-am-sdk-python

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