Skip to main content

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

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.1.1.tar.gz (16.5 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.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dekeyrej_secretmanager-1.1.1.tar.gz
  • Upload date:
  • Size: 16.5 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.1.tar.gz
Algorithm Hash digest
SHA256 acb6e78f849ac3bab20585b49535f5ab4236e8607bfe850a48a54a6f26dac8a3
MD5 f389687afd5cddb9b916d4e04e5978fc
BLAKE2b-256 f44e0b80174a50aab4d2e7b413122ce26f4eb7ab2b3b115a86243411f8ede941

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dekeyrej_secretmanager-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3fbe5ae5ad5341b89b8375ff7d136fc3ea2d359472be7708317f6f70b5199188
MD5 00e920108e2992b64acc0ba9885f34c6
BLAKE2b-256 db9ad17bddc1f00cdb17db004d79edaa81e83faa9895822f26c32a7ed6985484

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