Skip to main content

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.

Metadata

Release files for dekeyrej-secretmanager 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dekeyrej-secretmanager 1.1.6
File Size Uploaded
dekeyrej_secretmanager-1.1.6.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dekeyrej-secretmanager 1.1.6
File Interpreter ABI Platform
dekeyrej_secretmanager-1.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 31.2 kB

Release files / dekeyrej_secretmanager-1.1.6.tar.gz

Download URL dekeyrej_secretmanager-1.1.6.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d997f80ab35413f25f6b29d061aab90a3b479f77a196bd32487a86a902ffd140
BLAKE2b-256 checksum
How to use checksums
144e3b0cf4e890f00f5893a5aad4fef811dfeec0e03ac3ad2f3c0961b7b786af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / dekeyrej_secretmanager-1.1.6-py3-none-any.whl

Download URL dekeyrej_secretmanager-1.1.6-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2685577d29509433ecbac27d8f7ae3fa2a23d2dde10b5c764445cc399714823a
BLAKE2b-256 checksum
How to use checksums
d66813ab142f57411b8d541170e477777e9eaac3589e6f7a71361c1a27fe02e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.1.6 This release

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.2

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page