M8: Security-Headers, Rate-Limits und Audit-Log
Erste drei Bausteine der Haertung: - Security-Headers (X-Content-Type-Options, X-Frame-Options, Referrer- Policy, Permissions-Policy, HSTS bei HTTPS) laufen automatisch ueber app_send_security_headers() am Ende von app/bootstrap.php fuer jede dynamische Seite; landing.php war als einzige Seite ganz ohne PHP und bekam einen minimalen Bootstrap-Aufruf. Bewusst kein CSP, da die bestehenden Templates durchgaengig auf Inline-style-Attribute setzen. - DB-gestuetzte Rate-Limits (neue Tabelle rate_limit_attempts) fuer Login (10/15min je E-Mail, 20/15min je IP), Registrierung (5/h je IP) und Passwort-Reset-Anfrage (5/h je E-Mail, 10/h je IP); bei ausgereiztem Reset-Limit erscheint dieselbe generische Meldung wie im Erfolgsfall, um kein Konto-Enumeration-Signal zu geben. - Zentrales Audit-Log (neue Tabelle audit_log) fuer Mitgliederverwaltung, Zugangsvergabe/-entzug, Storno, Mandant-Einstellungen, Hinweise, CSV-Import, Jahresbonus-Verteilung und Live-Mailversand; sichtbar fuer Owner/Admin auf mandant-einstellungen.php. Live getestet: Rate-Limit greift nach 10 Fehlversuchen, Audit-Log-Eintrag mit korrekten Metadaten und Nutzernamen ueber einen isolierten Test- Mandanten geprueft. Alle Regressionstests weiterhin gruen (26/26 Smoke, 104 Golden-Master-Assertions). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+7
-4
@@ -3,6 +3,7 @@
|
||||
include "functions.php";
|
||||
require_once __DIR__ . "/app/ledger.php";
|
||||
require_once __DIR__ . "/app/notices.php";
|
||||
require_once __DIR__ . "/app/audit.php";
|
||||
app_require_csrf();
|
||||
include "header.php";
|
||||
include "headerline.php";
|
||||
@@ -45,10 +46,12 @@ if($hasAccess){
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$aktion = $_POST['aktion'] ?? 'speichern';
|
||||
|
||||
$actorUserId = $saasUser !== null ? (int)$saasUser['user_id'] : null;
|
||||
|
||||
if ($aktion === 'loeschen') {
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
if ($id > 0) {
|
||||
notices_soft_delete($pdo, $tenantId, $id);
|
||||
if ($id > 0 && notices_soft_delete($pdo, $tenantId, $id)) {
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, 'notice.deleted', 'notice', $id);
|
||||
}
|
||||
} else {
|
||||
$nachricht = $_POST['nachricht'] ?? '';
|
||||
@@ -57,8 +60,8 @@ if($hasAccess){
|
||||
|
||||
if ($dt) {
|
||||
$gueltig_bis_sql = $dt->format('Y-m-d H:i:s'); // z.B. "2025-09-03 14:00:00"
|
||||
$createdByUserId = $saasUser !== null ? (int)$saasUser['user_id'] : null;
|
||||
notices_create($pdo, $tenantId, (string)$nachricht, $gueltig_bis_sql, $createdByUserId);
|
||||
notices_create($pdo, $tenantId, (string)$nachricht, $gueltig_bis_sql, $actorUserId);
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, 'notice.created', 'notice', null, ['valid_until' => $gueltig_bis_sql]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user