Zertifikatsprüfung als Opt-in: pro Site und für SMTP
All checks were successful
CI / PHP Lint (push) Successful in 36s
CI / PHP Lint-1 (push) Successful in 38s
CI / Unit Tests & Static Analysis (push) Successful in 42s
CI / PHP Lint (pull_request) Successful in 36s
CI / PHP Lint-1 (pull_request) Successful in 41s
CI / Unit Tests & Static Analysis (pull_request) Successful in 42s
All checks were successful
CI / PHP Lint (push) Successful in 36s
CI / PHP Lint-1 (push) Successful in 38s
CI / Unit Tests & Static Analysis (push) Successful in 42s
CI / PHP Lint (pull_request) Successful in 36s
CI / PHP Lint-1 (pull_request) Successful in 41s
CI / Unit Tests & Static Analysis (pull_request) Successful in 42s
Übernommen aus dem alten Review-Branch claude/tool-review-optimization-q9nyv5, neu gebaut auf dem aktuellen Stand. Der Rest jenes Branches ist durch das Redesign überholt. Bisher galt CURLOPT_SSL_VERIFYPEER => false für jede Verbindung zum Controller, ohne Möglichkeit, das zu ändern. Wer den Controller unter seinem echten Namen mit gültigem Zertifikat betreibt, kann die Prüfung jetzt pro Site einschalten; Standard bleibt aus, weil UniFi-Geräte ab Werk ein selbst signiertes Zertifikat liefern. - Migration 0008, Spalte sites.ssl_verify (Default 0) - UniFiController: fünfter Konstruktor-Parameter, steuert VERIFYPEER und VERIFYHOST; testConnection() ebenso. Alle acht Aufrufer geben den Wert der Site weiter, tolerant über "?? 0" für Alt-Installationen - Site-Verwaltung: Schalter in beiden Modalen, Abzeichen auf der Karte - Mailer: dasselbe über die Einstellung smtp_verify_ssl, Schalter im SMTP-Tab - Backup nimmt die Spalte mit, Readme erklärt, wann man sie einschaltet - 3 Tests auf den Durchgriff bis cURL (75 Tests, 178 Assertions) Nebenbei: der Aufruf von openEditModal() hat fehlende Spalten bisher als leeres Argument gerendert - jetzt über (int)(... ?? 0) abgesichert. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
78819c0c96
commit
4c1e58e68f
19 changed files with 136 additions and 35 deletions
|
|
@ -32,15 +32,16 @@ if ($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['edit_site'])) {
|
|||
$username = trim($_POST['username']);
|
||||
$password = $_POST['password'];
|
||||
$publicAccess = isset($_POST['public_access']) ? 1 : 0;
|
||||
$sslVerify = isset($_POST['ssl_verify']) ? 1 : 0;
|
||||
if (empty($name)||empty($siteIdStr)||empty($controllerUrl)||empty($username)) throw new Exception(__('error_fill_all'));
|
||||
if (!empty($password)) {
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteIdStr);
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteIdStr,$sslVerify);
|
||||
if ($test !== true) throw new Exception('Verbindung fehlgeschlagen: '.$test);
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,unifi_password=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,Crypto::encrypt($password),$publicAccess,$siteId]);
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,unifi_password=?,ssl_verify=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,Crypto::encrypt($password),$sslVerify,$publicAccess,$siteId]);
|
||||
} else {
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,$publicAccess,$siteId]);
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,ssl_verify=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,$sslVerify,$publicAccess,$siteId]);
|
||||
}
|
||||
$auth->writeAuditLog($_SESSION['user_id'],'site_edit','site',$siteId,"Site {$name} aktualisiert");
|
||||
$success = __('sites_updated');
|
||||
|
|
@ -60,11 +61,12 @@ if ($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['add_site'])) {
|
|||
$username = trim($_POST['username']);
|
||||
$password = $_POST['password'];
|
||||
$publicAccess = isset($_POST['public_access']) ? 1 : 0;
|
||||
$sslVerify = isset($_POST['ssl_verify']) ? 1 : 0;
|
||||
if (empty($name)||empty($siteId)||empty($controllerUrl)||empty($username)) throw new Exception(__('error_fill_all'));
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteId);
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteId,$sslVerify);
|
||||
if ($test !== true) throw new Exception('Verbindung fehlgeschlagen: '.$test);
|
||||
$newId = $db->execute("INSERT INTO sites (name,site_id,unifi_controller_url,unifi_username,unifi_password,public_access) VALUES (?,?,?,?,?,?)",
|
||||
[$name,$siteId,$controllerUrl,$username,Crypto::encrypt($password),$publicAccess]);
|
||||
$newId = $db->execute("INSERT INTO sites (name,site_id,unifi_controller_url,unifi_username,unifi_password,ssl_verify,public_access) VALUES (?,?,?,?,?,?,?)",
|
||||
[$name,$siteId,$controllerUrl,$username,Crypto::encrypt($password),$sslVerify,$publicAccess]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'],'site_create','site',$newId,"Site {$name} erstellt");
|
||||
$success = __('sites_added');
|
||||
} catch (Exception $e) { $error = $e->getMessage(); }
|
||||
|
|
@ -140,6 +142,9 @@ $currentPage = 'sites';
|
|||
<?php if ($site['public_access']): ?>
|
||||
<span class="badge badge-info"><i class="fas fa-globe" aria-hidden="true"></i> <?= __('status_public') ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($site['ssl_verify'])): ?>
|
||||
<span class="badge badge-secondary" title="<?= __('sites_ssl_verify_hint') ?>"><i class="fas fa-lock" aria-hidden="true"></i> <?= __('sites_ssl_badge') ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="site-info">
|
||||
|
|
@ -157,7 +162,7 @@ $currentPage = 'sites';
|
|||
</div>
|
||||
</div>
|
||||
<div class="site-actions">
|
||||
<button onclick="openEditModal(<?= $site['id'] ?>, '<?= htmlspecialchars($site['name'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['site_id'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_controller_url'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_username'], ENT_QUOTES) ?>', <?= $site['public_access'] ?>)"
|
||||
<button onclick="openEditModal(<?= $site['id'] ?>, '<?= htmlspecialchars($site['name'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['site_id'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_controller_url'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_username'], ENT_QUOTES) ?>', <?= (int)($site['public_access'] ?? 0) ?>, <?= (int)($site['ssl_verify'] ?? 0) ?>)"
|
||||
class="btn btn-secondary btn-sm">
|
||||
<i class="fas fa-edit" aria-hidden="true"></i> <?= __('btn_edit') ?>
|
||||
</button>
|
||||
|
|
@ -214,6 +219,11 @@ $currentPage = 'sites';
|
|||
<input type="checkbox" id="add_public" name="public_access">
|
||||
<label for="add_public" style="margin:0;"><?= __('sites_public') ?></label>
|
||||
</div>
|
||||
<div class="form-group checkbox-group">
|
||||
<input type="checkbox" id="add_ssl_verify" name="ssl_verify">
|
||||
<label for="add_ssl_verify" style="margin:0;"><?= __('sites_ssl_verify') ?></label>
|
||||
</div>
|
||||
<p class="help-text"><?= __('sites_ssl_verify_hint') ?></p>
|
||||
<div style="display:flex;gap:10px;margin-top:20px;">
|
||||
<button type="submit" class="btn btn-primary" style="flex:1;" id="addSiteSubmitBtn">
|
||||
<i class="fas fa-save" aria-hidden="true"></i> <?= __('sites_add') ?>
|
||||
|
|
@ -264,6 +274,11 @@ $currentPage = 'sites';
|
|||
<input type="checkbox" id="edit_public_access" name="public_access">
|
||||
<label for="edit_public_access" style="margin:0;"><?= __('sites_public') ?></label>
|
||||
</div>
|
||||
<div class="form-group checkbox-group">
|
||||
<input type="checkbox" id="edit_ssl_verify" name="ssl_verify">
|
||||
<label for="edit_ssl_verify" style="margin:0;"><?= __('sites_ssl_verify') ?></label>
|
||||
</div>
|
||||
<p class="help-text"><?= __('sites_ssl_verify_hint') ?></p>
|
||||
<div style="display:flex;gap:10px;margin-top:20px;">
|
||||
<button type="submit" class="btn btn-primary" style="flex:1;" id="editSiteSubmitBtn">
|
||||
<i class="fas fa-save" aria-hidden="true"></i> <?= __('btn_save') ?>
|
||||
|
|
@ -281,7 +296,7 @@ $currentPage = 'sites';
|
|||
function openModal() { document.getElementById('addSiteModal').classList.add('active'); }
|
||||
function closeModal(id) { document.getElementById(id).classList.remove('active'); }
|
||||
|
||||
function openEditModal(id, name, siteIdStr, controllerUrl, username, publicAccess) {
|
||||
function openEditModal(id, name, siteIdStr, controllerUrl, username, publicAccess, sslVerify) {
|
||||
document.getElementById('edit_site_id').value = id;
|
||||
document.getElementById('edit_name').value = name;
|
||||
document.getElementById('edit_site_id_str').value = siteIdStr;
|
||||
|
|
@ -289,6 +304,7 @@ function openEditModal(id, name, siteIdStr, controllerUrl, username, publicAcces
|
|||
document.getElementById('edit_username').value = username;
|
||||
document.getElementById('edit_password').value = '';
|
||||
document.getElementById('edit_public_access').checked = publicAccess == 1;
|
||||
document.getElementById('edit_ssl_verify').checked = sslVerify == 1;
|
||||
document.getElementById('editSiteModal').classList.add('active');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue