Härtung: Backup vollständig, Caddy-Konfiguration, POST statt GET
All checks were successful
CI / PHP Lint (pull_request) Successful in 35s
CI / PHP Lint-1 (pull_request) Successful in 34s
CI / Unit Tests & Static Analysis (pull_request) Successful in 38s
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 32s
CI / Unit Tests & Static Analysis (push) Successful in 36s
All checks were successful
CI / PHP Lint (pull_request) Successful in 35s
CI / PHP Lint-1 (pull_request) Successful in 34s
CI / Unit Tests & Static Analysis (pull_request) Successful in 38s
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 32s
CI / Unit Tests & Static Analysis (push) Successful in 36s
Backup (das war eine echte Lücke): admin/backup.php sicherte nur Einstellungen, Sites und Profile – die Display-Seiten fehlten. Nach einem Restore wären alle Kiosk-Links weg gewesen und aufgehängte QR-Codes hätten ins Leere gezeigt. Sie werden jetzt mitgesichert, inklusive Token, damit vorhandene Aufkleber weiter funktionieren; Site und Profil werden über den Namen verknüpft, weil die IDs auf der Zielinstallation andere sind. Caddy: die mitgelieferte .htaccess wird von Caddy nicht gelesen – damit griffen weder die Sicherheits-Header noch die Sperre, die PHP unterhalb von uploads/ verbietet. docs/Caddyfile.example enthält beides, die README verweist darauf. Verändernde Aktionen laufen jetzt über POST statt über Links mit CSRF-Token in der URL (Sites, Benutzer, Profile, API-Schlüssel, Display- Seiten). Token in URLs landen in Server-Logs, Referer-Headern und der Browser-Chronik. Neuer Helfer Ui::actionForm() hält das Markup kurz. Entfernt: login_simple.php und m365_debug.php. login_simple.php war eine zweite Login-Implementierung, die den Rückgabewert von Auth::login() als Boolean behandelte – 'totp_required' und 'rate_limited' sind truthy, also wurde auf index.php weitergeleitet, ohne dass eine Sitzung bestand. Kein Bypass (setUserSession lief nicht), aber genau die Art Altlast, aus der später einer wird. Database::getInstance() bricht nicht mehr mit die() samt PDO-Meldung ab (die Host und Datenbanknamen enthält), sondern zeigt im Web eine schlichte 503-Seite und wirft auf der Kommandozeile weiter. Neu: Warnung im Tab "Integration & Wartung", wenn eine Anfrage über einen Proxy kam, aber kein vertrauenswürdiger Proxy eingetragen ist – dann sehen Rate-Limit und Audit-Log für alle Gäste dieselbe IP. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3a09e35097
commit
f26684b128
27 changed files with 381 additions and 423 deletions
|
|
@ -42,17 +42,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_key'])) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['toggle']) && isset($_GET['token']) && $auth->validateCsrfToken($_GET['token'])) {
|
||||
$row = $db->fetchOne("SELECT is_active FROM api_keys WHERE id = ?", [(int)$_GET['toggle']]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['toggle_key']) && $auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$row = $db->fetchOne("SELECT is_active FROM api_keys WHERE id = ?", [(int)($_POST['key_id'] ?? 0)]);
|
||||
if ($row) {
|
||||
$db->query("UPDATE api_keys SET is_active = ? WHERE id = ?", [$row['is_active'] ? 0 : 1, (int)$_GET['toggle']]);
|
||||
$db->query("UPDATE api_keys SET is_active = ? WHERE id = ?", [$row['is_active'] ? 0 : 1, (int)($_POST['key_id'] ?? 0)]);
|
||||
$success = __('api_status_updated');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['delete']) && isset($_GET['token']) && $auth->validateCsrfToken($_GET['token'])) {
|
||||
$db->query("DELETE FROM api_keys WHERE id = ?", [(int)$_GET['delete']]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'api_key_delete', 'api_key', (int)$_GET['delete'], 'API-Key gelöscht');
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_key']) && $auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$db->query("DELETE FROM api_keys WHERE id = ?", [(int)($_POST['key_id'] ?? 0)]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'api_key_delete', 'api_key', (int)($_POST['key_id'] ?? 0), 'API-Key gelöscht');
|
||||
$success = __('api_deleted');
|
||||
}
|
||||
|
||||
|
|
@ -127,8 +127,12 @@ $adminBase = '';
|
|||
<td class="muted" data-label="<?= __('api_col_last_used') ?>"><?= $k['last_used_at'] ? date('d.m.Y H:i', strtotime($k['last_used_at'])) : '–' ?></td>
|
||||
<td class="muted" data-label="<?= __('api_col_created_by') ?>"><?= htmlspecialchars($k['creator'] ?? '–') ?></td>
|
||||
<td style="text-align:right;white-space:nowrap;">
|
||||
<a class="a-link" href="?toggle=<?= (int)$k['id'] ?>&token=<?= urlencode($csrf) ?>"><?= $k['is_active'] ? __('api_action_block') : __('api_action_unblock') ?></a>
|
||||
<a class="a-link" style="color:var(--danger);" href="?delete=<?= (int)$k['id'] ?>&token=<?= urlencode($csrf) ?>" onclick="return confirm('<?= __('api_delete_confirm') ?>');"><?= __('btn_delete') ?></a>
|
||||
<?= Ui::actionForm('toggle_key', ['key_id' => (int)$k['id']], $csrf,
|
||||
htmlspecialchars($k['is_active'] ? __('api_action_block') : __('api_action_unblock')),
|
||||
'btn btn-secondary btn-sm') ?>
|
||||
<?= Ui::actionForm('delete_key', ['key_id' => (int)$k['id']], $csrf,
|
||||
htmlspecialchars(__('btn_delete')),
|
||||
'btn btn-danger-soft btn-sm', __('api_delete_confirm')) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue