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.1.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.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nextpertise_envy_settings-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 d18febddcb2b3c96828f0e9400c2ea7c4b157f5b5d7638121863e6ed2f6da482
MD5 0e496a16a37caa72b0b3a0ef454c4191
BLAKE2b-256 4c72b9fdf550b75780fd5671b09712c5200fda1986d92663eea5d0acef74f92d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nextpertise_envy_settings-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e789fe9925a80ebd832e5530580ee7029fbb383e9d3fda39ec7fc7d993fcbc4
MD5 3fdcc4cda29031e6452a4955efbae31d
BLAKE2b-256 af59ae575d20ce83079c3492702f32ccecaacca0d5680c3cfc187811af5123f5

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