Update wizard back logic and tweak setup.html
This commit is contained in:
parent
c16e954715
commit
afeb5e4541
|
@ -61,7 +61,7 @@ repos:
|
|||
hooks:
|
||||
- id: codespell
|
||||
name: Codespell Spell Checker
|
||||
exclude: (^src/(common/core/.+/files|bw/loading)/.+.html|modsecurity-rules.conf.*)$
|
||||
exclude: (^src/(ui/templates|common/core/.+/files|bw/loading)/.+.html|modsecurity-rules.conf.*)$
|
||||
entry: codespell --ignore-regex="(tabEl|Widgits)" --skip src/ui/static/js/utils/flatpickr.js,CHANGELOG.md
|
||||
language: python
|
||||
types: [text]
|
||||
|
|
|
@ -231,7 +231,7 @@ csrf = CSRFProtect()
|
|||
csrf.init_app(app)
|
||||
|
||||
LOG_RX = re_compile(r"^(?P<date>\d+/\d+/\d+\s\d+:\d+:\d+)\s\[(?P<level>[a-z]+)\]\s\d+#\d+:\s(?P<message>[^\n]+)$")
|
||||
REVERSE_PROXY_PATH = re_compile(r"^(?P<host>https?://[a-zA-Z0-9.-]{1,255}(:((6553[0-5])|(655[0-2]\d)|(65[0-4]\d{2})|(6[0-4]\d{3})|([1-5]\d{4})|([0-5]{0,5})|(\d{1,4})))?)(?P<url>/.*)?$")
|
||||
REVERSE_PROXY_PATH = re_compile(r"^(?P<host>https?://[a-zA-Z0-9.-]{1,255}(:((6553[0-5])|(655[0-2]\d)|(65[0-4]\d{2})|(6[0-4]\d{3})|([1-5]\d{4})|([0-5]{0,5})|(\d{1,4})))?)$")
|
||||
|
||||
|
||||
def manage_bunkerweb(method: str, *args, operation: str = "reloads"):
|
||||
|
@ -362,8 +362,8 @@ def setup():
|
|||
flash("Missing form data.", "error")
|
||||
return redirect(url_for("setup"))
|
||||
|
||||
if not any(key in request.form for key in ("admin_username", "admin_password", "admin_password_check", "server_name", "hostname")):
|
||||
flash("Missing either admin_username, admin_password, server_name or hostname parameter.", "error")
|
||||
if not any(key in request.form for key in ("admin_username", "admin_password", "admin_password_check", "server_name", "ui_host", "ui_url")):
|
||||
flash("Missing either admin_username, admin_password, admin_password_check, server_name, ui_host, ui_url or auto_lets_encrypt parameter.", "error")
|
||||
return redirect(url_for("setup"))
|
||||
|
||||
error = False
|
||||
|
@ -393,15 +393,13 @@ def setup():
|
|||
error = True
|
||||
break
|
||||
|
||||
if not (hostname := REVERSE_PROXY_PATH.search(request.form["hostname"])):
|
||||
if not REVERSE_PROXY_PATH.match(request.form["ui_host"]):
|
||||
flash("The hostname is not valid.", "error")
|
||||
error = True
|
||||
|
||||
if error:
|
||||
return redirect(url_for("setup"))
|
||||
|
||||
assert hostname
|
||||
|
||||
app.config["USER"] = User(request.form["admin_username"], request.form["admin_password"])
|
||||
|
||||
ret = db.create_ui_user(app.config["USER"].get_id(), app.config["USER"].password_hash)
|
||||
|
@ -422,8 +420,9 @@ def setup():
|
|||
"SERVER_NAME": request.form["server_name"],
|
||||
"USE_UI": "yes",
|
||||
"USE_REVERSE_PROXY": "yes",
|
||||
"REVERSE_PROXY_HOST": hostname.group("host"),
|
||||
"REVERSE_PROXY_URL": hostname.group("url") or "/",
|
||||
"REVERSE_PROXY_HOST": request.form["ui_host"],
|
||||
"REVERSE_PROXY_URL": request.form["ui_url"] or "/",
|
||||
"AUTO_LETS_ENCRYPT": request.form.get("auto_lets_encrypt", "no"),
|
||||
"INTERCEPTED_ERROR_CODES": "400 404 405 413 429 500 501 502 503 504",
|
||||
},
|
||||
request.form["server_name"],
|
||||
|
|
|
@ -1299,9 +1299,8 @@
|
|||
type="text"
|
||||
id="ui_host"
|
||||
name="ui_host"
|
||||
value="UI_HOST"
|
||||
class="col-span-12 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-300 disabled:opacity-75 focus:valid:border-green-500 focus:invalid:border-red-500 outline-none focus:border-primary text-sm leading-5.6 ease block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-4 py-2 font-normal text-gray-700 transition-all placeholder:text-gray-500"
|
||||
placeholder="UI_HOST"
|
||||
placeholder="http://bw-ui:7000"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
@ -1350,7 +1349,6 @@
|
|||
aria-checked="false"
|
||||
class="checkbox"
|
||||
value="no"
|
||||
required
|
||||
/>
|
||||
<svg
|
||||
data-checkbox-handler="auto_lets_encrypt"
|
||||
|
@ -1381,7 +1379,7 @@
|
|||
id="server_name"
|
||||
name="server_name"
|
||||
class="col-span-12 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-300 disabled:opacity-75 focus:valid:border-green-500 focus:invalid:border-red-500 outline-none focus:border-primary text-sm leading-5.6 ease block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-4 py-2 font-normal text-gray-700 transition-all placeholder:text-gray-500"
|
||||
placeholder="app1.example.com"
|
||||
placeholder="www.example.com"
|
||||
minlength="1"
|
||||
required
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue