Implement the following plan: Fix: Remote deployment auth setup dead-end (#646) Context…
- User
Implement the following plan:
Fix: Remote deployment auth setup dead-end (#646)
Context
A user running Moltis via docker-compose on a remote server (with
MOLTIS_NO_TLS=true) reports that visiting the web UI shows a page titled "Authentication Not Configured" that tells them to runmoltis auth reset-password. Running that command in the container does not help — they are stuck and cannot complete first-time setup remotely.The irony: the onboarding UI already has a working setup-code flow for remote users (entered via the terminal stdout), and the auth gate already allows
/onboardingto render for non-local connections during setup. The only thing missing is that remote users are never sent there — they hit a static dead-end page instead.What the code actually does today
crates/httpd/src/auth_middleware.rs:146-162— when setup is required and the request is remote and the path is not/onboarding, the middleware redirects to/setup-required.crates/web/src/spa.rs:49-60+crates/web/src/templates/setup-required.html— render a static page whose only advice is: runmoltis auth reset-password. That CLI command wipes credentials (crates/cli/src/auth_commands.rs:204-217) — it does not help a fresh install where no credentials exist yet; the server still prints a new setup code on the next start, but the web page gives no hint of that.crates/web/src/assets/js/onboarding-view.js:175-526—AuthStepalready supports remote setup: whenGET /api/auth/statusreturnssetup_code_required: true, it renders a "Setup code" input and sends it withPOST /api/auth/setup(validated atcrates/httpd/src/auth_routes.rs:166-213against the in-memory code generated atcrates/gateway/src/server.rs:3373-3381).crates/web/src/spa.rs:30-43+crates/web/src/templates.rs:793-795—should_redirect_from_onboardingalready returnsfalsewhenauth_setup_pending=true, so/onboardingwill stay on the onboarding page during remote setup (the original redirect-loop #350 was already solved at the template layer).
Why the current
/setup-requiredredirect existedCommit
fd01fb94(PR #356) added the/setup-requiredredirect to fix both a redirect loop between and , and a security concern that a remote user could "claim" the instance before the owner. The loop was fixed separately (onboarding handler no longer bounces away while auth is pending), and the security concern is already mitigated by the requirement — the code is only visible in stdout on the server, so a remote attacker without terminal access cannot complete setup even if they can reach . Assistant
Now let me make the changes. Start with the middleware:
Assistant
Now update the HTML template:
Assistant
Now update the template test:
Assistant
Now update the integration tests in auth_middleware.rs:
Assistant
Now let me also update the assertions about "must not redirect to /setup-required" in the /onboarding passthrough tests — they should now assert the direction more accurately. Actually those are still valid (they ensure onboarding isn't redirected), but I could tighten them. Let me leave them as is since they're still true.
Now the e2e test:
Assistant
Good —
/setup-requiredremains a public path, so stale bookmarks still work. Let me also check the page-settings.js references — they mention "setup-required page" in user-facing hints:Assistant
Compiles cleanly. Now run the specific tests:
- Assistant· <synthetic>
You've hit your limit · resets 8pm (Europe/Lisbon)
- Assistant· <synthetic>
You've hit your limit · resets 8pm (Europe/Lisbon)
- User
proceed
Assistant
Template test passes. Now run the httpd integration tests:
Assistant
All 5 tests pass. Now run format check:
Assistant
Format clean. Now let me also verify the plan mentioned "Add regression coverage" for unit-level test. The integration test
root_redirects_to_onboarding_for_remotealready covers this, plus I updated thesetup_required_page_accessible_for_remoteand template tests. That satisfies the regression coverage requirement.Let me check one more thing — the plan mentions a unit test in
crates/httpd/src/auth_middleware.rs. Let me check if there are inline tests there:Assistant
Plan complete. Let me run biome on the JS file and check git status:
Assistant
Implementation complete. Summary of changes:
crates/httpd/src/auth_middleware.rs—auth_gatenow redirects remote SetupRequired traffic to/onboarding(was/setup-required). Comment updated to reference #646 + #350 and explain the security model (setup code gates completion).crates/web/src/templates/setup-required.html— Rewritten body: heading "First-time setup", instructs user to find the one-time setup code in stdout (docker compose logs moltis), prominent "Continue setup →" link to/onboarding. Keeps a subtle note aboutmoltis auth reset-passwordfor locked-out recovery with filesystem access, but no longer recommends it as the primary path.crates/web/src/templates.rs—setup_required_template_renders_htmlasserts new heading, "setup code" text, and link.Assistant
Already read that output earlier — the 5 tests passed (
root_redirects_to_onboarding_for_remote,setup_required_page_accessible_for_remote,onboarding_passes_through_for_remote_during_setup,onboarding_passes_through_for_local_during_setup,setup_required_redirects_to_login_after_setup). Implementation is complete; no further action needed.- User
proceed
Assistant
The plan is fully implemented and verified. Nothing further to do — all changes are made, tests pass, formatting is clean, and the beads issue is closed. The files are left unstaged per project policy (commit only on explicit request).
- User
commit push and create a PR
Assistant
PR created: https://github.com/moltis-org/moltis/pull/665
- Committed as
04afae6eonspurious-idea - Pushed to
origin/spurious-idea - PR #665 opened against
main, closes #646
- Committed as
- User
Fix and resolve PR comments
Assistant
Now let me check whether there's a local-validate.sh script that I need to run to satisfy the local/* CI gates:
Assistant
Now commit the Greptile fix and run the full local-validate.sh. Let me amend by creating a new commit:
Assistant
Now run local-validate.sh in the background — it publishes local status checks required by CI:
Assistant
While that runs, push the Greptile fix commit and reply to the review comment:
Assistant
Now let me try to resolve the comment thread via GraphQL:
Assistant
Review thread resolved. Now let me check the local-validate status:
Assistant
The initial local-validate.sh is actually working — it's publishing status checks and most are passing. Just waiting on
local/test(nextest still running). Let me wait for it.Assistant
Tests pass. macOS/iOS builds still running. Let me wait for them:
Assistant
The validation is actively building the swift-bridge for macOS/iOS app checks. These take a while. Let me wait longer:
Assistant
Coverage is still running. Let me wait more:
Assistant
All checks green. PR #665 is ready:
Review feedback addressed:
- Greptile P2: replaced custom
.ctaclass with sharedprovider-btn provider-btn-secondaryclasses (commit45c797f0). Thread resolved.
CI status (all green):
local/*checks all pass (fmt, biome, lint, test, coverage, e2e, i18n, zizmor, macos-app, ios-app, build, build-css, install-docs, install-names, lockfile)- GitHub Actions mirrors (fmt, clippy, biome, test, i18n, zizmor, macos-app, ios-app) all pass
- Code Coverage, CodSpeed, codecov/patch, CodeQL all pass
PR ready to merge: https://github.com/moltis-org/moltis/pull/665
- Greptile P2: replaced custom