Skip to content

Commit acccc1a

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-93786: Payment APIs webhooks are now expecting a form key
1 parent 54d065a commit acccc1a

File tree

7 files changed

+150
-7
lines changed

7 files changed

+150
-7
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
use Magento\Authorizenet\Model\Directpost;
1111
use Magento\Authorizenet\Model\DirectpostFactory;
1212
use Magento\Framework\App\Action\Context;
13+
use Magento\Framework\App\CsrfAwareActionInterface;
14+
use Magento\Framework\App\Request\InvalidRequestException;
15+
use Magento\Framework\App\RequestInterface;
1316
use Magento\Framework\Controller\ResultFactory;
1417
use Magento\Framework\Exception\LocalizedException;
1518
use Magento\Framework\Registry;
1619
use Psr\Log\LoggerInterface;
1720

18-
class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Payment
21+
class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Payment implements CsrfAwareActionInterface
1922
{
2023
/**
2124
* @var LoggerInterface
@@ -48,6 +51,23 @@ public function __construct(
4851
$this->logger = $logger ?: $this->_objectManager->get(LoggerInterface::class);
4952
}
5053

54+
/**
55+
* @inheritDoc
56+
*/
57+
public function createCsrfValidationException(
58+
RequestInterface $request
59+
): ?InvalidRequestException {
60+
return null;
61+
}
62+
63+
/**
64+
* @inheritDoc
65+
*/
66+
public function validateForCsrf(RequestInterface $request): ?bool
67+
{
68+
return true;
69+
}
70+
5171
/**
5272
* Response action.
5373
* Action for Authorize.net SIM Relay Request.

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Response.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@
66
*/
77
namespace Magento\Authorizenet\Controller\Directpost\Payment;
88

9-
class Response extends \Magento\Authorizenet\Controller\Directpost\Payment
9+
use Magento\Framework\App\CsrfAwareActionInterface;
10+
use Magento\Framework\App\Request\InvalidRequestException;
11+
use Magento\Framework\App\RequestInterface;
12+
13+
class Response extends \Magento\Authorizenet\Controller\Directpost\Payment implements CsrfAwareActionInterface
1014
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function createCsrfValidationException(
19+
RequestInterface $request
20+
): ?InvalidRequestException {
21+
return null;
22+
}
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public function validateForCsrf(RequestInterface $request): ?bool
28+
{
29+
return true;
30+
}
31+
1132
/**
1233
* Response action.
1334
* Action for Authorize.net SIM Relay Request.

app/code/Magento/Paypal/Controller/Ipn/Index.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
namespace Magento\Paypal\Controller\Ipn;
99

10+
use Magento\Framework\App\CsrfAwareActionInterface;
11+
use Magento\Framework\App\Request\InvalidRequestException;
12+
use Magento\Framework\App\RequestInterface;
1013
use Magento\Framework\Exception\RemoteServiceUnavailableException;
1114

1215
/**
1316
* Unified IPN controller for all supported PayPal methods
1417
*/
15-
class Index extends \Magento\Framework\App\Action\Action
18+
class Index extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
1619
{
1720
/**
1821
* @var \Psr\Log\LoggerInterface
@@ -39,6 +42,23 @@ public function __construct(
3942
parent::__construct($context);
4043
}
4144

45+
/**
46+
* @inheritDoc
47+
*/
48+
public function createCsrfValidationException(
49+
RequestInterface $request
50+
): ?InvalidRequestException {
51+
return null;
52+
}
53+
54+
/**
55+
* @inheritDoc
56+
*/
57+
public function validateForCsrf(RequestInterface $request): ?bool
58+
{
59+
return true;
60+
}
61+
4262
/**
4363
* Instantiate IPN model and pass IPN request to it
4464
*

app/code/Magento/Paypal/Controller/Payflow/CancelPayment.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@
66
*/
77
namespace Magento\Paypal\Controller\Payflow;
88

9-
class CancelPayment extends \Magento\Paypal\Controller\Payflow
9+
use Magento\Framework\App\CsrfAwareActionInterface;
10+
use Magento\Framework\App\Request\InvalidRequestException;
11+
use Magento\Framework\App\RequestInterface;
12+
13+
class CancelPayment extends \Magento\Paypal\Controller\Payflow implements CsrfAwareActionInterface
1014
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function createCsrfValidationException(
19+
RequestInterface $request
20+
): ?InvalidRequestException {
21+
return null;
22+
}
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public function validateForCsrf(RequestInterface $request): ?bool
28+
{
29+
return true;
30+
}
31+
1132
/**
1233
* When a customer cancel payment from payflow gateway.
1334
*

app/code/Magento/Paypal/Controller/Payflow/ReturnUrl.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
*/
77
namespace Magento\Paypal\Controller\Payflow;
88

9+
use Magento\Framework\App\CsrfAwareActionInterface;
10+
use Magento\Framework\App\Request\InvalidRequestException;
11+
use Magento\Framework\App\RequestInterface;
912
use Magento\Paypal\Controller\Payflow;
1013
use Magento\Paypal\Model\Config;
1114
use Magento\Sales\Model\Order;
1215

13-
class ReturnUrl extends Payflow
16+
class ReturnUrl extends Payflow implements CsrfAwareActionInterface
1417
{
1518
/**
1619
* @var array of allowed order states on frontend
@@ -30,6 +33,23 @@ class ReturnUrl extends Payflow
3033
Config::METHOD_PAYFLOWLINK
3134
];
3235

36+
/**
37+
* @inheritDoc
38+
*/
39+
public function createCsrfValidationException(
40+
RequestInterface $request
41+
): ?InvalidRequestException {
42+
return null;
43+
}
44+
45+
/**
46+
* @inheritDoc
47+
*/
48+
public function validateForCsrf(RequestInterface $request): ?bool
49+
{
50+
return true;
51+
}
52+
3353
/**
3454
* When a customer return to website from payflow gateway.
3555
*

app/code/Magento/Paypal/Controller/Payflow/SilentPost.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@
66
*/
77
namespace Magento\Paypal\Controller\Payflow;
88

9-
class SilentPost extends \Magento\Paypal\Controller\Payflow
9+
use Magento\Framework\App\CsrfAwareActionInterface;
10+
use Magento\Framework\App\Request\InvalidRequestException;
11+
use Magento\Framework\App\RequestInterface;
12+
13+
class SilentPost extends \Magento\Paypal\Controller\Payflow implements CsrfAwareActionInterface
1014
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function createCsrfValidationException(
19+
RequestInterface $request
20+
): ?InvalidRequestException {
21+
return null;
22+
}
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public function validateForCsrf(RequestInterface $request): ?bool
28+
{
29+
return true;
30+
}
31+
1132
/**
1233
* Get response from PayPal by silent post method
1334
*

app/code/Magento/Paypal/Controller/Transparent/Response.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Paypal\Controller\Transparent;
77

8+
use Magento\Framework\App\CsrfAwareActionInterface;
9+
use Magento\Framework\App\Request\InvalidRequestException;
10+
use Magento\Framework\App\RequestInterface;
811
use Magento\Framework\Registry;
912
use Magento\Framework\App\Action\Context;
1013
use Magento\Framework\View\Result\LayoutFactory;
@@ -20,7 +23,7 @@
2023
/**
2124
* Class Response
2225
*/
23-
class Response extends \Magento\Framework\App\Action\Action
26+
class Response extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
2427
{
2528
/**
2629
* Core registry
@@ -91,6 +94,23 @@ public function __construct(
9194
$this->paymentFailures = $paymentFailures ?: $this->_objectManager->get(PaymentFailuresInterface::class);
9295
}
9396

97+
/**
98+
* @inheritDoc
99+
*/
100+
public function createCsrfValidationException(
101+
RequestInterface $request
102+
): ?InvalidRequestException {
103+
return null;
104+
}
105+
106+
/**
107+
* @inheritDoc
108+
*/
109+
public function validateForCsrf(RequestInterface $request): ?bool
110+
{
111+
return true;
112+
}
113+
94114
/**
95115
* @return ResultInterface
96116
*/

0 commit comments

Comments
 (0)