Secrets Management
TextLayer Core provides flexible options for managing secrets and environment variables across different environments. This guide covers the various secrets management tools supported by TextLayer Core.Supported Providers
TextLayer Core supports several secrets management solutions:- Doppler (Recommended)
- Keeper
- Infisical
- HashiCorp Vault
- Centralized management for all environment variables
- Environment-specific configurations (dev, staging, prod)
- Team access controls
- Version history and audit trails
- Seamless integration with CI/CD and local development
Doppler Setup
Setting Up Doppler
Prerequisites
Before getting started with Doppler for TextLayer Core, you’ll need:- A Doppler account
- The Doppler CLI installed on your machine
- Access to your TextLayer Core project in Doppler (ask your administrator for access)
Installation
- macOS
- Linux
- Windows
Configuration
Once you have the Doppler CLI installed, you need to authenticate and set up your project:- Login to Doppler:
- Set up your project:
- Your Doppler project (select the TextLayer Core project)
- The config (environment) you want to use (e.g.,
dev,staging,prod)
Using Doppler with TextLayer Core
Local Development
There are two primary ways to use Doppler with TextLayer Core for local development:- doppler run (Recommended)
- doppler-env Package
The recommended way to run your TextLayer Core application with Doppler is to use the This approach injects environment variables at runtime without writing them to disk, providing better security.
doppler run command:Managing Secrets
Doppler provides a web dashboard and CLI for managing your secrets:- Viewing secrets:
- Setting secrets:
- Removing secrets:
Environment-Specific Configurations
Doppler allows you to manage different configurations for different environments (development, staging, production):- Switching environments:
- Running with a specific config:
CI/CD Integration
While TextLayer Core uses GitHub Actions secrets directly for CI/CD pipelines, you can integrate Doppler with your CI/CD system for consistent secrets management across all environments.GitHub Actions
To use Doppler with GitHub Actions:- Add Doppler Service Token:
- Use in GitHub Actions workflow:
Best Practices
Secret Management Workflow
-
Never store secrets in code or version control
- Use Doppler for all secrets and environment variables
- Add
.envfiles to.gitignore
-
Use descriptive names for secrets
- Follow a consistent naming pattern (e.g.,
SERVICE_CREDENTIAL_TYPE) - Use uppercase for environment variables
- Follow a consistent naming pattern (e.g.,
-
Limit access to production secrets
- Use Doppler’s access controls to restrict who can view or modify production secrets
- Use readonly service tokens for CI/CD systems
-
Rotate secrets regularly
- Set up a schedule for rotating important credentials
- Doppler maintains a history of changes for auditability
-
Use different configs for different environments
- Create separate configs for development, staging, and production
- Use config syncing for promoting changes between environments
Secure Local Development
For local development with TextLayer Core:-
Always use
doppler runinstead of.envfiles- This prevents secrets from being written to disk
- Example:
doppler run -- flask run
-
Verify your active configuration
- Check which Doppler config you’re using:
doppler configure - Ensure you’re not accidentally using production secrets in development
- Check which Doppler config you’re using:
-
Set up a personal development config
- For team environments, consider having personal configs (e.g.,
dev-john) - This prevents conflicts when multiple developers need different values
- For team environments, consider having personal configs (e.g.,
Troubleshooting
Common Issues
-
Authentication problems:
-
Wrong environment variables:
-
Doppler CLI not found:
Keeper Setup
Keeper Secrets Manager provides zero-knowledge secure storage for secrets. This section covers how to set up and use Keeper with TextLayer Core.Installation
- Python SDK
Configuration
To use Keeper with TextLayer Core:- Create a Keeper Secrets Manager account at Keeper Security
- Create a secrets manager application in the Keeper Admin Console
- Generate a One-Time Token for initializing the SDK
- Initialize the SDK with your token:
- Add the Keeper integration to your TextLayer Core setup:
keeper_secrets.py file in your project:
Infisical Setup
Infisical is an open-source secrets management platform. This section covers how to set up and use Infisical with TextLayer Core.Installation
- CLI
- Python SDK
Configuration
To use Infisical with TextLayer Core:- Create an Infisical account at Infisical
- Create a project in the Infisical dashboard
- Initialize Infisical in your project:
- Create a service token in the Infisical dashboard
- Add the Infisical integration to your TextLayer Core setup:
infisical_secrets.py file in your project:
HashiCorp Vault Setup
HashiCorp Vault is an advanced secrets management and data protection platform. This section covers how to set up and use Vault with TextLayer Core.Installation
- CLI
- Python SDK
Configuration
To use HashiCorp Vault with TextLayer Core:- Set up a Vault server or use HashiCorp Cloud Platform (HCP) Vault
- Create a policy for TextLayer Core access:
- Create a token with the policy:
- Add the Vault integration to your TextLayer Core setup:
vault_secrets.py file in your project:
Using .env Files
For local development or simple deployments, TextLayer Core supports using.env files for environment variables.
Creating a .env File
Create a.env file in the root of your TextLayer Core project:
Loading Environment Variables
TextLayer Core automatically loads environment variables from the.env file using the python-dotenv package:
Best Practices for .env Files
While.env files are convenient for local development, they have security limitations:
-
Never commit
.envfiles to version control- Always add
.envto your.gitignorefile - Consider using
.env.examplewith placeholder values as a template
- Always add
-
Limit access to
.envfiles- Restrict file permissions:
chmod 600 .env - Share secrets securely with team members
- Restrict file permissions:
-
Consider using a secrets manager for production
.envfiles are best for local development only- Use Doppler or another secrets manager for production environments
-
Validate required variables
- Add validation in your application startup to ensure all required variables are present
Choosing the Right Solution
When selecting a secrets management solution for TextLayer Core, consider:-
Team Size and Collaboration
- Doppler and Infisical excel at team collaboration
- Keeper provides strong access controls for larger teams
- Vault offers advanced policy-based access control
-
Security Requirements
- All solutions provide encryption at rest and in transit
- Keeper and Vault offer advanced security features
- Consider compliance requirements for your organization
-
Integration Needs
- Doppler has the tightest integration with TextLayer Core
- All solutions provide CLI and SDK options
- Consider existing infrastructure and tooling
-
Deployment Model
- Doppler and Keeper are primarily cloud-based
- Infisical and Vault can be self-hosted
- Consider your organization’s cloud vs. on-premises requirements