Skip to main content

Hanzo KMS SDK - Secret management for Python

Project description

Hanzo KMS - Python SDK

Official Python SDK for Hanzo KMS - Secret management for your applications.

Installation

pip install hanzo-kms

Or with uv:

uv add hanzo-kms

Quick Start

from hanzo_kms import KMSClient, ClientSettings, AuthenticationOptions, UniversalAuthMethod

# Initialize client
client = KMSClient(ClientSettings(
    site_url="https://kms.hanzo.ai",
    auth=AuthenticationOptions(
        universal_auth=UniversalAuthMethod(
            client_id="your-client-id",
            client_secret="your-client-secret",
        )
    )
))

# List all secrets
secrets = client.list_secrets(
    project_id="my-project",
    environment="production"
)

for secret in secrets:
    print(f"{secret.secret_key}: {secret.secret_value}")

# Get a specific secret
db_url = client.get_value(
    project_id="my-project",
    environment="production",
    secret_name="DATABASE_URL"
)

# Inject all secrets into environment
client.inject_env(
    project_id="my-project",
    environment="production"
)

Environment Variables

The client can be configured via environment variables:

export HANZO_KMS_URL="https://kms.hanzo.ai"
export HANZO_KMS_CLIENT_ID="your-client-id"
export HANZO_KMS_CLIENT_SECRET="your-client-secret"

Then simply:

from hanzo_kms import KMSClient

client = KMSClient()  # Uses environment variables
secrets = client.list_secrets("my-project", "production")

Authentication Methods

Universal Auth (Recommended)

from hanzo_kms import KMSClient, ClientSettings, AuthenticationOptions, UniversalAuthMethod

client = KMSClient(ClientSettings(
    auth=AuthenticationOptions(
        universal_auth=UniversalAuthMethod(
            client_id="...",
            client_secret="...",
        )
    )
))

Kubernetes Auth

For workloads running in Kubernetes:

from hanzo_kms import KMSClient, ClientSettings, AuthenticationOptions, KubernetesAuthMethod

client = KMSClient(ClientSettings(
    auth=AuthenticationOptions(
        kubernetes=KubernetesAuthMethod(
            identity_id="your-identity-id",
            # Uses default service account token path
        )
    )
))

AWS IAM Auth

from hanzo_kms import KMSClient, ClientSettings, AuthenticationOptions, AWSIamAuthMethod

client = KMSClient(ClientSettings(
    auth=AuthenticationOptions(
        aws_iam=AWSIamAuthMethod(
            identity_id="your-identity-id",
        )
    )
))

API Reference

KMSClient

Method Description
list_secrets(project_id, environment, path="/") List all secrets
get_secret(project_id, environment, secret_name) Get a single secret
get_value(project_id, environment, secret_name, default=None) Get just the value
create_secret(project_id, environment, secret_name, secret_value) Create a secret
update_secret(project_id, environment, secret_name, secret_value) Update a secret
delete_secret(project_id, environment, secret_name) Delete a secret
inject_env(project_id, environment, overwrite=False) Inject into os.environ

Compatibility

This SDK is compatible with:

The InfisicalClient alias is provided for drop-in compatibility:

from hanzo_kms import InfisicalClient  # Same as KMSClient

License

MIT License - see LICENSE for details.

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

hanzo_kms-1.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

hanzo_kms-1.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file hanzo_kms-1.1.0.tar.gz.

File metadata

  • Download URL: hanzo_kms-1.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hanzo_kms-1.1.0.tar.gz
Algorithm Hash digest
SHA256 13242266012dcc2a1b48705b48704504409f21c13ec022c32385f952cf4b9f8b
MD5 d432a3f51adb70ddb253b0cf5dbb9b85
BLAKE2b-256 6d78c459ae92072e55d94e6b0718d927fb2801c06ea8ef8a5cacc417c237b385

See more details on using hashes here.

File details

Details for the file hanzo_kms-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: hanzo_kms-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hanzo_kms-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19ec34ae131917e153feade770f4aa03366ba43a662fba040d3e31cd78dd2fd3
MD5 3a9a1725f6ceda5633d6b76514dd8f7d
BLAKE2b-256 801377301a5216f4f3c85689061e590f606086f32f26bb0ea7a86ce850223e04

See more details on using hashes here.

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