fix(updates): allow notify endpoint past CSRF + portable JSON parse in release.sh

- csrf-protection: skip CSRF validation on /api/system/update-notify. The
  endpoint has its own X-DashCaddy-Notify-Secret auth and is only ever called
  machine-to-machine; browsers never reach it. Without this, the CSRF cookie
  check rejects the notify POST before the secret comparison runs.
- release.sh: the verify step piped curl into `node -p ".../dev/stdin"` which
  works on Linux but blows up on Windows/git-bash. Replaced with portable
  grep+sed extraction so the same script works on both publisher OSes.
This commit is contained in:
Sami
2026-05-16 23:55:08 -07:00
parent 850db40479
commit 7e23cb5b06
2 changed files with 7 additions and 3 deletions
+4 -1
View File
@@ -122,7 +122,10 @@ function csrfValidationMiddleware(req, res, next) {
'/api/totp/verify-setup',
'/api/totp/setup',
'/health',
'/api/health'
'/api/health',
// Machine-to-machine: publishing host POSTs here with its own shared-secret
// header (X-DashCaddy-Notify-Secret) — browsers never reach this endpoint.
'/api/system/update-notify'
];
// Normalize /api/v1/... to /api/... so exclusions work with both prefixes
+3 -2
View File
@@ -173,7 +173,7 @@ fi
# ── Verify ───────────────────────────────────────────────────────────────
echo
echo "─── Verifying live ───"
SERVED_VER="$(curl -fsSL --max-time 5 https://get.dashcaddy.net/release/version.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin')).version")"
SERVED_VER="$(curl -fsSL --max-time 5 https://get.dashcaddy.net/release/version.json | grep -oE '"version"[[:space:]]*:[[:space:]]*"[^"]+"' | head -1 | sed -E 's/.*"([^"]+)"$/\1/')"
[[ "$SERVED_VER" == "$VERSION" ]] || { echo "MISMATCH: get.dashcaddy.net serves $SERVED_VER, expected $VERSION" >&2; exit 1; }
echo " get.dashcaddy.net → $SERVED_VER"
@@ -183,7 +183,8 @@ SHA_HTTP="$(curl -fsSL --max-time 30 "https://get.dashcaddy.net/release/dashcadd
echo " tarball sha256 → $SHA_HTTP"
if [[ "$MIRROR_OK" == "true" ]]; then
GET2_VER="$(curl -fsSL --max-time 5 https://get2.dashcaddy.net/release/version.json 2>/dev/null | node -p "try{JSON.parse(require('fs').readFileSync('/dev/stdin')).version}catch{'unreachable'}" 2>/dev/null || echo unreachable)"
GET2_VER="$(curl -fsSL --max-time 5 https://get2.dashcaddy.net/release/version.json 2>/dev/null | grep -oE '"version"[[:space:]]*:[[:space:]]*"[^"]+"' | head -1 | sed -E 's/.*"([^"]+)"$/\1/')"
[[ -z "$GET2_VER" ]] && GET2_VER=unreachable
if [[ "$GET2_VER" == "$VERSION" ]]; then
echo " get2.dashcaddy.net → $GET2_VER"
else