secret-loader (0.1.19)

Published 2024-09-26 22:07:33 +00:00 by Jmaa in Jmaa/secret_loader

Installation

pip install --index-url  secret-loader

About this package

System for loading secrets from a variety of sources.

Secret Loader System.

System for loading secrets from a variety of sources.

Usage:

import secret_loader

secrets = secret_loader.SecretLoader(env_key_prefix='MYAPP')

db_username = secrets.load_or_fail('DATABASE_USERNAME')
db_password = secrets.load_or_fail('DATABASE_PASSWORD')

Secret loading order:

  1. Hardcoded values. This is purely for debugging, prototyping, and for configuring below options.
  2. Files pointed to by environment variables. Docker friendly.
  3. Secrets folder. Also Docker friendly. Defaults to secrets, but can be configured through the SECRETS_DIRECTORY key (NOTE: passed directly, rather than through a file.)
  4. Pass: the standard unix password manager. Most suited for personal usage; very unsuited for server environments. Requires pass installed locally, and configuration of the PASS_STORE_SUBFOLDER through one of the above methods.
  5. Vault instance if configured. Suited for production environments. NOTE: This is barely supported. Requires hvac python package.

Future extensions

  • Key casing should be more consistent
    • Case-insensitive for hardcoded and load.
    • Upper case for environment variables.
    • Lower case for files and others.
  • New special configuration value for switching the secrets directory.
  • Wrap secrets in intelligent strings:
    • Instead of returning None on unloaded, return UnknownSecret, that produce error when formatted.
    • repr(secret) should not include contents, but only the secret and how it was loaded.
    • Methods on Secret should be kept minimal.
  • Avoid leakage to swap files.
  • Vault:
    • Ensure vault code path works.
    • Document usage and requirements.
  • Get inspiration from https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html

Requirements

Requires Python: >=3.9
Details
PyPI
2024-09-26 22:07:33 +00:00
10
Jon Michael Aanes
12 KiB
Assets (2)
Versions (17) View all
0.1.19 2024-09-26
0.1.18 2024-09-04
0.1.17 2024-09-01
0.1.16 2024-08-25
0.1.15 2024-08-08