Spaces:
Runtime error
Runtime error
feat: switch auth from password to token mode (persists in browser)
Browse filesToken auth stores the credential in localStorage so user only needs
to enter it once. Password auth requires re-entry on every page refresh.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- openclaw.json +1 -1
- scripts/sync_hf.py +4 -4
openclaw.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"mode": "local",
|
| 4 |
"bind": "lan",
|
| 5 |
"port": 7860,
|
| 6 |
-
"auth": { "
|
| 7 |
"trustedProxies": [
|
| 8 |
"0.0.0.0/0"
|
| 9 |
],
|
|
|
|
| 3 |
"mode": "local",
|
| 4 |
"bind": "lan",
|
| 5 |
"port": 7860,
|
| 6 |
+
"auth": { "token": "__OPENCLAW_PASSWORD__" },
|
| 7 |
"trustedProxies": [
|
| 8 |
"0.0.0.0/0"
|
| 9 |
],
|
scripts/sync_hf.py
CHANGED
|
@@ -346,8 +346,8 @@ class OpenClawFullSync:
|
|
| 346 |
cfg = json.load(f)
|
| 347 |
# Replace token placeholder
|
| 348 |
if "gateway" in cfg and "auth" in cfg["gateway"]:
|
| 349 |
-
if cfg["gateway"]["auth"].get("
|
| 350 |
-
cfg["gateway"]["auth"]["
|
| 351 |
if OPENAI_API_KEY and "models" in cfg and "providers" in cfg["models"] and "openai" in cfg["models"]["providers"]:
|
| 352 |
cfg["models"]["providers"]["openai"]["apiKey"] = OPENAI_API_KEY
|
| 353 |
if OPENAI_BASE_URL:
|
|
@@ -420,7 +420,7 @@ class OpenClawFullSync:
|
|
| 420 |
# Force full gateway config for HF Spaces
|
| 421 |
if not OPENCLAW_PASSWORD:
|
| 422 |
print("[SYNC] WARNING: OPENCLAW_PASSWORD not set! Gateway will have no auth.")
|
| 423 |
-
auth = {"
|
| 424 |
# Dynamic allowedOrigins from SPACE_HOST (auto-set by HF runtime)
|
| 425 |
allowed_origins = [
|
| 426 |
"https://huggingface.co",
|
|
@@ -441,7 +441,7 @@ class OpenClawFullSync:
|
|
| 441 |
"allowedOrigins": allowed_origins
|
| 442 |
}
|
| 443 |
}
|
| 444 |
-
print(f"[SYNC] Set gateway config (auth={'
|
| 445 |
|
| 446 |
# Ensure agents defaults
|
| 447 |
data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})
|
|
|
|
| 346 |
cfg = json.load(f)
|
| 347 |
# Replace token placeholder
|
| 348 |
if "gateway" in cfg and "auth" in cfg["gateway"]:
|
| 349 |
+
if cfg["gateway"]["auth"].get("token") == "__OPENCLAW_PASSWORD__":
|
| 350 |
+
cfg["gateway"]["auth"]["token"] = OPENCLAW_PASSWORD
|
| 351 |
if OPENAI_API_KEY and "models" in cfg and "providers" in cfg["models"] and "openai" in cfg["models"]["providers"]:
|
| 352 |
cfg["models"]["providers"]["openai"]["apiKey"] = OPENAI_API_KEY
|
| 353 |
if OPENAI_BASE_URL:
|
|
|
|
| 420 |
# Force full gateway config for HF Spaces
|
| 421 |
if not OPENCLAW_PASSWORD:
|
| 422 |
print("[SYNC] WARNING: OPENCLAW_PASSWORD not set! Gateway will have no auth.")
|
| 423 |
+
auth = {"token": OPENCLAW_PASSWORD} if OPENCLAW_PASSWORD else {}
|
| 424 |
# Dynamic allowedOrigins from SPACE_HOST (auto-set by HF runtime)
|
| 425 |
allowed_origins = [
|
| 426 |
"https://huggingface.co",
|
|
|
|
| 441 |
"allowedOrigins": allowed_origins
|
| 442 |
}
|
| 443 |
}
|
| 444 |
+
print(f"[SYNC] Set gateway config (auth={'token' if OPENCLAW_PASSWORD else 'none'}, origins={len(allowed_origins)})")
|
| 445 |
|
| 446 |
# Ensure agents defaults
|
| 447 |
data.setdefault("agents", {}).setdefault("defaults", {}).setdefault("model", {})
|