Skip to main content

Reusable Pydantic BaseSettings loader for Keycloak-secured Envy environments

Project description

nextpertise-envy-settings

A reusable Pydantic BaseSettings subclass that fetches environment variables from an Envy API using a Keycloak-secured token. It automatically writes these variables to a .env.envy file and prepends it to your environment configuration.


✨ Features

  • ✅ Compatible with Pydantic v1
  • 🔐 Uses OAuth2 client credentials flow via Keycloak
  • 📄 Automatically fetches and stores .env.envy
  • 🧠 Prepend .env.envy to Pydantic's env_file list
  • 🛡 Graceful fallback to existing file if API fails

📦 Installation

poetry add envy-settings

Or with pip:

pip install envy-settings


⸻

🚀 Usage

from envy_settings import EnvySettings

class Settings(EnvySettings):
    mysql_user: str

    class Config(EnvySettings.Config):
        envy_url = "https://myenvy.com"
        envy_keycloak_url = "https://mykeycloak.com/realms/realm"
        envy_keycloak_client_id = "your-clientid"
        envy_keycloak_token = "your-client-secret"
        envy_environment = "your-environment"
        env_file = (".env",)


⸻

🔧 Environment Variables (optional)

Instead of hardcoding the config, you can also use these environment variables:

Variable	Description
ENV_API_BASE_URL	Base URL for Envy API
ENV_API_KEYCLOAK_URL	Keycloak realm URL
ENV_API_KEYCLOAK_CLIENT_ID	OAuth2 client ID
ENV_API_KEYCLOAK_TOKEN	OAuth2 client secret
ENV_API_ENVIRONMENT	Target environment name


⸻

📁 Example .env.envy

MYSQL_USER=abc
MYSQL_PASSWORD=xyz
REDIS_HOST=localhost

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

nextpertise_envy_settings-0.2.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nextpertise_envy_settings-0.2.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file nextpertise_envy_settings-0.2.0.tar.gz.

File metadata

  • Download URL: nextpertise_envy_settings-0.2.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.8 Darwin/23.4.0

File hashes

Hashes for nextpertise_envy_settings-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a9b91d102a0cadad0f22896baa45d9babdcf2ceaecc2a0e58fc57a794e55d56e
MD5 e51c2cf717765c2cee56b77e48547997
BLAKE2b-256 b1737ff6514dad5a9ef8c3c23094bb74a9f61207fa3c9842ecca192ffed5c815

See more details on using hashes here.

File details

Details for the file nextpertise_envy_settings-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nextpertise_envy_settings-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7511b5e3633846ab4272a0b7ad43eeabf11aae5f5ec019592bb185df7259a051
MD5 8d17afd2aa24ea36f2b4f719272e3893
BLAKE2b-256 2bbb61a5b5f3c59ad4b95fba3f5059f9d63b17b619894ea4aa7d241b4c3d4aae

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