fix(httpd): redirect remote setup traffic to onboarding wizard#665
fix(httpd): redirect remote setup traffic to onboarding wizard#665
Conversation
Remote visitors on a fresh deployment were redirected to a static /setup-required dead-end page that instructed them to run `moltis auth reset-password`, which is useless on a fresh install and left users stuck. The onboarding wizard already supports remote setup via a one-time setup code printed to stdout, but remote users were never sent there. Redirect remote SetupRequired traffic to /onboarding so users can enter the setup code (from `docker compose logs moltis`) and complete first- time setup via the AuthStep. The original redirect loop between / and /onboarding (#350) is already fixed at the SPA template layer via should_redirect_from_onboarding, and the setup-code requirement still prevents an unauthorized remote visitor from claiming the instance. Repurpose /setup-required as a stale-bookmark fallback with a prominent link to /onboarding and updated copy that points users at the setup code in stdout. Drop the misleading reset-password instructions from the primary flow. Closes #646 Entire-Checkpoint: 4e8cfe8c7a17
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryFixes the remote first-time setup dead-end (#646) by redirecting Confidence Score: 5/5Safe to merge; redirect logic is sound, loop prevention is verified, and all findings are P2 style suggestions. The core logic change is a single redirect target swap in auth_gate, backed by correct loop-prevention in onboarding_handler (should_redirect_from_onboarding returns false while auth_setup_pending is true). Tests cover the new redirect, the fallback page content, the post-setup redirect, and the E2E flow. The only finding is a P2 style suggestion to reuse an existing components.css class for the CTA button. crates/web/src/templates/setup-required.html — minor CTA styling could reuse provider-btn-secondary Important Files Changed
Sequence DiagramsequenceDiagram
participant R as Remote Visitor
participant MW as auth_gate
participant OH as onboarding_handler
participant SH as setup_required_handler
Note over R,SH: Fresh install, setup incomplete
R->>MW: GET /
MW->>MW: SetupRequired (remote, not /onboarding)
MW-->>R: 302 /onboarding
R->>MW: GET /onboarding
MW->>MW: SetupRequired + path is /onboarding, pass through
MW->>OH: forward
OH->>OH: onboarded false, auth pending true
OH->>OH: should_redirect_from_onboarding returns false
OH-->>R: 200 Onboarding SPA with setup-code AuthStep
Note over R,SH: Stale bookmark hits /setup-required
R->>MW: GET /setup-required
MW->>MW: is_public_path, pass through
MW->>SH: forward
SH->>SH: is_setup_complete returns false
SH-->>R: 200 Fallback page with link to /onboarding
Note over R,SH: After setup is complete
R->>MW: GET /setup-required
MW->>SH: forward (public path)
SH->>SH: is_setup_complete returns true
SH-->>R: 302 /login
Reviews (1): Last reviewed commit: "fix(httpd): redirect remote setup traffi..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Replace the custom `.cta` class padding/border/color definitions with the shared `provider-btn` / `provider-btn-secondary` classes from components.css so the CTA adopts the page theme colours instead of falling back to default anchor colours (Greptile P2 review). Entire-Checkpoint: 3d594e395d28
Summary
Fixes #646 — remote visitors on fresh deployments (docker-compose with
MOLTIS_NO_TLS=true) were stuck on a static "Authentication Not Configured" dead-end page that told them to runmoltis auth reset-password. That CLI command is useless on a fresh install (no credentials to reset) and left users with no path to complete first-time setup.The onboarding wizard's
AuthStepalready supports remote setup via a one-time setup code printed to stdout, but remote users were never sent there.SetupRequiredtraffic to/onboarding(was/setup-required). Users can now enter the 6-digit setup code fromdocker compose logs moltisand complete setup normally./↔/onboardingredirect loop ([Bug]: too many redirects over tailscale #350) is already fixed at the SPA template layer viashould_redirect_from_onboarding, and the setup-code requirement still prevents an unauthorized remote visitor from claiming the instance./setup-requiredas a stale-bookmark fallback: rewritten body with a prominent "Continue setup →" link to/onboardingand updated copy pointing users at the setup code.moltis auth reset-passwordis demoted to a side note for locked-out recovery scenarios.Validation
Completed
cargo test -p moltis-httpd --test auth_middleware -- root_redirects_to_onboarding_for_remote setup_required_page_accessible_for_remote setup_required_redirects_to_login_after_setup onboarding_passes— 5/5 passingcargo test -p moltis-web --lib --features vault,web-ui templates::tests::setup_required— passingcargo check -p moltis-httpd -p moltis-web— cleancargo +nightly-2025-11-30 fmt --all -- --check— cleanbiome check --write crates/web/ui/e2e/specs/onboarding-auth.spec.js— cleanRemaining
just lint(OS-aware clippy)just test(full test suite)npx playwright test e2e/specs/onboarding-auth.spec.js(restored to visit/instead of/onboarding)Manual QA
Mirror the bug report:
docker build -t moltis-local .MOLTIS_NO_TLS=truebound to a non-loopback interface (or access via LAN IP).http://<host>:<port>/./onboarding, AuthStep shows "Setup code" input.docker compose logs moltisprints the 6-digit code./setup-requireddead-end, and subsequent visits after logout land on/login.Security sanity check
POST /api/auth/setup(validated atcrates/httpd/src/auth_routes.rs:179-183)./api/*remote calls duringSetupRequiredstill returnAUTH_SETUP_REQUIRED401 — unchanged./onboardinggets the normal auth gate back — unchanged.