From fdc5594d69a8a2b60af4d94a7c20dda8c491f0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sat, 22 Nov 2025 22:55:27 +0100 Subject: [PATCH] docs: clarify docker-compose dollar sign escaping for bcrypt hashes --- README.md | 16 +++++++++++++++- docker-compose.example.yml | 2 +- scripts/hash-password.js | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9794cd7..6e82b91 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ Das Projekt ist für den Betrieb mit Docker optimiert. Passe die Umgebungsvariablen in der `docker-compose.yml` an: - `ADMIN_PASSWORD`: Admin-Passwort als Bcrypt-Hash. Erstelle den Hash mit: `node scripts/hash-password.js ` - Standard (admin123): `$2b$10$SHOt9G1qUNIvHoWre7499.eEtp5PtOII0daOQGNV.dhDEuPmOUdsq` + **Wichtig:** In `docker-compose.yml` müssen alle `$` Zeichen im Hash verdoppelt werden (`$$`), damit sie nicht als Variablen interpretiert werden! + Beispiel: `$$2b$$10$$...` - `TZ`: Zeitzone für täglichen Puzzle-Wechsel (Standard: `Europe/Berlin`) - `GOTIFY_URL`: URL deines Gotify Servers (z.B. `https://gotify.example.com`) - `GOTIFY_APP_TOKEN`: App Token für Gotify (z.B. `A...`) @@ -142,6 +143,19 @@ Eine vollständige Beispiel-Konfiguration findest du in `nginx.conf.example`. - `proxy_buffering off;` - Deaktiviert Buffering für große Dateien - `client_max_body_size 50M;` - Erlaubt große Uploads +### Admin Login schlägt fehl (Docker) + +**Problem:** "Wrong password" trotz korrekt generiertem Hash. + +**Ursache:** Docker Compose interpretiert `$` Zeichen im Hash als Variablen. + +**Lösung:** +In der `docker-compose.yml` müssen alle `$` Zeichen im Hash verdoppelt werden (`$$`). +Falsch: `$2b$10$...` +Richtig: `$$2b$$10$$...` + +Das Skript `node scripts/hash-password.js ` gibt nun auch direkt den passenden String für Docker Compose aus. + ## Lizenz MIT diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 2be3e6c..f1ac156 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -10,7 +10,7 @@ services: - "3010:3000" environment: - DATABASE_URL=file:/app/data/prod.db - - ADMIN_PASSWORD=$2b$10$SHOt9G1qUNIvHoWre7499.eEtp5PtOII0daOQGNV.dhDEuPmOUdsq # Change this! Must be a bcrypt hash. Use scripts/hash-password.js to generate. + - ADMIN_PASSWORD=$$2b$$10$$SHOt9G1qUNIvHoWre7499.eEtp5PtOII0daOQGNV.dhDEuPmOUdsq # Change this! Must be a bcrypt hash. Escape $ as $$ in docker-compose! - TZ=Europe/Berlin # Timezone for daily puzzle rotation - GOTIFY_URL=https://gotify.example.com - GOTIFY_APP_TOKEN=your_gotify_token diff --git a/scripts/hash-password.js b/scripts/hash-password.js index dfbfc8f..d025aa6 100644 --- a/scripts/hash-password.js +++ b/scripts/hash-password.js @@ -17,5 +17,8 @@ bcrypt.hash(password, saltRounds, (err, hash) => { } console.log('Plaintext:', password); console.log('Bcrypt Hash:', hash); + console.log('\n⚠️ IMPORTANT FOR DOCKER COMPOSE:'); + console.log('If you use this hash directly in docker-compose.yml, you MUST escape the $ signs:'); + console.log('Docker Hash:', hash.replace(/\$/g, '$$$$')); console.log('\nSet this hash as your ADMIN_PASSWORD environment variable.'); });