Python
1.36.0: First-time setup without one-time code (optional SETUP_TOKEN)
DerMilderJoghurt8c57c099a976
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3c165af..5be6774 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,13 @@Version numbers follow [SemVer](https://semver.org/): MAJOR.MINOR.PATCH(MAJOR = incompatible change, MINOR = new feature, PATCH = bug fix).+## 1.36.0 – 2026-11-23+- **First-time setup without a one-time code:** as long as no user exists, the first visit in the browser creates+ the admin directly (user name and password are enough). The setup code from the container log is gone.+- If you still want the code (e.g. because the container is reachable from the internet before the setup), set+ `SETUP_TOKEN=true`. The setup then works as before. The README explains the risk.+- Existing installations with users are not affected.+## 1.35.0 – 2026-11-23- **Two-way sync creates missing folders:** if the folder of side A or side B does not exist yet on the first run,it is created (previously the run stopped with "directory not found", except with "Also copy the source folderdiff --git a/Dockerfile b/Dockerfileindex 8a848d5..e6b7cc6 100644--- a/Dockerfile+++ b/Dockerfile@@ -18,7 +18,7 @@ RUN for i in 1 2 3; do \exit 1COPY app/ .-ARG VERSION=1.35.0+ARG VERSION=1.36.0LABEL org.opencontainers.image.title="MirrorSync" org.opencontainers.image.version=$VERSIONENV TZ=Europe/Berlin CONFIG_DIR=/config LOG_DIR=/logs PORT=8080 PYTHONUNBUFFERED=1VOLUME ["/config", "/logs"]diff --git a/README.de.md b/README.de.mdindex 7e8ec84..2358f68 100644--- a/README.de.md+++ b/README.de.md@@ -4,7 +4,7 @@# MirrorSync – 1:1-Spiegelung mit Web-GUI und Zeitplänen-Version **1.35.0** · Änderungen siehe [CHANGELOG.md](CHANGELOG.md) (englisch) · [English version](README.md)+Version **1.36.0** · Änderungen siehe [CHANGELOG.md](CHANGELOG.md) (englisch) · [English version](README.md)Ein Docker-Container, der Ordner **einweg 1:1 spiegelt** (wie FreeFileSync „Spiegeln"):Das Ziel wird exakt wie die Quelle, inklusive Löschungen. Als Sync-Motor dient@@ -33,7 +33,7 @@ docker run -d --name mirrorsync --restart unless-stopped \-v ./config:/config -v ./logs:/logs \ghcr.io/dermilderjoghurt/mirrorsync:latest```-Dann `http://<docker-host>:8080` öffnen und den Einrichtungs-Code aus `docker logs mirrorsync` eingeben.+Dann `http://<docker-host>:8080` öffnen und den ersten Admin anlegen.## Funktionen- **Mehrere Benutzer** mit **eigenen Rollen** (Einzelrechte pro Aktion, beschränkbar auf einzelne Aufgaben und Speicherorte), **2FA** per Authenticator-App inkl. Backup-Codes und **Passkeys**@@ -68,7 +68,7 @@ Geänderte Dateien werden komplett neu übertragen (kein Delta wie bei rsync).## InstallationDas fertige Image liegt in der GitHub Container Registry: `ghcr.io/dermilderjoghurt/mirrorsync`-(für amd64 und arm64, z. B. Raspberry Pi). Tags: `latest` (neueste Version), `1.35.0` (feste Version),+(für amd64 und arm64, z. B. Raspberry Pi). Tags: `latest` (neueste Version), `1.36.0` (feste Version),`1.34` (neuester Patch dieser Version).### Mit Docker Compose (empfohlen)@@ -158,16 +158,16 @@ Passwörter werden gehasht in der Datenbank `config/mirrorsync.db` gespeichert.aus der Compose-Datei löschen, sie werden nur noch für den Notfall (`ADMIN_RESET`) gebraucht.### Ersteinrichtung-Beim ersten Start (noch kein Benutzer angelegt) schreibt der Container einen **Einrichtungs-Code**-ins Log, z. B. `6E7W-U9DF-3HK3`:-```-docker logs mirrorsync-```-1. Web-GUI öffnen, Einrichtungs-Code, Benutzername und Passwort eingeben → der erste Admin ist angelegt.- Ohne den Code kann niemand sonst den frischen Container übernehmen; Fehlversuche werden gebremst und geloggt.+Solange noch kein Benutzer angelegt ist, führt der erste Aufruf im Browser direkt zur Ersteinrichtung:+1. Web-GUI öffnen, Benutzername und Passwort eingeben → der erste Admin ist angelegt.2. Optional gleich 2FA (Authenticator-App) und/oder einen Passkey einrichten, oder „Fertig“.-Der Code steht auch in `config/setup_token` und gilt bis der Admin angelegt ist, danach wird er gelöscht.+> **Achtung:** Bis der Admin angelegt ist, kann jeder, der die Web-GUI erreicht, diesen Admin anlegen. Lege ihn+> deshalb gleich nach dem ersten Start an. Ist der Container schon vorher aus dem Internet erreichbar (z. B. über+> eine Portfreigabe), setze `SETUP_TOKEN=true`: Dann schreibt der Container beim ersten Start einen+> **Einrichtungs-Code** ins Log (`docker logs mirrorsync`, auch in `config/setup_token`), ohne den sich der Admin+> nicht anlegen lässt. Fehlversuche werden gebremst und geloggt, nach der Einrichtung wird der Code gelöscht.+Wer weiter `WEB_USER`/`WEB_PASS` setzt, bekommt wie früher den Admin automatisch angelegt.### Passkeysdiff --git a/README.md b/README.mdindex b60e04c..b213501 100644--- a/README.md+++ b/README.md@@ -4,7 +4,7 @@# MirrorSync – 1:1 mirroring with a web GUI and schedules-Version **1.35.0** · Changes: [CHANGELOG.md](CHANGELOG.md) · [Deutsche Version](README.de.md)+Version **1.36.0** · Changes: [CHANGELOG.md](CHANGELOG.md) · [Deutsche Version](README.de.md)A Docker container that **mirrors folders one-way, 1:1** (like FreeFileSync "Mirror"):the destination becomes an exact copy of the source, including deletions. The sync engine is@@ -33,7 +33,7 @@ docker run -d --name mirrorsync --restart unless-stopped \-v ./config:/config -v ./logs:/logs \ghcr.io/dermilderjoghurt/mirrorsync:latest```-Then open `http://<docker-host>:8080` and enter the setup code from `docker logs mirrorsync`.+Then open `http://<docker-host>:8080` and create the first admin.## Features- **Multiple users** with **custom roles** (individual permissions per action, can be limited to specific jobs and storage locations), **2FA** with an authenticator app incl. backup codes, and **passkeys**@@ -67,7 +67,7 @@ Changed files are transferred completely (no delta transfer like rsync).## InstallationThe ready-made image is in the GitHub Container Registry: `ghcr.io/dermilderjoghurt/mirrorsync`-(for amd64 and arm64, e.g. Raspberry Pi). Tags: `latest` (newest version), `1.35.0` (fixed version),+(for amd64 and arm64, e.g. Raspberry Pi). Tags: `latest` (newest version), `1.36.0` (fixed version),`1.34` (newest patch of this version).### With Docker Compose (recommended)@@ -156,15 +156,16 @@ Passwords are stored hashed in the database `config/mirrorsync.db`.from the compose file, they are only needed for emergencies (`ADMIN_RESET`).### First-time setup-On the first start (no user yet) the container writes a **setup code** to the log, e.g. `6E7W-U9DF-3HK3`:-```-docker logs mirrorsync-```-1. Open the web GUI, enter the setup code, user name and password → the first admin is created.- Without the code nobody else can take over the fresh container; failed attempts are throttled and logged.+As long as no user exists, the first visit in the browser leads straight to the first-time setup:+1. Open the web GUI, enter a user name and password → the first admin is created.2. Optionally set up 2FA (authenticator app) and/or a passkey right away, or click "Done".-The code is also in `config/setup_token` and is valid until the admin has been created, then it is deleted.+> **Caution:** until the admin has been created, anyone who can reach the web GUI can create that admin. So create+> it right after the first start. If the container is reachable from the internet before that (e.g. through a port+> forward), set `SETUP_TOKEN=true`: the container then writes a **setup code** to the log on the first start+> (`docker logs mirrorsync`, also in `config/setup_token`), and the admin cannot be created without it. Failed+> attempts are throttled and logged, the code is deleted after the setup.+If you keep setting `WEB_USER`/`WEB_PASS`, the admin is created automatically as before.### Passkeysdiff --git a/app/VERSION b/app/VERSIONindex 2aeaa11..39fc130 100644--- a/app/VERSION+++ b/app/VERSION@@ -1 +1 @@-1.35.0+1.36.0diff --git a/app/app.py b/app/app.pyindex a765535..14408af 100644--- a/app/app.py+++ b/app/app.py@@ -1087,11 +1087,15 @@ IPGUARD_OFF = os.environ.get("IPGUARD", "").lower() in ("0", "off", "false", "neSETUP_TOKEN_FILE = os.path.join(CONFIG_DIR, "setup_token")SETUP_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789" # ohne 0/O und 1/I+# Einmal-Code bei der Ersteinrichtung nur auf Wunsch (SETUP_TOKEN=true), z. B. wenn der Container vor dem ersten+# Admin schon aus dem Internet erreichbar ist. Standard: der erste Aufruf im Browser legt direkt den Admin an.+SETUP_TOKEN_ON = os.environ.get("SETUP_TOKEN", "").strip().lower() in ("1", "true", "yes", "on", "ja")def setup_token(show=False):- """Einmal-Code fuer die Ersteinrichtung. Existiert nur, solange es keinen Benutzer gibt, und steht im Container-Log."""- if store.load():+ """Einmal-Code fuer die Ersteinrichtung (nur mit SETUP_TOKEN=true). Existiert nur, solange es keinen Benutzer gibt,+ und steht im Container-Log."""+ if store.load() or not SETUP_TOKEN_ON:try:os.remove(SETUP_TOKEN_FILE)except OSError:@@ -1667,7 +1671,7 @@ def setup():elif request.method == "POST":name, pw = request.form.get("user", "").strip(), request.form.get("password", "")typed = re.sub(r"[^A-Z0-9]", "", request.form.get("token", "").upper())- if not token or not hmac.compare_digest(typed, token.replace("-", "")):+ if SETUP_TOKEN_ON and (not token or not hmac.compare_digest(typed, token.replace("-", ""))):_fail()print(f"Ersteinrichtung: falscher Einrichtungs-Code von {_client_ip()}", flush=True)err = "Einrichtungs-Code falsch. Er steht im Container-Log (docker logs mirrorsync)."@@ -1692,7 +1696,7 @@ def setup():session["welcome"] = Truereturn redirect(url_for("account"))return render_template("login.html", mode="setup", err=err, user=request.form.get("user", ""),- token_typed=request.form.get("token", ""))+ token_typed=request.form.get("token", ""), need_token=SETUP_TOKEN_ON)@app.route("/login", methods=["GET", "POST"])diff --git a/app/templates.py b/app/templates.pyindex 7fd1463..178a918 100644--- a/app/templates.py+++ b/app/templates.py@@ -1234,9 +1234,9 @@ code{font-family:ui-monospace,monospace;font-size:12px;background:var(--card2);b<button>Bestätigen</button><p style="text-align:center;margin:14px 0 0"><a href="/login" style="color:var(--mut);font-size:13px">Abbrechen</a></p>{% else %}-{% if mode == "setup" %}<label for="tok">Einrichtungs-Code</label><input id="tok" type="text" name="token" value="{{ token_typed or '' }}" autocomplete="off" autocapitalize="characters" spellcheck="false" placeholder="XXXX-XXXX-XXXX" required autofocus style="letter-spacing:.12em;font-family:ui-monospace,monospace">+{% if mode == "setup" and need_token %}<label for="tok">Einrichtungs-Code</label><input id="tok" type="text" name="token" value="{{ token_typed or '' }}" autocomplete="off" autocapitalize="characters" spellcheck="false" placeholder="XXXX-XXXX-XXXX" required autofocus style="letter-spacing:.12em;font-family:ui-monospace,monospace"><p class="sub" style="margin:6px 0 0;font-size:12.5px">Steht im Container-Log: <code>docker logs mirrorsync</code> (oder in <code>config/setup_token</code>). Damit kann niemand sonst deinen Container übernehmen, bevor du den Admin angelegt hast.</p>{% endif %}-<label for="u">Benutzername</label><input id="u" type="text" name="user" value="{{ user }}" autocomplete="username" {{ "" if user or mode == "setup" else "autofocus" }} required>+<label for="u">Benutzername</label><input id="u" type="text" name="user" value="{{ user }}" autocomplete="username" {{ "" if user or (mode == "setup" and need_token) else "autofocus" }} required><label for="pw">Passwort</label><input id="pw" type="password" name="password" autocomplete="{{ 'new-password' if mode == 'setup' else 'current-password' }}" {{ "autofocus" if user and mode != "setup" }} required>{% if mode == "setup" %}<label for="pw2">Passwort wiederholen</label><input id="pw2" type="password" name="password2" autocomplete="new-password" required><p class="sub" style="margin:8px 0 16px;font-size:12.5px">Mindestens 8 Zeichen. Im nächsten Schritt kannst du optional 2FA und einen Passkey einrichten.</p>diff --git a/docker-compose.yml b/docker-compose.ymlindex 8b3f666..87a1d4e 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -8,7 +8,7 @@services:mirrorsync:- image: ghcr.io/dermilderjoghurt/mirrorsync:latest # or a fixed version, e.g. :1.35.0+ image: ghcr.io/dermilderjoghurt/mirrorsync:latest # or a fixed version, e.g. :1.36.0# Build it yourself instead of pulling (Dockerfile and app/ in the same folder):# build: .container_name: mirrorsync@@ -16,7 +16,8 @@ services:environment:- TZ=Europe/Berlin# No user/password needed here: you create the admin when you first open the web GUI.- # The setup code for that is shown by: docker logs mirrorsync+ # - SETUP_TOKEN=true # optional: require a setup code (then shown by: docker logs mirrorsync),+ # useful if the container is reachable from the internet before the setup# - PUBLIC_URL=https://sync.example.com # optional, address for passkeys (can also be set in the GUI)# Emergency, if you locked yourself out (comment out again afterwards):# - WEB_USER=admin