Login: follow a redirect back to priv.<domain>
stppriv's admin gate sends a signed-out visitor here with an absolute https://priv.<domain>/... redirect. Only that exact host is allowed, so it is not an open redirect. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit c8c34d15483722cae145c9501823dbff74cf0c02)
This commit is contained in:
@@ -20,9 +20,24 @@ const password = ref("");
|
|||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
const errorMsg = ref("");
|
const errorMsg = ref("");
|
||||||
|
|
||||||
|
// stppriv's gate sends people here with an absolute priv.<domain> 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
|
// 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) {
|
function goTo(dest) {
|
||||||
|
if (isPrivUrl(dest)) {
|
||||||
|
window.location.assign(dest);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (typeof dest !== "string" || !dest.startsWith("/") || dest.startsWith("//")) {
|
if (typeof dest !== "string" || !dest.startsWith("/") || dest.startsWith("//")) {
|
||||||
router.push(home());
|
router.push(home());
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user