From f80f6c87e829b9e60040a9ea8956d618ab3a8d46 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 17 Jun 2026 10:15:28 -0400 Subject: [PATCH] feat(auth): capture Steward URL during first-run admin setup (OOBE) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A fresh install had no prompt for general.public_base_url, so first-run agent installs/share links silently used the request Host header. Add a "Steward URL" field to the first-run /setup page (create-admin), pre-filled with the current address, with help text. setup_post saves general.public_base_url and applies it to app.config immediately (no restart). Editable later in Settings → General. Scribe #896. Co-Authored-By: Claude Opus 4.8 (1M context) --- steward/auth/routes.py | 12 +++++++++++- steward/templates/auth/setup.html | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/steward/auth/routes.py b/steward/auth/routes.py index e646c6b..f1cd510 100644 --- a/steward/auth/routes.py +++ b/steward/auth/routes.py @@ -184,7 +184,10 @@ async def setup(): from quart import current_app if await get_user_count(current_app) > 0: return redirect(url_for("auth.login")) - return await render_template("auth/setup.html") + # Pre-fill the public URL with however the operator reached this page — the + # common case is correct, and it's what agent installs / share links use. + return await render_template( + "auth/setup.html", default_url=request.host_url.rstrip("/")) @auth_bp.post("/setup") @@ -201,9 +204,16 @@ async def setup_post(): return await render_template("auth/setup.html", error="All fields required"), 400 pw_hash = bcrypt.hashpw(password, bcrypt.gensalt()).decode() user = User(username=username, email=email, password_hash=pw_hash, role=UserRole.admin) + steward_url = (form.get("public_base_url", "") or "").strip().rstrip("/") async with current_app.db_sessionmaker() as db: async with db.begin(): db.add(user) + if steward_url: + from steward.core.settings import set_setting + await set_setting(db, "general.public_base_url", steward_url) + if steward_url: + # Apply immediately so agent installs / share links use it without a restart. + current_app.config["PUBLIC_BASE_URL"] = steward_url login_user(user) await log_audit(current_app, user.id, user.username, "auth.setup", detail={"username": username}) diff --git a/steward/templates/auth/setup.html b/steward/templates/auth/setup.html index 48a076a..00c3db7 100644 --- a/steward/templates/auth/setup.html +++ b/steward/templates/auth/setup.html @@ -18,6 +18,17 @@ +
+ + + + Used for agent installs, share links, and alert links. Pre-filled from your current + address — change it if hosts reach Steward by a different name. Editable later in Settings → General. + +