Skip to main content

Modular secret management with Vault, Kubernetes, Environment and file backends.

Project description

SecretManager

MIT License Last Commit Repo Size PyPI codecov 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.1.4.tar.gz (16.9 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.1.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dekeyrej_secretmanager-1.1.4.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for dekeyrej_secretmanager-1.1.4.tar.gz
Algorithm Hash digest
SHA256 1df4910420529c40c3a19a500a688754e93e573ba04de7092ad56250c8f8cfe0
MD5 1712dc16aeadf0c0b7853cfc32340235
BLAKE2b-256 1c958d68cf106d5d49ea16331680f54f447cdf6287ca82ef103c496543ec747c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dekeyrej_secretmanager-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ea27b4fb510ca1f213ce6d119d198ae227755f8f469aefa95d15b3652fbc548c
MD5 dec5582c0e27e19bc849673c27116f04
BLAKE2b-256 f8d304874d2d037b719cbc8576df0722107485d621c7c0d55a49c0339cbd61b4

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