Overview
Infisical is a secure secret management platform that GAIA uses to centrally manage environment variables and API keys. Instead of storing sensitive information in.env files, Infisical allows you to:
- Centrally manage secrets across multiple environments
- Secure access controls with role-based permissions
- Audit logging for secret access and changes
- Automatic secret rotation capabilities
- Team collaboration with shared secret access
When Infisical is configured, it will override any local environment variables with the same names from your Infisical project.
How Infisical Works with GAIA
GAIA’s backend automatically loads secrets from Infisical during startup using theinject_infisical_secrets() function. Here’s the process:
- Authentication: Uses machine identity credentials to authenticate with Infisical
- Secret Retrieval: Fetches all secrets from your Infisical project
- Environment Injection: Overwrites local environment variables with Infisical secrets
- Application Startup: GAIA starts with the combined environment configuration
Setting Up Infisical
Step 1: Create an Infisical Account
- Visit app.infisical.com
- Sign up for a free account
- Create a new project for GAIA
Step 2: Create a Machine Identity
Machine identities allow GAIA to authenticate with Infisical automatically:- Go to Project Settings → Access Control → Machine Identities
- Click Create Identity
- Configure the identity:
- Name:
gaia-backend - Role: Admin or Developer (with read access to secrets)
- Name:
- Note down the Client ID and Client Secret
Step 3: Add Secrets to Infisical
Navigate to your project’s Secrets section and add all your environment variables:Core Application
Database URLs
AI API Keys
Integration APIs
Step 4: Configure GAIA Backend
Add the Infisical configuration to your backend.env file:
The
INFISICAL_PROJECT_ID, INFISICAL_MACHINE_INDENTITY_CLIENT_ID, and INFISICAL_MACHINE_INDENTITY_CLIENT_SECRET must be set in your local .env file - they cannot be stored in Infisical itself since they’re needed to authenticate with Infisical.Environment Priority
GAIA loads environment variables in this order (later sources override earlier ones):- System environment variables
- Local
.envfile variables - Infisical secrets (highest priority)
- ✅ Infisical secrets will override local
.envvariables - ✅ You can use local
.envfor development and Infisical for production - ✅ Critical secrets are managed centrally through Infisical
Development vs Production
Development Setup
For local development, you can choose between: Option A: Use Infisical (Recommended for teams)Production Setup
For production, always use Infisical:Troubleshooting
Common Issues
InfisicalConfigError: INFISICAL_PROJECT_ID is missing
InfisicalConfigError: INFISICAL_PROJECT_ID is missing
Solution: Add the
INFISICAL_PROJECT_ID to your .env file. You can find this in your Infisical project settings.Authentication failed
Authentication failed
Solution:
- Verify your
INFISICAL_MACHINE_INDENTITY_CLIENT_IDandINFISICAL_MACHINE_INDENTITY_CLIENT_SECRET - Ensure the machine identity has proper permissions
- Check that the identity is enabled
Secrets not loading
Secrets not loading
Solution:
- Verify the environment slug matches (development/production)
- Check that secrets exist in the correct Infisical project
- Ensure the machine identity has read access to secrets
Local variables not being overridden
Local variables not being overridden
Solution: This is expected behavior. Infisical secrets have the highest priority and will override local variables with the same name.
Debug Mode
To debug Infisical integration, check the application logs during startup. The backend will log any Infisical connection issues.Security Best Practices
Access Control
- Use separate machine identities for different environments
- Grant minimal required permissions
- Regularly audit access logs
Secret Management
- Use different secrets for dev/staging/production
- Rotate secrets regularly
- Never commit Infisical credentials to version control
Environment Separation
- Use separate Infisical projects for each environment
- Implement proper CI/CD secret injection
- Monitor secret access patterns
Backup Strategy
- Export secrets regularly for backup
- Document secret recovery procedures
- Have fallback authentication methods
Next Steps
Environment Variables
Configure your environment variables and learn about Infisical integration
Docker Setup
Deploy GAIA with Docker Compose and Infisical secrets
For more detailed Infisical documentation, visit the official Infisical docs.
