Skip to main content

base classes for microservice servers and matrix display pages

Project description

SecretManager

MIT License Last Commit Repo Size PyPI Build Status

Important note!

With no gymnastics, this works with Python 3.12 and earlier. It may fail with Python 3.13 (or later) — see details for a fix here

Why SecretManager?

Where does the first secret live?

Kubernetes provides mechanisms for working with secrets—but not securely storing or transporting them. Traditional approaches often leave “Secret Zero” exposed in environment variables, mounted volumes, or static keys.

This project implements a Zero Trust, ephemeral authentication solution for managing your Kubernetes secrets securely, leveraging HashiCorp Vault as an encryption-as-a-service backend.

Originally built to harden my homelab, this is a practical tool for anyone facing that lingering security question: “How do I bootstrap secrets without leaking them?”

Design Principles

  • Secrets stored as Vault-encrypted ciphertext in Kubernetes
  • Vault Transit used as the encryption backend (AES-256)
  • Kubernetes auth ensures no standing credentials are ever stored
  • Vault tokens are short-lived (10s or less) to reduce exposure
  • AES key material never touches disk or memory
  • Automated key lifecycle hygiene via Vault key rotation

Project Components

  • **encryptonator.py**: One-time or occasional encryptor for secrets JSON; stores ciphertext in Kubernetes Secret after vault-encrypted transit encryption.
  • **kubevault_example.py**: Reads ciphertext from Kubernetes and decrypts it via Vault Transit — intended as an init routine for microservices. Secrets live only in ephemeral Python objects.
  • **recryptonator.py**: Rotates your Vault Transit key. Pulls ciphertext, decrypts, rotates key, re-encrypts with new key, pushes new ciphertext to Kubernetes. Designed to run as a CronJob (mine is daily at 3:00 AM).

All connection and secret metadata are defined in config dictionaries. Policies follow a least-privilege model (see encryptonator/my-app-policy.hcl).

A Brief History of Failing Forward

This repo evolved through a series of failed or insecure (but educational) strategies:

  1. Secrets in image: wildly insecure, but good for offline dev.
  2. Encrypted SecureDicts: better, but required bundling an AES key.
  3. "One secret to rule them all": stored whole dict in Kubernetes, loaded at runtime, then wiped—still shaky.
  4. YAML-based env config split: functional and easy but insecure.
  5. This: Vault + short-lived auth + encryption-as-a-service + automatic key rotation = peace of mind.

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

dekeyrej_secretmanager-1.0.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

dekeyrej_secretmanager-1.0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file dekeyrej_secretmanager-1.0.2.tar.gz.

File metadata

  • Download URL: dekeyrej_secretmanager-1.0.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dekeyrej_secretmanager-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e2deffc8da13a45471d47629ecf54b42853c5468768a693dc1031f0b830f2b03
MD5 2343dacabffa3c033bd5558e087d9a5a
BLAKE2b-256 7d4d825d7bcb73edfcaa9210f56a4b33dd40e2378138815ba69a4263d9e80153

See more details on using hashes here.

Provenance

The following attestation bundles were made for dekeyrej_secretmanager-1.0.2.tar.gz:

Publisher: publish-to-test-pypi.yml on dekeyrej/secretmanager

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

File details

Details for the file dekeyrej_secretmanager-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dekeyrej_secretmanager-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4dbff81ba1f38237c7be78665bd7958e52d88c5e803281a61bbc827fc64d2208
MD5 ec01688bd2005f53b5c48fbe098a8694
BLAKE2b-256 fd6be37297828dc60d0f43ff2009ca5490f6e8c694424355efb8008072e5e3dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for dekeyrej_secretmanager-1.0.2-py3-none-any.whl:

Publisher: publish-to-test-pypi.yml on dekeyrej/secretmanager

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