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 nextpertise-envy-settings

Or with pip:

pip install nextpertise-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.3.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.3.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nextpertise_envy_settings-0.3.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.3.0.tar.gz
Algorithm Hash digest
SHA256 de3cc3dcf56b78c9e722f3abfec113a101e17b1248ae8130c107e309bed47656
MD5 dcb94379097605d66cfbfa1998cf151f
BLAKE2b-256 0246895fbca39c62d3b753d4832fa06e4fa2990f7dc59a653dbba016151cb9c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nextpertise_envy_settings-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec0d0268a1b565d081be3184ef899255224c2b78d706f1ad88f30bf3e28b7dab
MD5 90284d2d2b29f73e328c96c03e86fdef
BLAKE2b-256 d8a6dc1eac34d5743d8933aafb895e05ad994fc59f9b978eb423d778c5af9cbc

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