Python
1.40.0: Android app (wrapper around the web interface) with notifications and passkeys
Claude09ff293a0380
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex efa4585..b190a5a 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -99,15 +99,28 @@ jobs:ignore-unfixed: trueskip-setup-trivy: true+ # Android app (android/), see android.yml. The release job attaches the APK.+ android:+ if: github.ref == 'refs/heads/main'+ uses: ./.github/workflows/android.yml+ secrets: inherit+# On a new version in app/VERSION, automatically creates tag vX.Y.Z and a GitHub release- # (text from the matching CHANGELOG section, ZIP of the repo attached).+ # (text from the matching CHANGELOG section, ZIP of the repo and the signed Android APK attached).release:- needs: build- if: github.ref == 'refs/heads/main'+ needs: [build, android]+ if: ${{ !cancelled() && needs.build.result == 'success' && github.ref == 'refs/heads/main' }}runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4+ - name: Get the Android APK+ uses: actions/download-artifact@v4+ continue-on-error: true+ with:+ name: mirrorsync-apk+ path: apk+- name: Create release or update its textenv:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}@@ -132,3 +145,7 @@ jobs:gh release create "v$V" "mirrorsync-$V.zip" \--target "$GITHUB_SHA" --title "MirrorSync $V" --notes-file notes.md --latestfi+ # signed APK only (an unsigned one cannot be installed)+ if [ -f "apk/mirrorsync-$V.apk" ]; then+ gh release upload "v$V" "apk/mirrorsync-$V.apk" --clobber+ fidiff --git a/CHANGELOG.md b/CHANGELOG.mdindex b15369f..9535042 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,25 @@Version numbers follow [SemVer](https://semver.org/): MAJOR.MINOR.PATCH(MAJOR = incompatible change, MINOR = new feature, PATCH = bug fix).+## 1.40.0 – 2026-11-23+- **Android app** (new, folder `android/`): MirrorSync as an app on the phone. A thin wrapper around the web+ interface without browser bar, so every new feature is in the app right away. The APK is attached to each+ GitHub release (`mirrorsync-1.40.0.apk`).+ - On first start enter the server address (checked via `/health`), change it later via the back button,+ the error screen or a long press on the app icon.+ - Login, 2FA and "Stay signed in" work as in the browser; **passkeys** work in the app as well (see below).+ - **Notifications** about failed runs (optionally also successful/cancelled ones) with copied/deleted/errors;+ a tap opens the log. The app checks in the background every 15 minutes to 6 hours, using its login or an+ optional API key.+ - Downloads (logs, audit CSV, backup export) land in the Downloads folder, file upload for backup import works.+ - Light/dark design follows the web interface, plain HTTP in the home network and self-signed certificates+ (after a confirmation) are possible.+- Server: new public endpoint `/.well-known/assetlinks.json` (Digital Asset Links), so Android lets the app use+ the passkeys of your domain. Passkey sign-in accepts the app's origin in addition to the HTTPS address.+ Self-built APKs with an own signing key: add its SHA-256 fingerprint via `MIRRORSYNC_ANDROID_CERTS`.+- GitHub Actions: new workflow `android.yml` builds the APK; "Image and release" attaches it to the release+ (signed when the secrets `ANDROID_KEYSTORE_B64` and `ANDROID_KEYSTORE_PASSWORD` are set).+## 1.39.0 – 2026-11-23- **Delete old logs** as its own section under Settings → General: pick a date, "Show count" shows how many runsin how many jobs started before that date, "Delete permanently now" (with confirmation) deletes them once,diff --git a/Dockerfile b/Dockerfileindex b0786fc..a8d4eee 100644--- a/Dockerfile+++ b/Dockerfile@@ -23,7 +23,7 @@ RUN pip uninstall -y pip setuptools wheel >/dev/null 2>&1; \/usr/local/lib/python3*/site-packages/pip* /usr/local/bin/pip*COPY app/ .-ARG VERSION=1.39.0+ARG VERSION=1.40.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 8440d30..710f2a1 100644--- a/README.de.md+++ b/README.de.md@@ -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.39.0` (feste Version),+(für amd64 und arm64, z. B. Raspberry Pi). Tags: `latest` (neueste Version), `1.40.0` (feste Version),`1.34` (neuester Patch dieser Version).### Mit Docker Compose (empfohlen)@@ -733,6 +733,30 @@ Release mit allen Änderungen. Übertragen wird dabei nur die eigene Versionsnum(`update_update_settings`); `/status` enthält `update` mit `interval_minutes`.- Ein anderes Repo (z. B. ein eigener Fork) lässt sich per `UPDATE_REPO=besitzer/repo` einstellen.+## Android-App (seit 1.40.0)+Im GitHub-Repo liegt unter `android/` eine kleine Android-App (ab Android 7): die MirrorSync-Weboberfläche ohne+Browserleiste, mit eigenem Symbol und Benachrichtigungen. Weil sie die normale Weboberfläche zeigt, ist jede neue+MirrorSync-Funktion sofort in der App.++- **Installieren:** `mirrorsync-<version>.apk` aus dem [neuesten Release](https://github.com/DerMilderJoghurt/mirrorsync/releases/latest)+ auf dem Handy laden und öffnen (einmalig „Unbekannte Apps installieren“ für Browser oder Dateimanager erlauben).+ Updates: neuere APK einfach drüber installieren, Einstellungen und Anmeldung bleiben.+- **Erster Start:** die Adresse eingeben, die du auch im Browser nutzt, z. B. `https://sync.example.com` oder+ `http://192.168.1.50:8080`. Später ändern über die Zurück-Taste auf der Startseite, den Fehlerbildschirm oder+ langes Drücken auf das App-Symbol → „Server & Benachrichtigungen“.+- **Passkeys** in der App brauchen wie im Browser HTTPS mit Domainnamen, eine aktuelle „Android System WebView“+ und Google-Play-Dienste. Android prüft `https://<deine Domain>/.well-known/assetlinks.json`, das MirrorSync selbst+ ausliefert. Google holt diese Datei aus dem Internet, sie muss also von außen erreichbar sein (Reverse-Proxy,+ kein Geo-Blocking für diesen Pfad). Im Browser angelegte Passkeys gehen auch in der App und umgekehrt.+ Klappt es nicht, geht Passwort + 2FA immer.+- **Benachrichtigungen:** standardmäßig an für fehlgeschlagene Läufe, wahlweise auch für erfolgreiche und+ abgebrochene. Die App fragt im Hintergrund `GET /api/v1/jobs` ab (alle 15 Min. bis 6 Std., Android verschiebt+ das evtl. etwas). Sie nutzt die Anmeldung der App, beim Anmelden „Angemeldet bleiben“ ankreuzen. Robuster: einen+ API-Key mit einer Rolle eintragen, die Aufgaben sehen darf.+- **Selbst bauen:** `cd android && ./gradlew assembleRelease` (JDK 17, Android SDK). Mit eigenem Schlüssel+ signiert: dessen SHA-256-Fingerabdruck am Server über `MIRRORSYNC_ANDROID_CERTS=AB:CD:…` eintragen, damit+ Passkeys weiter gehen.+## Update auf eine neue Version```bashdocker compose pull && docker compose up -ddiff --git a/README.md b/README.mdindex cc8f0af..81522b3 100644--- a/README.md+++ b/README.md@@ -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.39.0` (fixed version),+(for amd64 and arm64, e.g. Raspberry Pi). Tags: `latest` (newest version), `1.40.0` (fixed version),`1.34` (newest patch of this version).### With Docker Compose (recommended)@@ -713,6 +713,30 @@ release with all changes. Only the installed version number is sent.(`update_update_settings`); `/status` contains `update` with `interval_minutes`.- Another repository (e.g. your own fork) can be set with `UPDATE_REPO=owner/repo`.+## Android app (since 1.40.0)+The folder `android/` contains a small Android app (Android 7 or newer): the MirrorSync web interface without+browser bar, with its own icon and notifications. Because it shows the normal web interface, every new+MirrorSync feature is available in the app immediately.++- **Install:** download `mirrorsync-<version>.apk` from the [latest release](https://github.com/DerMilderJoghurt/mirrorsync/releases/latest)+ on the phone and open it (allow "Install unknown apps" for the browser or file manager once).+ Updates: install the newer APK over the old one, settings and login stay.+- **First start:** enter the address you also use in the browser, e.g. `https://sync.example.com` or+ `http://192.168.1.50:8080`. Change it later via the back button on the start page, the error screen or a long+ press on the app icon → "Server & notifications".+- **Passkeys** in the app need HTTPS with a domain name (as in the browser), a current "Android System WebView"+ and Google Play services. Android checks `https://<your domain>/.well-known/assetlinks.json`, which MirrorSync+ serves by itself. Google fetches this file from the internet, so it has to be reachable from outside (reverse+ proxy, no geo-blocking for this path). Passkeys created in the browser work in the app and vice versa.+ If it does not work, password + 2FA always do.+- **Notifications:** on by default for failed runs, optionally also for successful and cancelled runs. The app+ asks `GET /api/v1/jobs` in the background (every 15 min to 6 h, Android may delay it a bit). It uses the login of+ the app; tick "Stay signed in" when logging in. More robust: enter an API key with a role that may view jobs.+- **Build it yourself:** `cd android && ./gradlew assembleRelease` (JDK 17, Android SDK). The workflow+ `.github/workflows/android.yml` builds it on GitHub. To sign with your own key, set the repository secrets+ `ANDROID_KEYSTORE_B64` (base64 of the `.jks`) and `ANDROID_KEYSTORE_PASSWORD`, and add the key's SHA-256+ fingerprint to the server via `MIRRORSYNC_ANDROID_CERTS=AB:CD:…` so passkeys keep working.+## Updating to a new version```bashdocker compose pull && docker compose up -ddiff --git a/app/VERSION b/app/VERSIONindex 5edffce..32b7211 100644--- a/app/VERSION+++ b/app/VERSION@@ -1 +1 @@-1.39.0+1.40.0diff --git a/app/app.py b/app/app.pyindex 8d9773a..9af4ad8 100644--- a/app/app.py+++ b/app/app.py@@ -1313,6 +1313,8 @@ def auth():br["out"]["denied"] = perm or "scope"return {"ok": False, "error": "Keine Berechtigung"}, 403return None+ if request.path == "/.well-known/assetlinks.json": # oeffentlich: Android prueft damit die App (Passkeys)+ return Noneblocked = _ip_blocked()if blocked:return blocked@@ -1881,6 +1883,12 @@ def favicon():return app.send_static_file("favicon.ico")[email protected]("/.well-known/assetlinks.json")+def android_assetlinks():+ """Digital Asset Links fuer die Android-App (Passkeys in der App)."""+ return flask.Response(json.dumps(passkeys.assetlinks(), indent=2), mimetype="application/json")++@app.get("/health")def health():return {"status": "ok", "version": VERSION}diff --git a/app/passkeys.py b/app/passkeys.pyindex d9fe185..7db66be 100644--- a/app/passkeys.py+++ b/app/passkeys.py@@ -3,8 +3,11 @@Die eigentliche Pruefung macht die Bibliothek py_webauthn. Hier nur: Optionen bauen, Antworten pruefen,gespeicherte Passkeys verwalten. Ein Passkey ist an einen Domainnamen gebunden (RP-ID) und braucht HTTPS(ausser bei localhost)."""+import base64import ipaddressimport json+import os+import reimport secretsimport timefrom urllib.parse import urlparse@@ -19,6 +22,35 @@ except Exception: # Bibliothek fehlt: Passkeys einfach nicht anbietenAVAILABLE = FalseRP_NAME = "MirrorSync"++# Android-App (Huelle um die Web-GUI): Passkeys in der App laufen ueber den Credential Manager von Android.+# Der verlangt, dass die Domain die App per Digital Asset Links freigibt (/.well-known/assetlinks.json),+# und meldet als Origin "android:apk-key-hash:<SHA-256 des Signaturzertifikats>".+ANDROID_PACKAGE = "io.github.dermilderjoghurt.mirrorsync"+ANDROID_CERTS = ["9B:11:08:BB:79:B6:1C:B5:7C:AE:02:E5:67:E0:7B:C6:B9:6E:4D:DF:0F:48:76:E6:98:FE:09:B7:1B:61:F0:6F"]+++def android_certs():+ """Fingerabdruecke der offiziellen APK plus eigene aus MIRRORSYNC_ANDROID_CERTS (Komma-getrennt, selbst gebaute APK)."""+ extra = [c.strip().upper() for c in os.environ.get("MIRRORSYNC_ANDROID_CERTS", "").split(",") if c.strip()]+ out = []+ for c in ANDROID_CERTS + extra:+ h = c.replace(":", "")+ if re.fullmatch(r"[0-9A-F]{64}", h) and h not in [x.replace(":", "") for x in out]:+ out.append(":".join(h[i:i + 2] for i in range(0, 64, 2)))+ return out+++def android_origins():+ return ["android:apk-key-hash:" + base64.urlsafe_b64encode(bytes.fromhex(c.replace(":", ""))).decode().rstrip("=")+ for c in android_certs()]+++def assetlinks():+ """Inhalt von /.well-known/assetlinks.json: erlaubt der App, Passkeys dieser Domain zu nutzen."""+ return [{"relation": ["delegate_permission/common.get_login_creds", "delegate_permission/common.handle_all_urls"],+ "target": {"namespace": "android_app", "package_name": ANDROID_PACKAGE,+ "sha256_cert_fingerprints": android_certs()}}]TIMEOUT_S = 300 # so lange gilt eine Anfrage (Challenge)@@ -50,11 +82,11 @@ def rp_for(host, public_url=""):return None, [], "Adresse unbekannt."try:ipaddress.ip_address(rp_id)- return rp_id, origins, ("Passkeys funktionieren nicht über eine IP-Adresse. Öffne MirrorSync über seinen "+ return rp_id, origins + android_origins(), ("Passkeys funktionieren nicht über eine IP-Adresse. Öffne MirrorSync über seinen ""Domainnamen mit HTTPS, z. B. über deinen Reverse-Proxy.")except ValueError:pass- return rp_id, origins, None+ return rp_id, origins + android_origins(), None # Browser und Android-Appdef registration_options(rp_id, user_name, user_handle, existing):diff --git a/docker-compose.yml b/docker-compose.ymlindex cc7c6f6..ab36e36 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.39.0+ image: ghcr.io/dermilderjoghurt/mirrorsync:latest # or a fixed version, e.g. :1.40.0# Build it yourself instead of pulling (Dockerfile and app/ in the same folder):# build: .container_name: mirrorsync