diff --git a/resources/views/email_services/options/mailgun.blade.php b/resources/views/email_services/options/mailgun.blade.php
index 66a990dd..ed763ea9 100644
--- a/resources/views/email_services/options/mailgun.blade.php
+++ b/resources/views/email_services/options/mailgun.blade.php
@@ -1,3 +1,4 @@
+
diff --git a/src/Listeners/Webhooks/HandleMailgunWebhook.php b/src/Listeners/Webhooks/HandleMailgunWebhook.php
index 9044e9da..c698ae44 100644
--- a/src/Listeners/Webhooks/HandleMailgunWebhook.php
+++ b/src/Listeners/Webhooks/HandleMailgunWebhook.php
@@ -181,7 +181,7 @@ private function checkWebhookValidity(string $messageId, array $payload): bool
}
/** @var string|null $signingKey */
- $signingKey = $emailservice->settings['key'] ?? null;
+ $signingKey = $emailservice->settings['webhook_key'] ?? null;
if (!$signingKey) {
return false;
diff --git a/src/Services/Webhooks/Mailgun/WebhookVerifier.php b/src/Services/Webhooks/Mailgun/WebhookVerifier.php
index 8c63eea2..9e783158 100644
--- a/src/Services/Webhooks/Mailgun/WebhookVerifier.php
+++ b/src/Services/Webhooks/Mailgun/WebhookVerifier.php
@@ -14,6 +14,6 @@ public function verify(string $signingKey, string $token, int $timestamp, string
// return false;
// }
- return hash_hmac('sha256', $timestamp . $token, $signingKey) === $signature;
+ return hash_equals(hash_hmac('sha256', $timestamp . $token, $signingKey), $signature);
}
}
diff --git a/tests/Feature/Webhooks/MailgunWebhooksTest.php b/tests/Feature/Webhooks/MailgunWebhooksTest.php
index 77b501c7..45d5f20e 100644
--- a/tests/Feature/Webhooks/MailgunWebhooksTest.php
+++ b/tests/Feature/Webhooks/MailgunWebhooksTest.php
@@ -22,13 +22,13 @@ class MailgunWebhooksTest extends TestCase
protected $route = 'sendportal.api.webhooks.mailgun';
/** @var string */
- protected $apiKey;
+ protected $webHookKey;
public function setUp(): void
{
parent::setUp();
- $this->apiKey = Str::random();
+ $this->webHookKey = Str::random();
}
/** @test */
@@ -172,7 +172,7 @@ protected function createMessage(): Message
$emailService = EmailService::factory()->create([
'type_id' => EmailServiceType::MAILGUN,
'settings' => [
- 'key' => $this->apiKey,
+ 'webhook_key' => $this->webHookKey,
],
]);
@@ -192,7 +192,7 @@ protected function resolveWebhook(string $type, string $messageId): array
$token = Str::random();
- $signature = hash_hmac('sha256', $timestamp . $token, $this->apiKey);
+ $signature = hash_hmac('sha256', $timestamp . $token, $this->webHookKey);
return [
'event-data' => [