tao-shen Claude Opus 4.6 commited on
Commit
5a096f1
·
1 Parent(s): 3f16497

fix: revert to token auth with default "huggingclaw"

Browse files

auth.mode=none crashes on non-loopback bind. Revert to token mode
with GATEWAY_TOKEN env var (default: huggingclaw).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (3) hide show
  1. README.md +3 -3
  2. openclaw.json +1 -1
  3. scripts/sync_hf.py +6 -16
README.md CHANGED
@@ -112,7 +112,7 @@ Fine-tune persistence and performance. Set these as **Repository Secrets** in HF
112
 
113
  | Variable | Default | Description |
114
  |----------|---------|-------------|
115
- | `GATEWAY_TOKEN` | _(none)_ | **Gateway token.** If set, Control UI requires this token to connect. If not set, anyone with the URL can access. |
116
  | `AUTO_CREATE_DATASET` | `false` | **Auto-create the Dataset repo.** Set to `true` to auto-create a private Dataset repo on first startup. |
117
  | `SYNC_INTERVAL` | `60` | **Backup interval in seconds.** How often data syncs to the Dataset repo. |
118
 
@@ -120,7 +120,7 @@ Fine-tune persistence and performance. Set these as **Repository Secrets** in HF
120
 
121
  ### 3. Open the Control UI
122
 
123
- Visit your Space URL the Control UI connects automatically, no token needed. To add access control, set the `GATEWAY_TOKEN` secret.
124
 
125
  Messaging integrations (Telegram, WhatsApp) can be configured directly inside the Control UI after connecting.
126
 
@@ -141,7 +141,7 @@ HuggingClaw adds its own variables for persistence and deployment: `HF_TOKEN`, `
141
 
142
  ## Security
143
 
144
- - **Optional token auth** — set `GATEWAY_TOKEN` to restrict Control UI access; without it, the UI is open for easy setup
145
  - **Secrets stay server-side** — API keys and tokens are never exposed to the browser
146
  - **Private backups** — the Dataset repo is created as private by default
147
 
 
112
 
113
  | Variable | Default | Description |
114
  |----------|---------|-------------|
115
+ | `GATEWAY_TOKEN` | `huggingclaw` | **Gateway token for Control UI access.** Override to set a custom token. |
116
  | `AUTO_CREATE_DATASET` | `false` | **Auto-create the Dataset repo.** Set to `true` to auto-create a private Dataset repo on first startup. |
117
  | `SYNC_INTERVAL` | `60` | **Backup interval in seconds.** How often data syncs to the Dataset repo. |
118
 
 
120
 
121
  ### 3. Open the Control UI
122
 
123
+ Visit your Space URL. Enter the gateway token (default: `huggingclaw`) to connect. Customize via `GATEWAY_TOKEN` secret.
124
 
125
  Messaging integrations (Telegram, WhatsApp) can be configured directly inside the Control UI after connecting.
126
 
 
141
 
142
  ## Security
143
 
144
+ - **Token authentication** — Control UI requires a gateway token to connect (default: `huggingclaw`, customizable via `GATEWAY_TOKEN`)
145
  - **Secrets stay server-side** — API keys and tokens are never exposed to the browser
146
  - **Private backups** — the Dataset repo is created as private by default
147
 
openclaw.json CHANGED
@@ -3,7 +3,7 @@
3
  "mode": "local",
4
  "bind": "lan",
5
  "port": 7860,
6
- "auth": { "mode": "none" },
7
  "trustedProxies": [
8
  "0.0.0.0/0"
9
  ],
 
3
  "mode": "local",
4
  "bind": "lan",
5
  "port": 7860,
6
+ "auth": { "token": "huggingclaw" },
7
  "trustedProxies": [
8
  "0.0.0.0/0"
9
  ],
scripts/sync_hf.py CHANGED
@@ -65,8 +65,8 @@ OPENAI_BASE_URL = os.environ.get("OPENAI_BASE_URL", "https://api.openai.com/v1")
65
  # OpenRouter API key (optional; alternative to OPENAI_API_KEY + OPENAI_BASE_URL)
66
  OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
67
 
68
- # Gateway token (optional; if not set, Control UI connects without auth)
69
- GATEWAY_TOKEN = os.environ.get("GATEWAY_TOKEN", "")
70
 
71
  # Default model for new conversations (infer from provider if not set)
72
  OPENCLAW_DEFAULT_MODEL = os.environ.get("OPENCLAW_DEFAULT_MODEL") or (
@@ -347,12 +347,9 @@ class OpenClawFullSync:
347
  try:
348
  with open(config_path, "r") as f:
349
  cfg = json.load(f)
350
- # Set auth based on GATEWAY_TOKEN env var
351
  if "gateway" in cfg:
352
- if GATEWAY_TOKEN:
353
- cfg["gateway"]["auth"] = {"token": GATEWAY_TOKEN}
354
- else:
355
- cfg["gateway"]["auth"] = {"mode": "none"}
356
  if OPENAI_API_KEY and "models" in cfg and "providers" in cfg["models"] and "openai" in cfg["models"]["providers"]:
357
  cfg["models"]["providers"]["openai"]["apiKey"] = OPENAI_API_KEY
358
  if OPENAI_BASE_URL:
@@ -431,18 +428,11 @@ class OpenClawFullSync:
431
  if SPACE_HOST:
432
  allowed_origins.append(f"https://{SPACE_HOST}")
433
  print(f"[SYNC] SPACE_HOST detected: {SPACE_HOST}")
434
- # Auth: token mode if GATEWAY_TOKEN is set, otherwise no-auth mode
435
- if GATEWAY_TOKEN:
436
- auth_cfg = {"token": GATEWAY_TOKEN}
437
- auth_label = f"token"
438
- else:
439
- auth_cfg = {"mode": "none"}
440
- auth_label = "none (open access)"
441
  data["gateway"] = {
442
  "mode": "local",
443
  "bind": "lan",
444
  "port": 7860,
445
- "auth": auth_cfg,
446
  "trustedProxies": ["0.0.0.0/0"],
447
  "controlUi": {
448
  "allowInsecureAuth": True,
@@ -450,7 +440,7 @@ class OpenClawFullSync:
450
  "allowedOrigins": allowed_origins
451
  }
452
  }
453
- print(f"[SYNC] Set gateway config (auth={auth_label}, origins={len(allowed_origins)})")
454
 
455
  # Ensure agents defaults
456
  data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})
 
65
  # OpenRouter API key (optional; alternative to OPENAI_API_KEY + OPENAI_BASE_URL)
66
  OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
67
 
68
+ # Gateway token (default: huggingclaw; override via GATEWAY_TOKEN env var)
69
+ GATEWAY_TOKEN = os.environ.get("GATEWAY_TOKEN", "huggingclaw")
70
 
71
  # Default model for new conversations (infer from provider if not set)
72
  OPENCLAW_DEFAULT_MODEL = os.environ.get("OPENCLAW_DEFAULT_MODEL") or (
 
347
  try:
348
  with open(config_path, "r") as f:
349
  cfg = json.load(f)
350
+ # Set gateway token
351
  if "gateway" in cfg:
352
+ cfg["gateway"]["auth"] = {"token": GATEWAY_TOKEN}
 
 
 
353
  if OPENAI_API_KEY and "models" in cfg and "providers" in cfg["models"] and "openai" in cfg["models"]["providers"]:
354
  cfg["models"]["providers"]["openai"]["apiKey"] = OPENAI_API_KEY
355
  if OPENAI_BASE_URL:
 
428
  if SPACE_HOST:
429
  allowed_origins.append(f"https://{SPACE_HOST}")
430
  print(f"[SYNC] SPACE_HOST detected: {SPACE_HOST}")
 
 
 
 
 
 
 
431
  data["gateway"] = {
432
  "mode": "local",
433
  "bind": "lan",
434
  "port": 7860,
435
+ "auth": {"token": GATEWAY_TOKEN},
436
  "trustedProxies": ["0.0.0.0/0"],
437
  "controlUi": {
438
  "allowInsecureAuth": True,
 
440
  "allowedOrigins": allowed_origins
441
  }
442
  }
443
+ print(f"[SYNC] Set gateway config (auth=token, origins={len(allowed_origins)})")
444
 
445
  # Ensure agents defaults
446
  data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})