Improve setup script auth usability
This commit is contained in:
parent
5a2d808aa1
commit
334ed3aedc
1 changed files with 25 additions and 23 deletions
|
|
@ -3593,15 +3593,14 @@ else
|
||||||
IFS= read -r AUTH_TOKEN
|
IFS= read -r AUTH_TOKEN
|
||||||
if command -v stty >/dev/null 2>&1; then stty echo; fi
|
if command -v stty >/dev/null 2>&1; then stty echo; fi
|
||||||
printf "\n"
|
printf "\n"
|
||||||
elif { exec 3</dev/tty; } 2>/dev/null; then
|
elif [ -c /dev/tty ] && [ -r /dev/tty ] && [ -w /dev/tty ]; then
|
||||||
printf "Pulse setup token: " >&3
|
printf "Pulse setup token: " >/dev/tty
|
||||||
if command -v stty >/dev/null 2>&1; then stty -echo <&3 2>/dev/null || true; fi
|
if command -v stty >/dev/null 2>&1; then stty -echo </dev/tty 2>/dev/null || true; fi
|
||||||
IFS= read -r AUTH_TOKEN <&3 || true
|
IFS= read -r AUTH_TOKEN </dev/tty || true
|
||||||
if command -v stty >/dev/null 2>&1; then stty echo <&3 2>/dev/null || true; fi
|
if command -v stty >/dev/null 2>&1; then stty echo </dev/tty 2>/dev/null || true; fi
|
||||||
printf "\n" >&3
|
printf "\n" >/dev/tty
|
||||||
exec 3<&-
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Only proceed with auto-registration if we have an auth token
|
# Only proceed with auto-registration if we have an auth token
|
||||||
if [ -n "$AUTH_TOKEN" ]; then
|
if [ -n "$AUTH_TOKEN" ]; then
|
||||||
|
|
@ -4653,15 +4652,14 @@ else
|
||||||
IFS= read -r AUTH_TOKEN
|
IFS= read -r AUTH_TOKEN
|
||||||
if command -v stty >/dev/null 2>&1; then stty echo; fi
|
if command -v stty >/dev/null 2>&1; then stty echo; fi
|
||||||
printf "\n"
|
printf "\n"
|
||||||
elif { exec 3</dev/tty; } 2>/dev/null; then
|
elif [ -c /dev/tty ] && [ -r /dev/tty ] && [ -w /dev/tty ]; then
|
||||||
printf "Pulse setup token: " >&3
|
printf "Pulse setup token: " >/dev/tty
|
||||||
if command -v stty >/dev/null 2>&1; then stty -echo <&3 2>/dev/null || true; fi
|
if command -v stty >/dev/null 2>&1; then stty -echo </dev/tty 2>/dev/null || true; fi
|
||||||
IFS= read -r AUTH_TOKEN <&3 || true
|
IFS= read -r AUTH_TOKEN </dev/tty || true
|
||||||
if command -v stty >/dev/null 2>&1; then stty echo <&3 2>/dev/null || true; fi
|
if command -v stty >/dev/null 2>&1; then stty echo </dev/tty 2>/dev/null || true; fi
|
||||||
printf "\n" >&3
|
printf "\n" >/dev/tty
|
||||||
exec 3<&-
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Only proceed with auto-registration if we have an auth token
|
# Only proceed with auto-registration if we have an auth token
|
||||||
if [ -n "$AUTH_TOKEN" ]; then
|
if [ -n "$AUTH_TOKEN" ]; then
|
||||||
|
|
@ -4871,12 +4869,16 @@ func (h *ConfigHandlers) HandleSetupScriptURL(w http.ResponseWriter, r *http.Req
|
||||||
tokenHint = fmt.Sprintf("%s…%s", token[:3], token[len(token)-3:])
|
tokenHint = fmt.Sprintf("%s…%s", token[:3], token[len(token)-3:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command := fmt.Sprintf(`curl -sSL "%s" | PULSE_SETUP_TOKEN=%s bash`, scriptURL, token)
|
||||||
|
|
||||||
response := map[string]interface{}{
|
response := map[string]interface{}{
|
||||||
"url": scriptURL,
|
"url": scriptURL,
|
||||||
"command": fmt.Sprintf(`curl -sSL "%s" | bash`, scriptURL),
|
"command": command,
|
||||||
"expires": expiry.Unix(),
|
"expires": expiry.Unix(),
|
||||||
"setupToken": token,
|
"setupToken": token,
|
||||||
"tokenHint": tokenHint,
|
"tokenHint": tokenHint,
|
||||||
|
"commandWithEnv": command,
|
||||||
|
"commandWithoutEnv": fmt.Sprintf(`curl -sSL "%s" | bash`, scriptURL),
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue