-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various login/beiboot preparations/cleanups #20967
Changes from all commits
fd3d8ea
465ab3b
5b7c441
0cfdeec
674e142
cc3fd60
382847d
971b727
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import "./login.scss"; | ||
|
||
function debug(...args) { | ||
if (window.debugging === 'all' || window.debugging?.includes('login')) | ||
console.debug('login:', ...args); | ||
} | ||
|
||
(function(console) { | ||
let localStorage; | ||
|
||
|
@@ -552,8 +557,7 @@ import "./login.scss"; | |
} | ||
|
||
function host_failure(msg) { | ||
const host = id("server-field").value; | ||
if (!host) { | ||
if (!login_machine) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This added line is not executed by any test. |
||
login_failure(msg); | ||
} else { | ||
clear_errors(); | ||
|
@@ -590,17 +594,20 @@ import "./login.scss"; | |
return hosts; | ||
} | ||
|
||
// value of #server-field at the time of clicking "Login" | ||
let login_machine = null; | ||
|
||
function call_login() { | ||
login_failure(null); | ||
login_machine = id("server-field").value; | ||
const user = trim(id("login-user-input").value); | ||
if (user === "" && !environment.is_cockpit_client) { | ||
login_failure(_("User name cannot be empty")); | ||
} else if (need_host() && id("server-field").value === "") { | ||
} else if (need_host() && login_machine === "") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This added line is not executed by any test. |
||
login_failure(_("Please specify the host to connect to")); | ||
} else { | ||
const machine = id("server-field").value; | ||
if (machine) { | ||
application = "cockpit+=" + machine; | ||
if (login_machine) { | ||
application = "cockpit+=" + login_machine; | ||
login_path = org_login_path.replace("/" + org_application + "/", "/" + application + "/"); | ||
id("brand").style.display = "none"; | ||
id("badge").style.visibility = "hidden"; | ||
|
@@ -611,12 +618,12 @@ import "./login.scss"; | |
brand("brand", "Cockpit"); | ||
} | ||
|
||
id("server-name").textContent = machine || environment.hostname; | ||
id("server-name").textContent = login_machine || environment.hostname; | ||
id("login-button").removeEventListener("click", call_login); | ||
|
||
const password = id("login-password-input").value; | ||
|
||
const superuser_key = "superuser:" + user + (machine ? ":" + machine : ""); | ||
const superuser_key = "superuser:" + user + (login_machine ? ":" + login_machine : ""); | ||
const superuser = localStorage.getItem(superuser_key) || "none"; | ||
localStorage.setItem("superuser-key", superuser_key); | ||
localStorage.setItem(superuser_key, superuser); | ||
|
@@ -629,7 +636,7 @@ import "./login.scss"; | |
"X-Superuser": superuser, | ||
}; | ||
// allow unknown remote hosts with interactive logins with "Connect to:" | ||
if (machine) | ||
if (login_machine) | ||
headers["X-SSH-Connect-Unknown-Hosts"] = "yes"; | ||
|
||
send_login_request("GET", headers, false); | ||
|
@@ -770,25 +777,30 @@ import "./login.scss"; | |
function do_hostkey_verification(data) { | ||
const key_db = get_known_hosts_db(); | ||
const key = data["host-key"]; | ||
const key_key = key.split(" ")[0]; | ||
const key_host = key.split(" ")[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. <3. Srsly. This confused the heck out of me too. |
||
const key_type = key.split(" ")[1]; | ||
|
||
if (key_db[key_key] == key) { | ||
if (key_db[key_host] == key) { | ||
debug("do_hostkey_verification: received key matches known_hosts database, auto-accepting fingerprint", data.default); | ||
Comment on lines
+783
to
+784
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 added lines are not executed by any test. |
||
converse(data.id, data.default); | ||
return; | ||
} | ||
|
||
if (key_db[key_key]) { | ||
id("hostkey-title").textContent = format(_("$0 key changed"), id("server-field").value); | ||
if (key_db[key_host]) { | ||
debug("do_hostkey_verification: received key fingerprint", data.default, "for host", key_host, | ||
"does not match key in known_hosts database:", key_db[key_host], "; treating as changed"); | ||
id("hostkey-title").textContent = format(_("$0 key changed"), login_machine); | ||
show("#hostkey-warning-group"); | ||
id("hostkey-message-1").textContent = ""; | ||
} else { | ||
debug("do_hostkey_verification: received key fingerprint", data.default, "for host", key_host, | ||
"not in known_hosts database; treating as new host"); | ||
id("hostkey-title").textContent = _("New host"); | ||
hide("#hostkey-warning-group"); | ||
id("hostkey-message-1").textContent = format(_("You are connecting to $0 for the first time."), id("server-field").value); | ||
id("hostkey-message-1").textContent = format(_("You are connecting to $0 for the first time."), login_machine); | ||
} | ||
|
||
id("hostkey-verify-help-1").textContent = format(_("To verify a fingerprint, run the following on $0 while physically sitting at the machine or through a trusted network:"), id("server-field").value); | ||
id("hostkey-verify-help-1").textContent = format(_("To verify a fingerprint, run the following on $0 while physically sitting at the machine or through a trusted network:"), login_machine); | ||
id("hostkey-verify-help-cmds").textContent = format("ssh-keyscan$0 localhost | ssh-keygen -lf -", | ||
key_type ? " -t " + key_type : ""); | ||
|
||
|
@@ -806,7 +818,7 @@ import "./login.scss"; | |
function call_converse() { | ||
id("login-button").removeEventListener("click", call_converse); | ||
login_failure(null, "hostkey"); | ||
key_db[key_key] = key; | ||
key_db[key_host] = key; | ||
set_known_hosts_db(key_db); | ||
converse(data.id, data.default); | ||
} | ||
|
@@ -816,7 +828,7 @@ import "./login.scss"; | |
show_form("hostkey"); | ||
show("#get-out-link"); | ||
|
||
if (key_db[key_key]) { | ||
if (key_db[key_host]) { | ||
id("login-button").classList.add("pf-m-danger"); | ||
id("login-button").classList.remove("pf-m-primary"); | ||
} | ||
|
@@ -905,6 +917,7 @@ import "./login.scss"; | |
} | ||
|
||
function send_login_request(method, headers, is_conversation) { | ||
debug("send_login_request():", method, "headers:", JSON.stringify(headers)); | ||
id("login-button").setAttribute('disabled', "true"); | ||
id("login-button").setAttribute('spinning', "true"); | ||
const xhr = new XMLHttpRequest(); | ||
|
@@ -921,6 +934,7 @@ import "./login.scss"; | |
const resp = JSON.parse(xhr.responseText); | ||
run(resp); | ||
} else if (xhr.status == 401) { | ||
debug("send_login_request():", method, "got 401, status:", xhr.statusText, "; response:", xhr.responseText); | ||
const challenge = xhr.getResponseHeader("WWW-Authenticate"); | ||
if (challenge && challenge.toLowerCase().indexOf("x-conversation") === 0) { | ||
const prompt_data = get_prompt_from_challenge(challenge, xhr.responseText); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 added lines are not executed by any test.