From 3462e540eec5f469c5dec6f6c55b170917c4eeea Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 9 Aug 2024 11:18:41 +0300 Subject: [PATCH] login: Warn before logging into multiple hosts --- pkg/static/login.html | 8 ++++++++ pkg/static/login.js | 12 ++++++++++-- pkg/static/login.scss | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pkg/static/login.html b/pkg/static/login.html index d91201916952..3740f0a7e490 100644 --- a/pkg/static/login.html +++ b/pkg/static/login.html @@ -21,6 +21,14 @@ + +
diff --git a/pkg/static/login.js b/pkg/static/login.js index ff296bc71408..386b05ed214f 100644 --- a/pkg/static/login.js +++ b/pkg/static/login.js @@ -355,8 +355,16 @@ import "./login.scss"; } } - if (cur_machine && !environment.page.allow_multihost) - redirect_to_current_machine(); + if (cur_machine) { + if (!environment.page.allow_multihost) + redirect_to_current_machine(); + else { + id("multihost-message").textContent = format(_("You are already connected to '$0' in this browser session. Connecting to other hosts will allow them to execute arbitrary code on each other. Please be careful."), + cur_machine == "." ? "localhost" : cur_machine); + id("multihost-get-me-there").addEventListener("click", redirect_to_current_machine); + show('#multihost-warning'); + } + } } function boot() { diff --git a/pkg/static/login.scss b/pkg/static/login.scss index 33e664562fa9..b1fddb29d11f 100644 --- a/pkg/static/login.scss +++ b/pkg/static/login.scss @@ -354,14 +354,14 @@ label.checkbox { display: none; } -.login-pf #banner { +.login-pf #banner, .login-pf #multihost-warning { margin-block: 1rem 0.5rem; margin-inline: 0; grid-area: banner; inline-size: 100%; } -#banner-message { +#banner-message, #multihost-message { white-space: pre-wrap; max-block-size: 12em; overflow: auto;