Skip to content

Commit a2526ce

Browse files
Merge pull request #167 from yasinBursali/fix/opencode-loopback-password
fix(security): bind OpenCode to 127.0.0.1 and generate random password
2 parents db34a83 + b06e835 commit a2526ce

5 files changed

Lines changed: 11 additions & 5 deletions

File tree

dream-server/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ LITELLM_KEY=CHANGEME
2222
# OpenClaw agent framework token (generate: openssl rand -hex 24)
2323
OPENCLAW_TOKEN=CHANGEME
2424

25+
# OpenCode web UI password (generate: openssl rand -base64 16)
26+
OPENCODE_SERVER_PASSWORD=CHANGEME
27+
2528
# ═══════════════════════════════════════════════════════════════════
2629
# LLM Backend Mode
2730
# ═══════════════════════════════════════════════════════════════════

dream-server/installers/macos/lib/env-generator.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ generate_dream_env() {
5656
dashboard_api_key=$(new_secure_hex 32)
5757
local openclaw_token
5858
openclaw_token=$(new_secure_hex 24)
59+
local opencode_password
60+
opencode_password=$(new_secure_base64 16)
5961
local searxng_secret
6062
searxng_secret=$(new_secure_hex 32)
6163
# macOS: llama-server runs natively, containers reach it via host.docker.internal
@@ -112,7 +114,7 @@ OPENCLAW_TOKEN=${openclaw_token}
112114
113115
#=== OpenCode Settings ===
114116
OPENCODE_PORT=3003
115-
OPENCODE_SERVER_PASSWORD=
117+
OPENCODE_SERVER_PASSWORD=${opencode_password}
116118
117119
#=== Voice Settings ===
118120
WHISPER_MODEL=base

dream-server/installers/phases/06-directories.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ MODELS_EOF
243243
LIVEKIT_SECRET=$(_env_get LIVEKIT_API_SECRET "$(openssl rand -base64 32 2>/dev/null || head -c 32 /dev/urandom | base64)")
244244
DASHBOARD_API_KEY=$(_env_get DASHBOARD_API_KEY "$(openssl rand -hex 32 2>/dev/null || head -c 32 /dev/urandom | xxd -p)")
245245
DIFY_SECRET_KEY=$(_env_get DIFY_SECRET_KEY "$(openssl rand -hex 32 2>/dev/null || head -c 32 /dev/urandom | xxd -p)")
246-
OPENCODE_SERVER_PASSWORD=$(_env_get OPENCODE_SERVER_PASSWORD "")
246+
OPENCODE_SERVER_PASSWORD=$(_env_get OPENCODE_SERVER_PASSWORD "$(openssl rand -base64 16 2>/dev/null || head -c 16 /dev/urandom | base64)")
247247

248248
# Preserve user-supplied cloud API keys
249249
ANTHROPIC_API_KEY=$(_env_get ANTHROPIC_API_KEY "${ANTHROPIC_API_KEY:-}")

dream-server/installers/windows/lib/env-generator.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ function New-DreamEnv {
106106
$dashboardApiKey = Get-EnvOrNew "DASHBOARD_API_KEY" (New-SecureHex -Bytes 32)
107107
$openclawToken = Get-EnvOrNew "OPENCLAW_TOKEN" (New-SecureHex -Bytes 24)
108108
$searxngSecret = Get-EnvOrNew "SEARXNG_SECRET" (New-SecureHex -Bytes 32)
109-
$difySecretKey = Get-EnvOrNew "DIFY_SECRET_KEY" (New-SecureHex -Bytes 32)
109+
$difySecretKey = Get-EnvOrNew "DIFY_SECRET_KEY" (New-SecureHex -Bytes 32)
110+
$opencodePassword = Get-EnvOrNew "OPENCODE_SERVER_PASSWORD" (New-SecureBase64 -Bytes 16)
110111

111112
# Determine LLM API URL based on backend
112113
# AMD on Windows: llama-server runs natively, containers reach it via host.docker.internal
@@ -207,7 +208,7 @@ LITELLM_KEY=$litellmKey
207208
LIVEKIT_API_KEY=$livekitApiKey
208209
LIVEKIT_API_SECRET=$livekitSecret
209210
OPENCLAW_TOKEN=$openclawToken
210-
OPENCODE_SERVER_PASSWORD=
211+
OPENCODE_SERVER_PASSWORD=$opencodePassword
211212
OPENCODE_PORT=3003
212213
DIFY_SECRET_KEY=$difySecretKey
213214

dream-server/opencode/opencode-web.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ After=network.target
66
[Service]
77
Type=simple
88
WorkingDirectory=__HOME__
9-
ExecStart=__HOME__/.opencode/bin/opencode web --port 3003 --hostname 0.0.0.0
9+
ExecStart=__HOME__/.opencode/bin/opencode web --port 3003 --hostname 127.0.0.1
1010
Restart=on-failure
1111
RestartSec=5
1212

0 commit comments

Comments
 (0)