From 1c846d0d2f93d2ac1328365184f3bbb44d9e0768 Mon Sep 17 00:00:00 2001 From: bencroker Date: Fri, 2 Aug 2024 12:35:54 +0200 Subject: [PATCH] Log IP address in failed Postmark webhook requests --- CHANGELOG.md | 6 ++++++ composer.json | 2 +- src/controllers/WebhookController.php | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e82bfcaa..d3f0747f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes for Campaign +## 2.17.2 - 2024-08-02 + +### Changed + +- IP addresses are now logged in failed webhook requests from Postmark. + ## 2.17.1 - 2024-07-15 ### Changed diff --git a/composer.json b/composer.json index 0f010a92..ef8821ba 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "putyourlightson/craft-campaign", "description": "Send and manage email campaigns, contacts and mailing lists.", - "version": "2.17.1", + "version": "2.17.2", "type": "craft-plugin", "homepage": "https://putyourlightson.com/plugins/campaign", "license": "proprietary", diff --git a/src/controllers/WebhookController.php b/src/controllers/WebhookController.php index bd9210a9..81c20a51 100755 --- a/src/controllers/WebhookController.php +++ b/src/controllers/WebhookController.php @@ -269,8 +269,11 @@ public function actionPostmark(): ?Response // https://postmarkapp.com/support/article/800-ips-for-firewalls#webhooks $allowedIpAddresses = Campaign::$plugin->settings->postmarkAllowedIpAddresses; - if ($allowedIpAddresses && !in_array($this->request->getRemoteIP(), $allowedIpAddresses)) { - return $this->asRawFailure('IP address not allowed.'); + if ($allowedIpAddresses !== null) { + $ipAddress = $this->request->getRemoteIP(); + if (!in_array($ipAddress, $allowedIpAddresses)) { + return $this->asRawFailure(Craft::t('campaign', 'IP address not allowed. [{ipAddress}]', ['ipAddress' => $ipAddress])); + } } $eventType = $this->request->getBodyParam('RecordType');