From 233647be4a289970b0d6ef3a87ee391d7a7e72b3 Mon Sep 17 00:00:00 2001 From: Vibe Nuage Agent Date: Thu, 4 Jun 2026 12:27:10 +0000 Subject: [PATCH] fix: Remove plain text password from code, use sessionStorage for security - Remove hardcoded Nextcloud credentials from app.js - Remove pre-filled password from HTML form - Store password in sessionStorage (cleared on browser close) instead of localStorage - Store only URL, username, and path in localStorage - Update README with security notes - Update quick start guide to reflect manual password entry - Add autocomplete attribute to password field Security improvement: Password is now only stored temporarily in sessionStorage and must be entered manually by the user on first use or after browser restart. Generated by Vibe Code Co-authored-by: trevor1969 --- README.md | 33 +++++++++++++++--------- app.js | 73 +++++++++++++++++++++--------------------------------- index.html | 6 ++--- 3 files changed, 52 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 39cb126..245c236 100644 --- a/README.md +++ b/README.md @@ -115,19 +115,18 @@ ### Option 3: Mit Nextcloud-Synchronisation (empfohlen!) 1. **App öffnen** (lokal oder über GitHub Pages) -2. **Automatische Verbindung**: Die App testet automatisch die Verbindung zu deiner Nextcloud -3. **Fertig!** 🎉 Deine Daten werden jetzt automatisch synchronisiert +2. Gehe zum Tab **⚙️ Einstellungen** +3. Aktiviere **Nextcloud-Synchronisation** +4. Trage deine Nextcloud-Daten ein: + - **URL**: `https://wralto.org/nextcloud3` + - **Benutzername**: `teetracker` + - **App-Passwort**: (dein App-Passwort aus Nextcloud) + - **Speicherpfad**: `/TeeTracker/` (Standard) +5. Klicke auf **🔍 Verbindung testen** +6. Speichere die Konfiguration mit **💾 Speichern** +7. **Fertig!** 🎉 Deine Daten werden jetzt automatisch synchronisiert -**Oder manuell einrichten:** -1. Gehe zum Tab **⚙️ Einstellungen** -2. Aktiviere **Nextcloud-Synchronisation** -3. Trage deine Nextcloud-Daten ein: - - **URL**: `https://wralto.org/nextcloud3` (vorbefüllt) - - **Benutzername**: `teetracker` (vorbefüllt) - - **App-Passwort**: `ruebennasenhausen!2026` (vorbefüllt) - - **Speicherpfad**: `/TeeTracker/` (vorbefüllt) -4. Klicke auf **🔍 Verbindung testen** -5. Speichere die Konfiguration mit **💾 Speichern** +**Hinweis:** Aus Sicherheitsgründen musst du dein Passwort manuell eingeben. Es wird nicht in der App gespeichert (nur temporär in sessionStorage). --- @@ -185,6 +184,14 @@ Falls Nextcloud nicht erreichbar ist: 2. Änderungen werden **lokal gespeichert** 3. Beim nächsten erfolgreichen Verbindungsaufbau werden die Daten **automatisch synchronisiert** +### 🔐 Sicherheitshinweise + +**WICHTIG:** Aus Sicherheitsgründen wird dein Passwort **NICHT** im Klartext in der App oder im localStorage gespeichert! + +- **sessionStorage**: Das Passwort wird nur in `sessionStorage` gespeichert (wird beim Schließen des Browsers gelöscht) +- **Keine Vorbefüllung**: Du musst dein Passwort manuell eingeben +- **Kein Klartext in Dateien**: Das Passwort erscheint nirgends im Code + ### App-Passwort erstellen Falls du ein neues Passwort brauchst: @@ -194,6 +201,8 @@ Falls du ein neues Passwort brauchst: 4. Erstelle ein neues Passwort mit dem Namen **"TeeTracker"** 5. Kopiere das Passwort und trage es in den Einstellungen ein +**Tipp:** Speichere das App-Passwort in einem Passwort-Manager, da es nach dem Erstellen nicht mehr angezeigt wird. + --- ## 🎨 Design diff --git a/app.js b/app.js index d494f3d..0b8b781 100644 --- a/app.js +++ b/app.js @@ -200,57 +200,35 @@ class TeeTracker { initStorage() { // Load Nextcloud configuration from localStorage const ncConfig = localStorage.getItem(STORAGE_KEY_NC_CONFIG); + const ncPassword = sessionStorage.getItem(STORAGE_KEY_NC_CONFIG + '_password'); + if (ncConfig) { try { const config = JSON.parse(ncConfig); - this.nextcloudStorage = new NextcloudStorage( - config.baseUrl, - config.username, - config.password, - config.path || '/TeeTracker/' - ); - this.useNextcloud = true; - this.updateSyncStatus(); + // Load password from sessionStorage (more secure than localStorage) + const password = ncPassword || ''; + + if (password) { + this.nextcloudStorage = new NextcloudStorage( + config.baseUrl, + config.username, + password, + config.path || '/TeeTracker/' + ); + this.useNextcloud = true; + this.updateSyncStatus(); + } else { + // Password not available, user needs to re-enter it + this.useNextcloud = false; + this.showStatusMessage('Bitte gib dein Nextcloud-Passwort erneut ein.', 'info'); + } } catch (error) { console.error('Invalid Nextcloud config:', error); this.useNextcloud = false; } } else { - // Check if we have predefined Nextcloud credentials - const predefinedConfig = { - baseUrl: 'https://wralto.org/nextcloud3', - username: 'teetracker', - password: 'ruebennasenhausen!2026', - path: '/TeeTracker/' - }; - - // Test the predefined connection - this.nextcloudStorage = new NextcloudStorage( - predefinedConfig.baseUrl, - predefinedConfig.username, - predefinedConfig.password, - predefinedConfig.path - ); - - // Test connection asynchronously - this.nextcloudStorage.testConnection().then(connected => { - if (connected) { - this.useNextcloud = true; - localStorage.setItem(STORAGE_KEY_NC_CONFIG, JSON.stringify(predefinedConfig)); - this.updateSyncStatus(); - // Reload data from Nextcloud - this.loadData().then(() => { - this.renderAll(); - this.updateSettingsStats(); - }); - } else { - this.useNextcloud = false; - this.updateSyncStatus(); - } - }).catch(() => { - this.useNextcloud = false; - this.updateSyncStatus(); - }); + // Don't pre-fill credentials - user must enter them manually + this.useNextcloud = false; } } @@ -800,10 +778,14 @@ class TeeTracker { return; } - // Save config - const config = { baseUrl: url, username, password, path }; + // Save config WITHOUT password for security + // Password will be requested each time or stored in sessionStorage + const config = { baseUrl: url, username, path }; localStorage.setItem(STORAGE_KEY_NC_CONFIG, JSON.stringify(config)); + // Store password in sessionStorage (cleared when browser closes) + sessionStorage.setItem(STORAGE_KEY_NC_CONFIG + '_password', password); + // Update app state this.nextcloudStorage = ncStorage; this.useNextcloud = true; @@ -815,6 +797,7 @@ class TeeTracker { } else { // Disable Nextcloud localStorage.removeItem(STORAGE_KEY_NC_CONFIG); + sessionStorage.removeItem(STORAGE_KEY_NC_CONFIG + '_password'); this.useNextcloud = false; this.nextcloudStorage = null; this.showStatusMessage('✅ Nextcloud-Synchronisation deaktiviert. Daten werden lokal gespeichert.', 'success'); diff --git a/index.html b/index.html index 7d0a35c..d476b33 100644 --- a/index.html +++ b/index.html @@ -137,17 +137,17 @@