From 46f06a033b8e6f213976a029f48d9cb493d53aa7 Mon Sep 17 00:00:00 2001 From: Adam French Date: Thu, 26 Nov 2026 13:52:39 +0000 Subject: [PATCH] Login: follow a redirect back to priv. stppriv's admin gate sends a signed-out visitor here with an absolute https://priv./... redirect. Only that exact host is allowed, so it is not an open redirect. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit c8c34d15483722cae145c9501823dbff74cf0c02) --- vue/src/views/admin/Login.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vue/src/views/admin/Login.vue b/vue/src/views/admin/Login.vue index 622eb0e..5a728a4 100644 --- a/vue/src/views/admin/Login.vue +++ b/vue/src/views/admin/Login.vue @@ -20,9 +20,24 @@ const password = ref(""); const submitting = ref(false); const errorMsg = ref(""); +// stppriv's gate sends people here with an absolute priv. URL. +function isPrivUrl(dest) { + try { + const url = new URL(dest); + return url.protocol === "https:" && url.host === `priv.${window.location.hostname.replace(/^www\./, "")}`; + } catch { + return false; + } +} + // Caddy-gated paths aren't Vue routes, so landing on "404" means a full page -// load. Only site-relative paths are followed, or it's an open redirect. +// load. Only site-relative paths (and stppriv) are followed, or it's an open +// redirect. function goTo(dest) { + if (isPrivUrl(dest)) { + window.location.assign(dest); + return; + } if (typeof dest !== "string" || !dest.startsWith("/") || dest.startsWith("//")) { router.push(home()); return;