e161c72fc4
- Implemented a secure rendering method for email content using a sandboxed iframe to prevent XSS attacks. - Added thorough HTML sanitization for incoming emails to mitigate potential exploits. - Refactored email body rendering logic to utilize a dedicated function for better readability and maintainability. - Updated Jira widget to fetch and display dashboard data, including assigned issues and team issues, with improved filtering options. - Enhanced the user interface of the Jira widget with a standardized control toolbar for resizing and collapsing widgets. - Introduced inline search functionality within the Jira widget for quick ticket filtering. - Improved error handling and logging for Jira data fetching.
53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Jira Webhook Receiver
|
|
* Ontvangt webhook events van Atlassian Jira Cloud (issue_created, issue_updated, etc.)
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../config/config.php';
|
|
require_once __DIR__ . '/../../config/database.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
// Beveiligingscontrole: Verifieer geheime webhook token indien geconfigureerd in .env
|
|
$configuredSecret = fociz_env('JIRA_WEBHOOK_SECRET', '');
|
|
if (!empty($configuredSecret)) {
|
|
$incomingSecret = $_GET['secret'] ?? ($_SERVER['HTTP_X_ATLASSIAN_WEBHOOK_SECRET'] ?? '');
|
|
if (!hash_equals($configuredSecret, $incomingSecret)) {
|
|
http_response_code(401);
|
|
echo json_encode(['error' => 'Onbevoegde webhook aanroep']);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$rawPayload = file_get_contents('php://input');
|
|
$data = json_decode($rawPayload, true);
|
|
|
|
if (!$data) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'Ongeldige JSON payload']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$db = get_db_connection();
|
|
$event = $data['webhookEvent'] ?? 'jira:unknown';
|
|
$issueKey = $data['issue']['key'] ?? '';
|
|
$summary = $data['issue']['fields']['summary'] ?? '';
|
|
|
|
// Sla event tijdelijk op of invalidate session cache
|
|
error_log("Jira Webhook ontvangen: {$event} voor {$issueKey} - {$summary}");
|
|
|
|
echo json_encode([
|
|
'received' => true,
|
|
'event' => $event,
|
|
'issue_key' => $issueKey,
|
|
'timestamp' => date('Y-m-d H:i:s')
|
|
]);
|
|
exit;
|
|
} catch (Throwable $t) {
|
|
http_response_code(500);
|
|
echo json_encode(['error' => $t->getMessage()]);
|
|
}
|
|
|