web setup: add an optional installation code

The purpose of this code is to prevent anyone who can access to
the initial setup screen from creating an admin user

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-02-27 14:27:53 +01:00
parent 4ed6e96c7b
commit b65dae89e8
12 changed files with 257 additions and 60 deletions

View File

@@ -211,8 +211,10 @@ type defenderHostsPage struct {
type setupPage struct {
basePage
Username string
Error string
Username string
HasInstallationCode bool
InstallationCodeHint string
Error string
}
type folderPage struct {
@@ -551,9 +553,11 @@ func renderMaintenancePage(w http.ResponseWriter, r *http.Request, error string)
func renderAdminSetupPage(w http.ResponseWriter, r *http.Request, username, error string) {
data := setupPage{
basePage: getBasePageData(pageSetupTitle, webAdminSetupPath, r),
Username: username,
Error: error,
basePage: getBasePageData(pageSetupTitle, webAdminSetupPath, r),
Username: username,
HasInstallationCode: installationCode != "",
InstallationCodeHint: installationCodeHint,
Error: error,
}
renderAdminTemplate(w, templateSetup, data)