fix(restore): generate sanitized authelia test config
This commit is contained in:
@@ -49,13 +49,13 @@ Planned isolation:
|
||||
- Test-Postgres: postgres:18.4 mit Wegwerf-Credentials
|
||||
- Test-Authelia: authelia/authelia:4.39.20 (Image-Pin wie Produktion)
|
||||
- Wegwerf-Secrets ausschliesslich im Test-Compose
|
||||
- configuration.yml wird im Restore-Lab gepatcht:
|
||||
- configuration.restoretest.yml wird im Restore-Lab erzeugt:
|
||||
* storage -> Test-Postgres (kein produktives Postgres erreicht)
|
||||
* notifier -> Filesystem (KEIN SMTP-Versand)
|
||||
* session -> in-memory (kein Redis-Backend noetig)
|
||||
* session -> lokaler Smoke ohne produktive Session-Secrets
|
||||
- Test endpoint: 127.0.0.1:19091/api/health (no Traefik, no public domain)
|
||||
Smoke-Test:
|
||||
- authelia config validate gegen gepatchte configuration.yml
|
||||
- authelia config validate gegen configuration.restoretest.yml
|
||||
- HTTP 200 von /api/health
|
||||
EOF
|
||||
exit 0
|
||||
@@ -110,10 +110,12 @@ if borg_extract "/restore/authelia-extract" "local/borg-dumps/latest/postgresql1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Stufe 3: configuration.yml im Restore-Lab gezielt patchen.
|
||||
# Wir ersetzen storage/notifier/session-Blocks durch Test-Definitionen,
|
||||
# damit der Test KEIN produktives Postgres und KEIN echtes SMTP anspricht.
|
||||
# Stufe 3: configuration.yml im Restore-Lab gezielt fuer den Test sanitizen.
|
||||
# Wir entfernen produktive Top-Level-Bloecke, die im Test andere Backends
|
||||
# brauchen, und haengen danach Test-Definitionen an. So verlassen wir uns
|
||||
# nicht darauf, dass ein Overlay alte Map-Keys wie notifier.smtp loescht.
|
||||
CONFIG_FILE="$RESTORE_ROOT/config/configuration.yml"
|
||||
TEST_CONFIG_FILE="$RESTORE_ROOT/config/configuration.restoretest.yml"
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "configuration.yml missing in restored config dir" >&2
|
||||
exit 1
|
||||
@@ -122,13 +124,20 @@ fi
|
||||
# Sichere Originalkopie fuer Diff/Diagnose
|
||||
cp "$CONFIG_FILE" "$CONFIG_FILE.original"
|
||||
|
||||
# Schreibe Drop-In fuer Test-Backends. Authelia 4.39 laedt mehrere
|
||||
# Configdateien ueber wiederholte --config-Argumente; einfacher fuer Smoke
|
||||
# ist ein gezielter Overlay-File, der Test-Werte vorgibt.
|
||||
cat > "$RESTORE_ROOT/config/configuration.test-overlay.yml" <<'YAML'
|
||||
# Test-Overlay nur fuer Restore-Smoke. Wird als zweite --config-Datei
|
||||
# zusaetzlich zur restaurierten configuration.yml geladen und ueberschreibt
|
||||
# externe Abhaengigkeiten.
|
||||
# Entferne produktive Blocks, die der Restore-Smoke bewusst ersetzt.
|
||||
awk '
|
||||
/^[A-Za-z_][A-Za-z0-9_]*:/ {
|
||||
key = $0
|
||||
sub(/:.*/, "", key)
|
||||
skip = (key == "storage" || key == "notifier" || key == "session" || key == "identity_validation" || key == "jwt_secret")
|
||||
}
|
||||
!skip { print }
|
||||
' "$CONFIG_FILE" > "$TEST_CONFIG_FILE"
|
||||
|
||||
cat >> "$TEST_CONFIG_FILE" <<'YAML'
|
||||
|
||||
# Restore-Smoke-Test-Backends. Produktive externe Abhaengigkeiten sind oben
|
||||
# entfernt und werden hier mit isolierten Test-Werten ersetzt.
|
||||
|
||||
storage:
|
||||
postgres:
|
||||
@@ -146,8 +155,8 @@ session:
|
||||
cookies:
|
||||
- name: authelia_session_restoretest
|
||||
domain: kaleschke.info
|
||||
authelia_url: http://127.0.0.1:19091
|
||||
default_redirection_url: http://127.0.0.1:19091
|
||||
authelia_url: https://auth.kaleschke.info
|
||||
default_redirection_url: https://glance.kaleschke.info
|
||||
expiration: 1h
|
||||
inactivity: 5m
|
||||
|
||||
@@ -192,7 +201,7 @@ if [ "$dump_available" -eq 1 ]; then
|
||||
dump_status="restored"
|
||||
fi
|
||||
|
||||
# Stufe 6: config validate im Container-Kontext, gegen restauriertes + overlay
|
||||
# Stufe 6: config validate im Container-Kontext, gegen sanitizte Test-Config
|
||||
validate_status="ok"
|
||||
if ! docker run --rm \
|
||||
-e AUTHELIA_JWT_SECRET=restoretest-authelia-jwt-secret-placeholder-32bytes \
|
||||
@@ -202,16 +211,15 @@ if ! docker run --rm \
|
||||
-e AUTHELIA_NOTIFIER_SMTP_PASSWORD=restoretest-authelia-smtp-placeholder \
|
||||
-v "$RESTORE_ROOT/config:/config" \
|
||||
authelia/authelia:4.39.20@sha256:1b363e9279e742397966333f364e0876ae02bf5c876de73e83af6d48c57ff51b \
|
||||
authelia config validate --config /config/configuration.yml --config /config/configuration.test-overlay.yml \
|
||||
authelia config validate --config /config/configuration.restoretest.yml \
|
||||
>/tmp/authelia-validate.log 2>&1; then
|
||||
validate_status="failed"
|
||||
cat /tmp/authelia-validate.log >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stufe 7: Authelia-Container starten. Das Compose setzt wiederholte
|
||||
# --config-Argumente, sodass das Test-Overlay zusaetzlich geladen wird; die
|
||||
# zweite Datei gewinnt bei Konflikten und ersetzt storage/notifier/session.
|
||||
# Stufe 7: Authelia-Container starten. Das Compose nutzt die sanitizte
|
||||
# configuration.restoretest.yml mit isolierten Test-Backends.
|
||||
docker compose -f "$COMPOSE_FILE" up -d restoretest-authelia >/dev/null
|
||||
|
||||
http_status=""
|
||||
@@ -248,7 +256,7 @@ write_report "$REPORT_FILE" <<EOF
|
||||
- Borg extract of config: \`ok\`
|
||||
- Borg extract of dump: \`$dump_status\`
|
||||
- configuration.yml present: \`ok\`
|
||||
- Test-overlay (storage/notifier/session) written: \`ok\`
|
||||
- configuration.restoretest.yml written: \`ok\`
|
||||
- \`authelia config validate\`: \`$validate_status\`
|
||||
- HTTP /api/health status: \`$http_status\`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user