From f37d4f7318618e0190584b8c9788ee3ced3a6a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alves?= Date: Fri, 17 Jul 2026 09:18:47 +0000 Subject: [PATCH] fix(devops): wp-login ops-only gate + smoke for branded auth (BIT-26754) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Nginx: add auth_basic gate on wp-login.php (ops htpasswd, BIT-26754) - deploy.sh: note htpasswd step 5 in post-deploy manual steps - smoke-andebol.sh: update /entrar+/registar checks to verify branded Astro 200 (no WordPress strings); add wp-login.php 401/403 gate check; add /api/homepage latest ≥24 density check (BIT-26752) Co-Authored-By: Paperclip --- deploy/nginx/newsproject.bitreport.pt.conf | 8 ++++--- deploy/scripts/deploy.sh | 3 +++ deploy/scripts/smoke-andebol.sh | 28 ++++++++++++++++------ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/deploy/nginx/newsproject.bitreport.pt.conf b/deploy/nginx/newsproject.bitreport.pt.conf index c22c3ef..21d5ac0 100644 --- a/deploy/nginx/newsproject.bitreport.pt.conf +++ b/deploy/nginx/newsproject.bitreport.pt.conf @@ -42,10 +42,12 @@ server { proxy_send_timeout 30s; } - # --- Public WordPress login surface (before restricted wp-* blocks) --- - # Same-origin cookies for the site hostname. With real_ip enabled, RFC1918-only rules below - # would 403 public users on wp-login. Core login UI needs css/js/images and wp-includes. + # WordPress login — ops-only gate (BIT-26754). + # Public auth goes through Astro /entrar and /registar; wp-login is reserved for admins. + # htpasswd at /etc/nginx/wp-ops.htpasswd — create once on the CT, never commit credentials. location = /wp-login.php { + auth_basic "Ops access only"; + auth_basic_user_file /etc/nginx/wp-ops.htpasswd; proxy_pass http://127.0.0.1:$news_wp_port; proxy_http_version 1.1; proxy_set_header Host $host; diff --git a/deploy/scripts/deploy.sh b/deploy/scripts/deploy.sh index 4ae0b50..25e1224 100755 --- a/deploy/scripts/deploy.sh +++ b/deploy/scripts/deploy.sh @@ -135,3 +135,6 @@ log " 1. IP 10.10.50.204 is static (BIT-24053: systemd-networkd + PVE config; M log " 2. Configure NPM proxy host: newsproject.bitreport.pt → http://10.10.50.204 (NPM proxy #20)" log " 3. Enable HTTPS in NPM (Let's Encrypt)" log " 4. Review $ENV_DIR/frontend.env and $ENV_DIR/bridge.env" +log " 5. Create /etc/nginx/wp-ops.htpasswd for ops-only wp-login gate (BIT-26754):" +log " htpasswd -c -B /etc/nginx/wp-ops.htpasswd wp-ops" +log " Save the password in the team vault. Never commit it to git." diff --git a/deploy/scripts/smoke-andebol.sh b/deploy/scripts/smoke-andebol.sh index c6aeb94..518089b 100755 --- a/deploy/scripts/smoke-andebol.sh +++ b/deploy/scripts/smoke-andebol.sh @@ -53,13 +53,27 @@ _c="$(code_for "$BASE_URL/wp-json/wp/v2/")" [[ "$_c" == "200" ]] || fail "GET $BASE_URL/wp-json/wp/v2/ expected 200, got $_c (WP andebol :8081)" ok "GET /wp-json/wp/v2/ → $_c" -# Auth redirects — /entrar and /registar must NOT land on / (BIT-22298) -_final_entrar="$(curl -fsS -o /dev/null -w '%{url_effective}' --max-time 25 -L -H "Host: $HOST_HEADER" "$BASE_URL/entrar" 2>/dev/null || true)" -[[ "$_final_entrar" == *"wp-login"* ]] || fail "/entrar final URL must contain wp-login; got: $_final_entrar" -ok "GET /entrar → $_final_entrar" +# Branded auth UI (BIT-26753) — /entrar and /registar must serve Astro 200, no WordPress chrome +_c="$(curl -fsS -o /dev/null -w '%{http_code}' --max-time 25 -H "Host: $HOST_HEADER" "$BASE_URL/entrar" 2>/dev/null || true)" +[[ "$_c" == "200" ]] || fail "GET $BASE_URL/entrar expected 200 (Astro branded form), got $_c" +_body_entrar="$(curl -fsS --max-time 15 -H "Host: $HOST_HEADER" "$BASE_URL/entrar" 2>/dev/null || true)" +echo "$_body_entrar" | grep -qi 'WordPress' && fail "/entrar must not contain 'WordPress' (WP chrome leaked)" +echo "$_body_entrar" | grep -qi 'Entrar.*Andebol\|Andebol.*Entrar\|Entrar' || fail "/entrar missing Andebol.net branded title" +ok "GET /entrar → $_c (Astro branded, no WordPress)" -_final_registar="$(curl -fsS -o /dev/null -w '%{url_effective}' --max-time 25 -L -H "Host: $HOST_HEADER" "$BASE_URL/registar" 2>/dev/null || true)" -[[ "$_final_registar" == *"wp-login"* ]] || fail "/registar final URL must contain wp-login; got: $_final_registar" -ok "GET /registar → $_final_registar" +_c="$(curl -fsS -o /dev/null -w '%{http_code}' --max-time 25 -H "Host: $HOST_HEADER" "$BASE_URL/registar" 2>/dev/null || true)" +[[ "$_c" == "200" ]] || fail "GET $BASE_URL/registar expected 200 (Astro branded form), got $_c" +ok "GET /registar → $_c" + +# wp-login.php must NOT be publicly accessible (BIT-26754) — expect 401 (basic auth gate) +_c="$(curl -so /dev/null -w '%{http_code}' --max-time 15 -H "Host: $HOST_HEADER" "$BASE_URL/wp-login.php" 2>/dev/null || true)" +[[ "$_c" == "401" || "$_c" == "403" ]] || fail "GET $BASE_URL/wp-login.php expected 401/403 (ops gate), got $_c" +ok "GET /wp-login.php → $_c (ops-only gate active)" + +# Homepage density: at least 24 latest items in bridge payload (BIT-26752) +_latest_count="$(curl -fsS --max-time 15 -H "Host: $HOST_HEADER" "$BASE_URL/api/homepage" 2>/dev/null \ + | python3 -c 'import sys,json; d=json.load(sys.stdin); print(len(d.get("latest",[])))' 2>/dev/null || echo 0)" +[[ "$_latest_count" -ge 24 ]] || fail "Homepage /api/homepage latest count expected ≥24, got $_latest_count" +ok "GET /api/homepage latest count → $_latest_count ≥ 24" echo "All smokes passed for BASE_URL=$BASE_URL (host: $HOST_HEADER)" -- 2.47.3