Files
Wallos/endpoints/admin/savesecuritysettings.php
Jonathan Rehm de59c1e6c6 add SSRF_ALLOWLIST environment variable (#1123)
By allowing this to be set via environment variable, we are one step
closer to OIDC being available immediately on initial start-up.
2026-07-18 19:41:11 +02:00

45 lines
1.3 KiB
PHP

<?php
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint_admin.php';
require_once '../../includes/ssrf_helper.php';
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);
if (!isset($data['local_webhook_notifications_allowlist'])) {
echo json_encode([
"success" => false,
"message" => translate('error', $i18n)
]);
die();
}
if (wallos_get_effective_ssrf_allowlist($db)['is_managed']) {
echo json_encode([
"success" => false,
"message" => translate('ssrf_allowlist_env_managed', $i18n)
]);
die();
}
// Basic cleanup: trim whitespace and strip any accidental HTML tags
$allowlist = trim(strip_tags($data['local_webhook_notifications_allowlist']));
// Update the admin table (assuming id 1 is the primary settings row, as in your reference)
$sql = "UPDATE admin SET local_webhook_notifications_allowlist = :allowlist WHERE id = 1";
$stmt = $db->prepare($sql);
$stmt->bindParam(':allowlist', $allowlist, SQLITE3_TEXT);
$result = $stmt->execute();
if ($result) {
echo json_encode([
"success" => true,
"message" => translate('success', $i18n)
]);
} else {
echo json_encode([
"success" => false,
"message" => translate('error', $i18n)
]);
}