fix(restore): authelia smoke without dump-restore, drop bogus env, disable ntp
Erstlauf 2026-06-03 hat einen by-design-Konflikt offengelegt: pg_restore des
produktiven postgresql17-authelia.dump in eine Test-Instanz mit Wegwerf
AUTHELIA_STORAGE_ENCRYPTION_KEY scheitert im Authelia-Startup-Check mit
"the configured encryption key does not appear to be valid for this database".
Productive Storage-Werte werden mit dem produktiven Key verschluesselt; ein
Wegwerf-Key kann sie nicht entschluesseln. Smoke ist deshalb explizit auf
Config-Restore + Boot reduziert, nicht Daten-Decrypt.
Zwei Nebenbefunde aus demselben Lauf:
- AUTHELIA__SERVER__ADDRESS (Doppel-Underscore) wurde von Authelia 4.39
abgelehnt ("configuration environment variable not expected"). ENV
entfernt; server.address kommt eh aus der generierten configuration.yml.
- ntp-Startup-Check schlug fehl ("Could not determine the clock offset
... lookup time.cloudflare.com on 127.0.0.1:53: server misbehaving"),
weil das isolierte Test-Compose-Netz keinen DNS-Resolver fuer NTP hat.
Neuer Test-Config-Block setzt ntp.disable_startup_check: true.
Doku nachgezogen (Plan + Runbook): Encryption-Key-Konflikt ist explizit
als "nicht Teil dieses Smokes" dokumentiert; Fehler-Matrix hat Eintraege
fuer Doppel-Underscore-ENV und NTP-Lookup.
Frische des produktiven authelia-Dumps wird unveraendert ueber
check-restore-freshness.sh ueberwacht; Daten-Decrypt-Drill ist eine eigene
DR-Aufgabe mit kontrollierter Schluessel-Verwendung.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -4,15 +4,27 @@ set -euo pipefail
|
||||
# Authelia Restore Smoke Test
|
||||
#
|
||||
# Nicht-destruktiver Restore-Smoke-Test fuer Authelia.
|
||||
# - extrahiert die Authelia-Config aus dem produktiven Borg-Archiv
|
||||
# - erzeugt eine minimale Test-Konfiguration, die restaurierte Begleitdateien
|
||||
# wie users_database.yml nutzt, aber produktive externe Abhaengigkeiten
|
||||
# durch Test-Backends ersetzt
|
||||
# - importiert optional den shared-Postgres-Dump fuer Authelia
|
||||
# - validiert die Test-Konfiguration mit `authelia config validate`
|
||||
# - startet einen isolierten Authelia-Container ohne Traefik
|
||||
# - prueft den HTTP-Health-Endpunkt
|
||||
# - bereinigt anschliessend
|
||||
#
|
||||
# Was dieser Smoke nachweist:
|
||||
# - Authelia-Config kann aus dem produktiven Borg-Archiv extrahiert werden
|
||||
# - die restaurierten Begleitdateien (users_database.yml etc.) sind lesbar
|
||||
# - eine minimale Test-Konfiguration, die diese Begleitdateien nutzt und
|
||||
# produktive externe Abhaengigkeiten (Postgres/SMTP) durch Wegwerf-Backends
|
||||
# ersetzt, ist gegen den produktiven Authelia-Image-Pin valide
|
||||
# (`authelia config validate`)
|
||||
# - Authelia startet damit gegen ein frisches Test-Postgres und antwortet
|
||||
# auf `/api/health`
|
||||
#
|
||||
# Was dieser Smoke bewusst NICHT nachweist:
|
||||
# - Daten-Restore des produktiven authelia.dump. Authelia verschluesselt
|
||||
# Storage-Werte mit AUTHELIA_STORAGE_ENCRYPTION_KEY; ein Restore mit
|
||||
# produktiven Daten in eine Test-Instanz mit Wegwerf-Encryption-Key
|
||||
# schlaegt im Startup-Check fehl ("the configured encryption key does
|
||||
# not appear to be valid for this database"). Daten-Decrypt ist eine
|
||||
# eigene DR-Aufgabe mit kontrollierter Schluessel-Verwendung, nicht
|
||||
# Teil dieses Smokes. Frische des Dumps wird ueber
|
||||
# check-restore-freshness.sh ueberwacht.
|
||||
# - vollstaendiger Login-/2FA-/ForwardAuth-Flow.
|
||||
#
|
||||
# Produktive Authelia-Container, produktive Postgres-DB, produktive Secrets
|
||||
# und produktiver SMTP-Versand werden NICHT angefasst.
|
||||
@@ -46,16 +58,23 @@ RestoreRoot: $RESTORE_ROOT
|
||||
ReportRoot: $REPORT_ROOT
|
||||
Expected Borg source paths:
|
||||
- local/appdata/authelia/config
|
||||
- local/borg-dumps/latest/postgresql17-authelia.dump (optional - wird uebersprungen wenn nicht vorhanden)
|
||||
Planned isolation:
|
||||
- Test-Postgres: postgres:18.4 mit Wegwerf-Credentials
|
||||
- Test-Postgres: postgres:18.4 mit Wegwerf-Credentials, FRISCH
|
||||
- Test-Authelia: authelia/authelia:4.39.20 (Image-Pin wie Produktion)
|
||||
- Wegwerf-Secrets ausschliesslich im Test-Compose
|
||||
- test-config/configuration.yml wird im Restore-Lab erzeugt:
|
||||
* storage -> Test-Postgres (kein produktives Postgres erreicht)
|
||||
* notifier -> Filesystem (KEIN SMTP-Versand)
|
||||
* session -> lokaler Smoke ohne produktive Session-Secrets
|
||||
* ntp -> disable_startup_check (kein DNS im isolierten Test-Netz)
|
||||
- Test endpoint: 127.0.0.1:19091/api/health (no Traefik, no public domain)
|
||||
|
||||
Bewusst NICHT Teil dieses Smokes:
|
||||
- pg_restore von postgresql17-authelia.dump. Authelia verschluesselt
|
||||
Storage-Werte mit AUTHELIA_STORAGE_ENCRYPTION_KEY; ein Restore in eine
|
||||
Test-Instanz mit Wegwerf-Key ist by design nicht boot-faehig.
|
||||
Dump-Frische wird via check-restore-freshness.sh ueberwacht.
|
||||
|
||||
Smoke-Test:
|
||||
- authelia config validate gegen test-config/configuration.yml
|
||||
- HTTP 200 von /api/health
|
||||
@@ -84,7 +103,7 @@ cleanup() {
|
||||
trap cleanup EXIT
|
||||
|
||||
rm -rf "$EXTRACT_DIR" "$RESTORE_ROOT"
|
||||
mkdir -p "$RESTORED_CONFIG_DIR" "$TEST_CONFIG_DIR" "$RESTORE_ROOT/postgres" "$RESTORE_ROOT/dumps/latest"
|
||||
mkdir -p "$RESTORED_CONFIG_DIR" "$TEST_CONFIG_DIR" "$RESTORE_ROOT/postgres"
|
||||
|
||||
archive="$(latest_archive_name)"
|
||||
repo="$(borg_repo_url)"
|
||||
@@ -102,17 +121,7 @@ if [ ! -d "$EXTRACT_DIR/local/appdata/authelia/config" ]; then
|
||||
fi
|
||||
cp -a "$EXTRACT_DIR/local/appdata/authelia/config/." "$RESTORED_CONFIG_DIR/"
|
||||
|
||||
# Stufe 2: optionalen Postgres-Dump extrahieren und ggf. einspielen
|
||||
dump_available=0
|
||||
if borg_extract "/restore/authelia-extract" "local/borg-dumps/latest/postgresql17-authelia.dump" 2>/dev/null; then
|
||||
if [ -f "$EXTRACT_DIR/local/borg-dumps/latest/postgresql17-authelia.dump" ]; then
|
||||
mv "$EXTRACT_DIR/local/borg-dumps/latest/postgresql17-authelia.dump" \
|
||||
"$RESTORE_ROOT/dumps/latest/postgresql17-authelia.dump"
|
||||
dump_available=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Stufe 3: Minimale Test-Konfiguration erzeugen.
|
||||
# Stufe 2: Minimale Test-Konfiguration erzeugen.
|
||||
# Die restaurierte Originalkonfig bleibt als Diagnosematerial erhalten. Der
|
||||
# Smoke nutzt bewusst eine neu geschriebene Test-Config, damit keine produktiven
|
||||
# Blocks (SMTP, echtes Postgres, Session/JWT-Altkeys) hineinmergen koennen.
|
||||
@@ -180,6 +189,12 @@ notifier:
|
||||
filesystem:
|
||||
filename: /config/notifier/notifications.txt
|
||||
|
||||
ntp:
|
||||
# Test-Netz hat keinen DNS-Resolver fuer time.cloudflare.com; ohne diesen
|
||||
# Schalter loggt Authelia "Could not determine the clock offset" und der
|
||||
# Startup-Check kann fehlschlagen.
|
||||
disable_startup_check: true
|
||||
|
||||
session:
|
||||
cookies:
|
||||
- name: authelia_session_restoretest
|
||||
@@ -199,38 +214,21 @@ YAML
|
||||
mkdir -p "$TEST_CONFIG_DIR/notifier"
|
||||
chmod -R a+rwX "$TEST_CONFIG_DIR/notifier"
|
||||
|
||||
# Stufe 4: Test-Postgres hochfahren
|
||||
# Stufe 3: Test-Postgres hochfahren (FRISCH, keine Daten aus Dump).
|
||||
# Authelia legt sein Schema beim ersten Start selbst an und schreibt eine
|
||||
# Encryption-Probe mit AUTHELIA_STORAGE_ENCRYPTION_KEY. Ein Restore des
|
||||
# produktiven authelia.dump in diese Instanz wuerde die Encryption-Probe
|
||||
# mit einem anderen Key vorbelegen und Authelia beim Startup-Check
|
||||
# ablehnen lassen ("the configured encryption key does not appear to be
|
||||
# valid for this database"). Genau aus diesem Grund laeuft der Smoke
|
||||
# bewusst auf einer leeren DB. Frische des produktiven Dumps wird
|
||||
# separat in check-restore-freshness.sh ueberwacht.
|
||||
docker compose -f "$COMPOSE_FILE" up -d restoretest-authelia-postgres >/dev/null
|
||||
until docker exec restoretest-authelia-postgres pg_isready -U authelia -d authelia >/dev/null 2>&1; do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Stufe 5: optional Dump einspielen
|
||||
dump_status="skipped (no dump in archive)"
|
||||
if [ "$dump_available" -eq 1 ]; then
|
||||
restore_ok=0
|
||||
for attempt in $(seq 1 12); do
|
||||
if docker exec -i restoretest-authelia-postgres \
|
||||
pg_restore -U authelia -d authelia --clean --if-exists --no-owner --no-privileges \
|
||||
< "$RESTORE_ROOT/dumps/latest/postgresql17-authelia.dump" 2>/tmp/authelia-pg-restore.err; then
|
||||
restore_ok=1
|
||||
break
|
||||
fi
|
||||
if grep -qiE "starting up|shutting down|connection refused|database .* does not exist" /tmp/authelia-pg-restore.err; then
|
||||
sleep 5
|
||||
continue
|
||||
fi
|
||||
cat /tmp/authelia-pg-restore.err >&2
|
||||
exit 1
|
||||
done
|
||||
if [ "$restore_ok" -ne 1 ]; then
|
||||
cat /tmp/authelia-pg-restore.err >&2
|
||||
exit 1
|
||||
fi
|
||||
dump_status="restored"
|
||||
fi
|
||||
|
||||
# Stufe 6: config validate im Container-Kontext, gegen minimale Test-Config
|
||||
# Stufe 4: config validate im Container-Kontext, gegen minimale Test-Config
|
||||
validate_status="ok"
|
||||
if ! docker run --rm \
|
||||
-e AUTHELIA_SESSION_SECRET=restoretest-authelia-session-secret-placeholder-32 \
|
||||
@@ -245,7 +243,7 @@ if ! docker run --rm \
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stufe 7: Authelia-Container starten. Das Compose nutzt test-config als
|
||||
# Stufe 5: Authelia-Container starten. Das Compose nutzt test-config als
|
||||
# /config-Mount mit isolierten Test-Backends.
|
||||
docker compose -f "$COMPOSE_FILE" up -d restoretest-authelia >/dev/null
|
||||
|
||||
@@ -274,27 +272,39 @@ write_report "$REPORT_FILE" <<EOF
|
||||
- Restore root: \`$RESTORE_ROOT\`
|
||||
- Test containers:
|
||||
- \`restoretest-authelia\`
|
||||
- \`restoretest-authelia-postgres\`
|
||||
- \`restoretest-authelia-postgres\` (fresh schema, no productive dump)
|
||||
- Test endpoint: \`http://127.0.0.1:19091/api/health\`
|
||||
- Result: \`SUCCESS\`
|
||||
|
||||
## Checks
|
||||
|
||||
- Borg extract of config: \`ok\`
|
||||
- Borg extract of dump: \`$dump_status\`
|
||||
- configuration.yml present: \`ok\`
|
||||
- configuration.yml present in archive: \`ok\`
|
||||
- test runtime configuration.yml written: \`ok\`
|
||||
- \`authelia config validate\`: \`$validate_status\`
|
||||
- HTTP /api/health status: \`$http_status\`
|
||||
|
||||
## Scope
|
||||
|
||||
Dieser Smoke prueft: Borg-Restore der Config, Validate gegen Produktions-Image,
|
||||
Authelia-Boot gegen frische Test-Postgres + Wegwerf-Encryption-Key,
|
||||
HTTP-Health-Endpoint antwortet.
|
||||
|
||||
Bewusst NICHT Teil des Smokes: pg_restore des produktiven authelia.dump.
|
||||
Authelia verschluesselt Storage-Werte mit \`AUTHELIA_STORAGE_ENCRYPTION_KEY\`;
|
||||
ein Restore mit produktiven Daten in eine Test-Instanz mit Wegwerf-Key
|
||||
schlaegt im Startup-Check by design fehl. Frische des produktiven Dumps
|
||||
wird in \`check-restore-freshness.sh\` ueberwacht; Daten-Decrypt-Drill ist
|
||||
eine separate DR-Aufgabe.
|
||||
|
||||
## Notes
|
||||
|
||||
- Test ran without Traefik and without the productive domain \`auth.kaleschke.info\`.
|
||||
- Productive Authelia secrets under \`/mnt/user/appdata/secrets/authelia_*.txt\` were NOT mounted.
|
||||
- Notifier was forced to filesystem (\`/config/notifier/notifications.txt\`); no SMTP call to GMX.
|
||||
- Storage forced to isolated test postgres; productive shared PostgreSQL 18 was NOT touched.
|
||||
- NTP startup-check disabled in test config (kein DNS-Resolver im isolierten Compose-Netz).
|
||||
- Test data was cleaned after success: \`$([ "$KEEP_DATA" -eq 1 ] && echo no || echo yes)\`
|
||||
- Restore-Quelle Dump: \`local/borg-dumps/latest/postgresql17-authelia.dump\` (optional, wenn im Archiv).
|
||||
EOF
|
||||
|
||||
RESTORE_SUCCESS=1
|
||||
|
||||
Reference in New Issue
Block a user