fix: seed api_keys on fresh install (X-API-Key auth) + momentry-proxy web-server plist + test.sh SPA auth model

- install.sh: seed api_keys row (key_hash = SHA-256 of demo key) — missing row
  caused 401 on every X-API-Key request after clean-install
- launchd/com.momentry.proxy.plist: serve via momentry-proxy binary
  (MOMENTRY_WEB_SERVER=true + TAURI_DIST_DIR) instead of serve_frontend.py
- test.sh: remote probes use X-API-Key (SPA auth model) instead of Bearer
  (proxy login returns UUID session token, core expects JWT/X-API-Key)
This commit is contained in:
2026-11-09 05:03:27 +08:00
parent 86c97a3eb7
commit ca0757652e
3 changed files with 40 additions and 3 deletions
+4 -3
View File
@@ -175,7 +175,8 @@ else
local name=$2
local pattern=${3:-"."}
echo -n " $name: "
RESP=$(curl -s --max-time 5 -H "Authorization: Bearer $TOKEN" "$url" 2>/dev/null | head -c 300)
# SPA 認證模型: X-API-Key (Bearer 僅用於 admin token 端點)
RESP=$(curl -s --max-time 5 -H "X-API-Key: muser_demo_key_32chars_abcdef1234567890" "$url" 2>/dev/null | head -c 300)
if echo "$RESP" | grep -qE "$pattern"; then
pass "HTTP 可及"
else
@@ -184,7 +185,7 @@ else
}
probe_url "$BASE_URL/" "frontend proxy (:8888)" "DOCTYPE|html"
probe_url "$BASE_URL/api/v1/health" "API health (透過 proxy)" "status"
probe_url "$BASE_URL/api/v1/health" "API health (透過 proxy)" "ok|status"
probe_url "$BASE_URL/api/v1/files?page_size=1" "API files" "success|total|files"
if [ "$QUICK" = false ] && [ -n "$SSH_CMD" ]; then
@@ -259,7 +260,7 @@ if [ -n "$TOKEN" ]; then
echo -n " 檔案列表: "
RESP=$(curl -s --max-time 5 "$BASE_URL/api/v1/files?page_size=1" \
-H "Authorization: Bearer $TOKEN" 2>/dev/null)
-H "X-API-Key: muser_demo_key_32chars_abcdef1234567890" 2>/dev/null)
if echo "$RESP" | grep -q '"success":true\|total'; then
TOTAL=$(echo "$RESP" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('total', d.get('data') and len(d.get('data')) or 0))" 2>/dev/null)
pass "$TOTAL 個檔案"