Skip to main content

Minimal configuration handling supporting hashicorp vault.

Project description

plainconf

Attempts to help build sensible configuration for python projects.

  • provide settings via toml file, keyword arguments or environment variables

  • read secrets from toml file or vault or both

  • can load environment variables from .env file

  • supports environments

  • allows to set path and mount point in vault

Uses hvac and python-dotenv

Limitations

  • Only supports userpass and token authentication on Hashicorp Vault

  • Only works with kv secret engine

  • Only supports toml

(for now)

Examples

With files

.mysecrets.toml:

[development]
password = 'secret'


conf = Plainconf(
    secrets_file='.mysecrets.toml', 
    settings_file='mysettings.toml',
    environment='development'
)

...

conf.password ("secret")

With vault

on the vault:

somewhere/development:
password = 'supersecret'


conf = Plainconf(
    vault_url="http://localhost:8200",
    vault_token="hvs.abc123def456",
    vault_mount_point="somewhere",
    environment="development"
)

conf.password ("supersecret")

Enviroment from env

.env file:

PLAINCONF_ENVIRONMENT="development"
PLAINCONF_VAULT_TOKEN="hvs.something123"
PLAINCONF_VAULT_URL="http://development.vault:8200"

conf = Plainconf()
conf.password ("supersecret")

Settings

Plainconf(settings_file='path_to_file') or environment variable SOBERCONF_SETTINGS_FILE="..."" or default: plainconf_settings.toml

Settings are read from the respective environment (default: default)

Secrets

Plainconf(secrets_file='path_to_file') or environment variable SOBERCONF_SECRETS_FILE="..."" or default: .plainconf_secrets.toml

Secrets are read from the environment (default: default)

Environments

Plainconf(environment='name') or environment variable SOBERCONF_ENVIRONMENT="..."" or default: default

Vault

Hashicorp Vault can be accessed via token or userpass.

Required configuration:

  • Plainconf(vault_url='http...') or environment variable SOBERCONF_VAULT_URL

  • Plainconf(vault_mount_point='name') or environment variable SOBERCONF_VAULT_MOUNT_POINT

and either a token

  • Plainconf(vault_token="hvs...") or SOBERCONF_VAULT_TOKEN

or user and pass

  • Plainconf(vault_user='user', vault_pass='password') or SOBERCONF_VAULT_USER and SOBERCONF_VAULT_PASS

Optional:

  • Plainconf(vault_path='secret/special...') or SOBERCONF_VAULT_PATH or default: environment (see above)

Plainconf tries to connect to the vault kv secrets engine v2 by default and v1 thereafter.

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

plainconf-0.1.4.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

plainconf-0.1.4-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page