Skip to content

feat: add MINDWTR_REQUIRE_SYNC login gate for self-hosted web deployments - #1144

Closed
chief-nerd wants to merge 11 commits into
dongdongbh:mainfrom
chief-nerd:feature/require-sync-login-gate
Closed

feat: add MINDWTR_REQUIRE_SYNC login gate for self-hosted web deployments#1144
chief-nerd wants to merge 11 commits into
dongdongbh:mainfrom
chief-nerd:feature/require-sync-login-gate

Conversation

@chief-nerd

@chief-nerd chief-nerd commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Adds MINDWTR_REQUIRE_SYNC: set it to 1 on a self-hosted web/PWA deployment and the app shows a login screen (Self-Hosted URL + Access Token) before anything loads, instead of opening straight into a local, unsynced app.

It reuses the existing self-hosted sync credential and the same probe-then-commit flow the Settings page already uses — no new auth system, no new session concept. "Logged in" just means valid sync config is already saved locally; a later revoked token surfaces through the normal sync-error UI, not a bounce back to this screen. The URL field prefills from the same runtime config the server already provides (e.g. MINDWTR_DEFAULT_CLOUD_URL) when available, and both fields show the same hint text as the Settings page.

Delivered via the same runtime-config.json mechanism as MINDWTR_DEFAULT_CLOUD_URL (runtime, not build-time), so it works with the prebuilt Docker image. Only affects the browser/PWA build — Tauri and the quick-add window always skip it.

Heads up: this is a convenience gate, not real authentication. It's client-side and fails open, so put a reverse proxy in front if you need actual access control (documented in docker/README.md).

Testing

Full workspace suite passes except a few pre-existing, unrelated failures — verified present on main too (a date-dependent calendar test, the long-standing Korean locale gap, some attachment-GC tests). Everything this PR touches is green.

Checklist

  • I have signed the CLA
  • I have tested this change locally
  • I linked the relevant issue (or explained why there isn't one — no tracked issue)
  • I added or updated tests/docs if needed

JakobMimirio and others added 11 commits September 2, 2026 20:43
…ic wording

- sv.ts: Replace 'själv värdadad' (malformed) with 'egen' to match existing sv.ts terminology (egen server)
- fa.ts: Replace 'خودمیزبان' with 'میزبانی شخصی' to match existing fa.ts terminology
…creen

SyncService.performSync always pairs a requeue with success: true, so the
provenEnough check (which only looked at .success) let a fully-requeued
probe fall through and commit+log in without ever proving the connection.
Add the missing skipped === 'requeued' guard (mirrors useSyncSettings) and
fix the test's mock to use the real production shape.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…cument REQUIRE_SYNC

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… form

The encrypted-remote branch of provenEnough was independent of
probeResult.success, so a pendingRemoteWriteBackoff (or busy remote
fence) skip carrying a stale SYNC_ENCRYPTION_REMOTE_ENCRYPTED string in
its carried-over lastSyncError could satisfy it without the probe ever
talking to the server. Gate it on !success, matching Settings.

Also prefill the URL field from the already-fetched runtime-config
default (when the user hasn't typed anything) and show the existing
settings.cloudHint / settings.cloudTokenHint text under each field.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SyncLoginGate unmounts SyncLoginScreen the instant onLoggedIn() fires, but
getWebDefaultCloudUrl()'s underlying fetch can take up to 3s to resolve, so a
fast login could resolve the prefill after unmount. Add the same `active`
flag guard already used in SyncLoginGate.tsx for the analogous race.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@chief-nerd chief-nerd closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants