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:
@@ -4,6 +4,7 @@
|
||||
include "functions.php";
|
||||
require_once __DIR__ . "/app/ledger.php";
|
||||
require_once __DIR__ . "/app/saas-mail.php";
|
||||
require_once __DIR__ . "/app/audit.php";
|
||||
app_require_csrf();
|
||||
include "header.php";
|
||||
include "headerline.php";
|
||||
@@ -43,6 +44,7 @@ if($hasAccess){
|
||||
$fehler = null;
|
||||
$einladungslink = null;
|
||||
$bearbeitenId = null;
|
||||
$actorUserId = $saasUser['user_id'] ?? null;
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$aktion = $_POST["aktion"] ?? '';
|
||||
@@ -59,7 +61,8 @@ if($hasAccess){
|
||||
$fehler = 'Bitte einen Namen und eine gültige E-Mail-Adresse angeben.';
|
||||
} else {
|
||||
try {
|
||||
ledger_create_participant($pdo, $tenantId, $name, $email, $paypalname, $aktiv);
|
||||
$neueId = ledger_create_participant($pdo, $tenantId, $name, $email, $paypalname, $aktiv);
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, 'participant.created', 'participant', $neueId, ['name' => $name, 'email' => $email]);
|
||||
$meldung = 'Mitglied wurde angelegt.';
|
||||
} catch (Throwable $e) {
|
||||
$fehler = 'Das Mitglied konnte nicht angelegt werden (E-Mail eventuell schon vergeben).';
|
||||
@@ -75,6 +78,7 @@ if($hasAccess){
|
||||
if ($name === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$fehler = 'Bitte einen Namen und eine gültige E-Mail-Adresse angeben.';
|
||||
} elseif (ledger_update_participant($pdo, $tenantId, $participantId, $name, $email, $paypalname, $aktiv)) {
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, 'participant.updated', 'participant', $participantId, ['name' => $name, 'email' => $email]);
|
||||
$meldung = 'Mitglied wurde gespeichert.';
|
||||
} else {
|
||||
$fehler = 'Das Mitglied konnte nicht gespeichert werden.';
|
||||
@@ -82,6 +86,7 @@ if($hasAccess){
|
||||
} elseif ($aktion === 'aktivieren' || $aktion === 'deaktivieren') {
|
||||
$participantId = (int)$_POST["mitgliedID"];
|
||||
if (ledger_set_participant_active($pdo, $tenantId, $participantId, $aktion === 'aktivieren')) {
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, $aktion === 'aktivieren' ? 'participant.activated' : 'participant.deactivated', 'participant', $participantId);
|
||||
$meldung = $aktion === 'aktivieren' ? 'Mitglied wurde aktiviert.' : 'Mitglied wurde deaktiviert.';
|
||||
} else {
|
||||
$fehler = 'Der Status konnte nicht geändert werden.';
|
||||
@@ -99,6 +104,7 @@ if($hasAccess){
|
||||
$rolle,
|
||||
$ergebnis['token']
|
||||
);
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, 'participant.access_granted', 'participant', $participantId, ['role' => $rolle]);
|
||||
$meldung = 'Zugang wurde gewährt, Einladung wurde verschickt.';
|
||||
if (saas_should_show_auth_links()) {
|
||||
$einladungslink = saas_app_url('passwort-zuruecksetzen.php?token=' . urlencode($ergebnis['token']));
|
||||
@@ -111,6 +117,7 @@ if($hasAccess){
|
||||
|
||||
$ergebnis = saas_revoke_participant_access($pdo, $tenantId, $participantId);
|
||||
if ($ergebnis['ok']) {
|
||||
app_audit_log($pdo, $tenantId, $actorUserId, 'participant.access_revoked', 'participant', $participantId);
|
||||
$meldung = 'Zugang wurde entzogen.';
|
||||
} else {
|
||||
$fehler = implode(' ', $ergebnis['errors']);
|
||||
|
||||
Reference in New Issue
Block a user