secret-loader (0.1.13)
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:
- Hardcoded values. This is purely for debugging, prototyping, and for configuring below options.
- Files pointed to by environment variables. Docker friendly.
- Secrets folder. Also Docker friendly.
- Pass: the standard unix password
manager. Most suited for personal
usage; very unsuited for server environments. Requires
pass
installed locally, and configuration of thePASS_STORE_SUBFOLDER
through one of the above methods. - 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.
- Case-insensitive for hardcoded and
- New special configuration value for switching the
secrets
directory. - Wrap secrets in intelligent strings:
- Instead of returning
None
on unloaded, returnUnknownSecret
, 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.
- Instead of returning
- Avoid leakage to swap files.
- Possibly Mlock? Does not seem to work
- Alternatively use mmap and memoryview?§
- Vault:
- Ensure vault code path works.
- Document usage and requirements.
License
MIT License
Copyright (c) 2024 Jon Michael Aanes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Requirements
Requires Python: >=3.9
Details
Assets (2)
Versions (23)
View all
secret_loader-0.1.13.tar.gz
5.4 KiB