Skip to main content

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:
Never commit .env files to version control. The .env.example file contains safe defaults for local development only.

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:
Never use predictable values like "secret" or "dev-secret" in production.
string
required
Master key for encrypting service credentials in the vault. Used with AES-256-GCM.Security:
  • Must be at least 32 characters long (enforced)
  • Use a cryptographically secure random string
  • If changed, existing credentials become unreadable
Generate:
Example:
Changing this value will make all existing encrypted credentials unreadable. Back up your database before rotating.
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
Example:
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 accuracy
  • gpt-4o - Highest accuracy, more expensive
  • gpt-3.5-turbo - Faster, lower cost, slightly less accurate
Example:
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
Example:
Start with 0.5 and adjust based on false positive/negative rates. Lower values are more permissive.
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 logging
  • production - Production optimizations, reduced logging
Example:

Example Configurations

Validation Rules

GaiterGuard validates all environment variables at startup (see backend/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
If validation fails, the backend will log the error and exit.

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