Overview
GaiterGuard is configured entirely through environment variables. All variables are validated at startup, and the server will refuse to start if required variables are missing or invalid.Environment File
Create a.env file in the backend/ directory:
Required Variables
These variables must be set or the backend will not start.string
required
PostgreSQL connection string in the format:Example:Docker Compose:
Use the service name
db as the host when running in Docker Compose.string
required
Secret key for signing JWT access and refresh tokens. Must be a long, random string.Security: Use a cryptographically secure random string of at least 32 characters.Generate:Example:
string
required
Master key for encrypting service credentials in the vault. Used with AES-256-GCM.Security:Example:
- Must be at least 32 characters long (enforced)
- Use a cryptographically secure random string
- If changed, existing credentials become unreadable
string
required
Base URL for the LLM API used for risk assessment. Must be OpenAI-compatible.Supported providers:
- OpenAI:
https://api.openai.com/v1 - Azure OpenAI:
https://{resource}.openai.azure.com/openai/deployments/{deployment} - Local models (Ollama):
http://localhost:11434/v1 - Any OpenAI-compatible endpoint
string
required
API key for authenticating with the LLM service.Example:
For local Ollama instances, you can use a placeholder value like
"ollama" since authentication is not required.Optional Variables
These variables have sensible defaults but can be customized.number
default:"3000"
Port the backend API server listens on.Example:
string
default:"15m"
Access token expiration time. Accepts time units:
s (seconds), m (minutes), h (hours), d (days).Recommended: 15 minutes to 1 hour for security.Examples:string
default:"7d"
Refresh token expiration time. Users must log in again after this period.Recommended: 7 to 30 days.Examples:
string
default:"gaiter-guard-salt-v1"
Salt value used in credential encryption key derivation. Change this to rotate the encryption scheme.Example:
Changing this requires re-encrypting all credentials. Use the same value across backend instances.
string
default:"gpt-4o-mini"
LLM model name to use for risk assessment.Recommended models:
gpt-4o-mini- Fast, cost-effective, good accuracygpt-4o- Highest accuracy, more expensivegpt-3.5-turbo- Faster, lower cost, slightly less accurate
number
default:"10000"
Timeout for LLM API requests in milliseconds.Recommended: 10000-30000 (10-30 seconds)Example:
If risk assessment times out, the request is rejected as a safety measure.
number
default:"0.5"
Risk score threshold (0.0 to 1.0) above which requests require human approval.
- 0.0 - Block nothing (all requests pass)
- 0.3 - Block high-risk operations (PUT, DELETE)
- 0.5 - Balanced (recommended)
- 0.7 - Aggressive (blocks most POST/PATCH)
- 1.0 - Block everything
number
default:"1"
Hours after approval before the execution window expires. Agents must execute approved requests within this time.Recommended: 1-24 hoursExample:
After expiry, the action transitions to
EXPIRED status. Agents must resubmit via POST /proxy.string
default:"development"
Node.js environment mode. Set to
production in production deployments.Values:development- Enables debug loggingproduction- Production optimizations, reduced logging
Example Configurations
Validation Rules
GaiterGuard validates all environment variables at startup (seebackend/src/config/env.ts:1):
- DATABASE_URL: Must be a valid PostgreSQL connection string
- JWT_SECRET: Required, no minimum length (but use 32+ chars)
- ENCRYPTION_SECRET: Must be at least 32 characters
- RISK_THRESHOLD: Must be a number between 0.0 and 1.0
- PORT: Must be a valid integer
- LLM_TIMEOUT_MS: Must be a valid integer
- APPROVAL_EXECUTE_TTL_HOURS: Must be a valid integer
Security Best Practices
1
Use strong secrets
Generate secrets with cryptographic tools:
2
Restrict file permissions
Protect your
.env file:3
Never commit secrets
Ensure
.env is in .gitignore:4
Rotate credentials regularly
- Rotate JWT_SECRET monthly
- Rotate ENCRYPTION_SECRET quarterly (requires re-encrypting credentials)
- Use secret management tools (AWS Secrets Manager, HashiCorp Vault)
Next Steps
Deployment
Deploy to production with Docker Compose
Agent Integration
Integrate AI agents with the gateway