Configuration File
All configuration is defined in a.env file in the project root. Copy the example file to get started:
After modifying
.env, restart Heimdall for changes to take effect.Server Configuration
Basic server settings for HTTP binding and CORS.| Variable | Default | Description |
|---|---|---|
APP_HOST | 0.0.0.0 | Bind address for the HTTP server |
APP_PORT | 8080 | Listen port |
TLS_ENABLED | false | Enable TLS termination in the app (set true only if not behind a reverse proxy) |
CORS_ALLOWED_ORIGIN | http://localhost:8080 | CORS allowed origin for API requests |
DATA_DIR | ./data | Persistent data directory for uploads, cloned repos, etc. |
Example
.env
Database Configuration
Heimdall requires PostgreSQL 14+.| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string |
Example
.env
The database schema is applied automatically on startup using idempotent DDL (
IF NOT EXISTS statements). No manual migrations needed.AI Provider Configuration
Heimdall requires at least one AI provider. When multiple providers are configured, Heimdall chains them in a fallback provider — if the primary fails with a retryable error (429 rate limit, 500/502/503 server errors, billing/quota exhaustion, or connection failures), requests automatically fall through to the next configured provider. Priority order: Anthropic → OpenAI → Ollama| Variable | Provider | Description |
|---|---|---|
ANTHROPIC_API_KEY | Claude | Anthropic API key (format: sk-ant-...) |
OPENAI_API_KEY | OpenAI | OpenAI API key (format: sk-...) |
OLLAMA_URL | Ollama | Ollama server URL (e.g., http://localhost:11434) |
DEFAULT_AI_MODEL | — | Override default model (default: claude-sonnet-4-20250514) |
Example
.env
Supported Models
Anthropic (Claude)
claude-sonnet-4-20250514(default, recommended)claude-opus-4-20250514(most capable)claude-3-5-sonnet-20241022
OpenAI
gpt-4o(latest)gpt-4o-minigpt-4-turbo
Ollama (Local)
llama3.3:70bmistral-nemocodestral:latest
Automatic Fallback Behavior
Primary provider fails
If the primary provider (Anthropic) returns a retryable error (HTTP 429, 500, 502, 503, 529, billing errors, or connection failures), the request is automatically retried with the next configured provider.
Cascade to next provider
The fallback chain continues through all configured providers until one succeeds or all fail.
Non-retryable errors (401 Unauthorized, 400 Bad Request) propagate immediately without fallback.
Bring Your Own Key (BYOK)
Users can add API keys through the Settings UI after registration:- Navigate to Settings → AI Providers
- Click Add API Key
- Select provider (Anthropic, OpenAI, or Ollama)
- Enter your API key
- Click Test Connection to verify
OAuth Configuration
OAuth enables GitHub/GitLab login and repository import.GitHub OAuth
| Variable | Description |
|---|---|
GITHUB_CLIENT_ID | GitHub OAuth app client ID |
GITHUB_CLIENT_SECRET | GitHub OAuth app client secret |
GITHUB_REDIRECT_URI | Callback URL (default: http://localhost:8080/api/auth/github/callback) |
Setting up GitHub OAuth App
Create OAuth App
- Go to GitHub Developer Settings
- Click New OAuth App
- Fill in:
- Application name: Heimdall
- Homepage URL:
http://localhost:8080 - Authorization callback URL:
http://localhost:8080/api/auth/github/callback
- Click Register application
GitLab OAuth
| Variable | Description |
|---|---|
GITLAB_CLIENT_ID | GitLab OAuth app client ID |
GITLAB_CLIENT_SECRET | GitLab OAuth app client secret |
GITLAB_REDIRECT_URI | Callback URL (default: http://localhost:8080/api/auth/gitlab/callback) |
GITLAB_BASE_URL | GitLab base URL (default: https://gitlab.com) |
Setting up GitLab OAuth App
Create OAuth App
- Go to GitLab Applications
- Fill in:
- Name: Heimdall
- Redirect URI:
http://localhost:8080/api/auth/gitlab/callback - Scopes: Select
api,read_user,read_repository
- Click Save application
For self-hosted GitLab, set
GITLAB_BASE_URL to your instance URL (e.g., https://gitlab.company.com).Security Configuration
Critical security settings for encryption and webhook verification.| Variable | Description | How to Generate |
|---|---|---|
ENCRYPTION_KEY | 32-byte hex key for AES-256-GCM encryption of stored API keys | openssl rand -hex 32 |
WEBHOOK_SECRET | Shared secret for GitHub/GitLab webhook signature verification | openssl rand -hex 20 |
Example
.env
Encryption Key
TheENCRYPTION_KEY encrypts stored API keys using AES-256-GCM:
- Required if users add API keys through the Settings UI
- Must be 64 hex characters (32 bytes)
- Must be kept secret — if lost, stored API keys cannot be decrypted
Webhook Secret
TheWEBHOOK_SECRET verifies webhook payloads from GitHub/GitLab:
- GitHub: HMAC-SHA256 verification against
X-Hub-Signature-256header - GitLab: Direct string comparison against
X-Gitlab-Tokenheader
Setting up GitHub Webhook
Configure webhook
- Payload URL:
https://heimdall.example.com/webhooks/github - Content type:
application/json - Secret: Same value as
WEBHOOK_SECRETin your.env - Events: Select “Just the push event”
Setting up GitLab Webhook
Configure webhook
- URL:
https://heimdall.example.com/webhooks/gitlab - Secret token: Same value as
WEBHOOK_SECRET - Trigger: Push events
Worker Configuration
The background worker polls for queued scans and executes them.| Variable | Default | Description |
|---|---|---|
WORKER_ENABLED | true | Enable/disable the background scan worker |
WORKER_POLL_INTERVAL_SECS | 5 | How often the worker polls for queued scans (seconds) |
WORKER_STALE_TIMEOUT_MINS | 10 | Timeout for stale/stuck scans (minutes) |
Example
.env
Worker Behavior
Poll for queued scans
Every
WORKER_POLL_INTERVAL_SECS seconds, the worker queries the database for scans with status queued.Set
WORKER_ENABLED=false to disable automatic scan execution. Scans will remain queued until manually triggered or a worker is enabled.Logging Configuration
Control log verbosity using theRUST_LOG environment variable.
| Variable | Default | Description |
|---|---|---|
RUST_LOG | info,heimdall=debug | Log filter (env_logger syntax) |
Log Levels
error— Critical errors onlywarn— Warnings and errorsinfo— General information, warnings, and errorsdebug— Detailed debugging informationtrace— Very verbose tracing (not recommended in production)
Example
.env
Module-Specific Logging
.env
Complete Example
Here’s a complete production-ready.env configuration:
.env
Next Steps
Quickstart
Run your first security scan
Installation
Set up Heimdall for local development or production
Troubleshooting
Missing Required Environment Variables
If Heimdall fails to start withDATABASE_URL must be set:
- Verify
.envfile exists in the project root - Check that
DATABASE_URLis set and not empty - Restart Heimdall
AI Provider Not Working
If scans fail withNo AI provider configured:
- Ensure at least one of these is set:
ANTHROPIC_API_KEYOPENAI_API_KEYOLLAMA_URL
- Test the provider connection via Settings → AI Providers
- Check API key format (Anthropic:
sk-ant-..., OpenAI:sk-...)
Webhook Verification Failed
If webhooks return403 Forbidden:
- Verify
WEBHOOK_SECRETmatches the secret configured in GitHub/GitLab - Check webhook logs for signature verification errors:
- Ensure the webhook payload is valid JSON
Encryption Key Issues
If stored API keys cannot be decrypted:- Verify
ENCRYPTION_KEYis exactly 64 hex characters (32 bytes) - Ensure the same
ENCRYPTION_KEYis used across restarts - If lost, users must re-add API keys through the Settings UI