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.5.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.5-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dekeyrej_secretmanager-1.1.5.tar.gz
Algorithm Hash digest
SHA256 8d0fe78064271c68f27256b5a88974822980b786ebeffa955f37ae704cd84968
MD5 624c9ff622e148dcb4475bfca85b28c7
BLAKE2b-256 e8d0f3fb68d00e794612ceb603f78528aaa6b6e3e2be43dc2d1c9f481eb67a24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dekeyrej_secretmanager-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 72f563e3ec783ea724e2e1441063f5f84eab7895c474a4cfb476ad358c0ecd50
MD5 646a09766c73106cc066a2a667a0b508
BLAKE2b-256 ff7ca2d1b3492dcbafe13f0678c5d9dbbc9453da870e01feed3caa1f7f3547d3

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