security: fix data loss on container restart due to relative paths
Root cause: .env.example used relative paths (./data/...) which resolve to /app/data/ inside the container instead of the persistent volume at /data/. This caused the database to be recreated on every container restart, resetting the admin password to a new initial value. Fixes: - .env.example: comment out path settings with clear warning about relative paths; Dockerfile already provides correct absolute defaults - auth: add initial_setup_complete flag in settings table as defence-in-depth so EnsureAdmin never re-creates an admin after the initial setup, even if the users table is unexpectedly empty - main: add validateDataPaths() startup check that warns when relative container paths are detected (potential data-loss misconfiguration) - auth_test: extend TestEnsureAdmin to verify the flag prevents admin re-creation after user deletion
This commit is contained in:
+9
-4
@@ -20,10 +20,15 @@ KEYWARDEN_ENCRYPTION_KEY=change-me-encryption-key-32chars
|
||||
KEYWARDEN_LOG_LEVEL=INFO
|
||||
|
||||
# --- Paths (optional, Docker defaults are usually fine) ---
|
||||
KEYWARDEN_DB_PATH=./data/keywarden.db
|
||||
KEYWARDEN_DATA_DIR=./data
|
||||
KEYWARDEN_KEYS_DIR=./data/keys
|
||||
KEYWARDEN_MASTER_DIR=./data/master
|
||||
# IMPORTANT: These paths refer to locations INSIDE the Docker container.
|
||||
# The Dockerfile already sets correct defaults (/data/...). Only override
|
||||
# if you know what you are doing. Do NOT use relative paths (./data/...)
|
||||
# – they resolve to /app/data/ inside the container and bypass the
|
||||
# persistent volume mount at /data, causing DATA LOSS on restart.
|
||||
# KEYWARDEN_DB_PATH=/data/keywarden.db
|
||||
# KEYWARDEN_DATA_DIR=/data
|
||||
# KEYWARDEN_KEYS_DIR=/data/keys
|
||||
# KEYWARDEN_MASTER_DIR=/data/master
|
||||
|
||||
# --- Security / Hardening (optional) ---
|
||||
# Public URL used for email links and cookie config.
|
||||
|
||||
Reference in New Issue
Block a user