Writing different code to load secrets in local development versus production Docker Swarm creates deployment headaches. wauth's DriverFactory automatically reads Docker secrets in containers and falls back to encrypted vaults locally.
Here is the exact production implementation for Dual-Driver Architecture & Docker Swarm Integration:
from wauth.drivers import DriverFactory
# Factory automatically selects DockerDriver in containers, LocalDriver locally
factory = DriverFactory()
# Inside Docker: reads /run/secrets/db_password
# Outside Docker: reads encrypted local SQLite vault
db_password = factory.get_value("db_password")
print(f"Loaded credentials securely via: {factory.driver_name}")
Why this changes developer velocity:
-
Auto-Detect Environment:
DriverFactorydetects whether it is running inside a Docker container. - Native /run/secrets: Mount Docker Swarm and Compose secrets securely in RAM.
- Graceful Fallback: Falls back to local encrypted SQLite vault seamlessly in development.
Zero Pain:
- Writing different secret-loading code for local development versus production Docker containers
- Exposing secrets in Docker environment variables where
docker inspectcan read them - Hardcoded paths to
/run/secretsthat crash when tested outside of Docker
Explore the verified open-source repository on GitHub or install it via:
pip install wauth
Top comments (0)