Skip to content

Commit 9b9ad6f

Browse files
author
Dmytro Voskoboinikov
committed
Merge branch 'MAGETWO-93786' into 2.3-bugfixes-150818
2 parents 484e09c + 50967a5 commit 9b9ad6f

File tree

8 files changed

+146
-9
lines changed

8 files changed

+146
-9
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Paypal\Controller\Transparent;
77

88
use Magento\Framework\App\CsrfAwareActionInterface;
9+
use Magento\Framework\App\Request\InvalidRequestException;
10+
use Magento\Framework\App\RequestInterface;
911
use Magento\Framework\Registry;
1012
use Magento\Framework\App\Action\Context;
1113
use Magento\Framework\View\Result\LayoutFactory;
@@ -17,8 +19,6 @@
1719
use Magento\Paypal\Model\Payflow\Transparent;
1820
use Magento\Sales\Api\PaymentFailuresInterface;
1921
use Magento\Framework\Session\Generic as Session;
20-
use Magento\Framework\App\RequestInterface;
21-
use Magento\Framework\App\Request\InvalidRequestException;
2222

2323
/**
2424
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)

lib/internal/Magento/Framework/App/FrontController.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Exception\NotFoundException;
1414
use Magento\Framework\Message\ManagerInterface as MessageManager;
1515
use Magento\Framework\App\Action\AbstractAction;
16+
use Psr\Log\LoggerInterface;
1617

1718
/**
1819
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -39,24 +40,33 @@ class FrontController implements FrontControllerInterface
3940
*/
4041
private $messages;
4142

43+
/**
44+
* @var LoggerInterface
45+
*/
46+
private $logger;
47+
4248
/**
4349
* @param RouterListInterface $routerList
4450
* @param ResponseInterface $response
4551
* @param RequestValidator|null $requestValidator
4652
* @param MessageManager|null $messageManager
53+
* @param LoggerInterface|null $logger
4754
*/
4855
public function __construct(
4956
RouterListInterface $routerList,
5057
ResponseInterface $response,
5158
?RequestValidator $requestValidator = null,
52-
?MessageManager $messageManager = null
59+
?MessageManager $messageManager = null,
60+
?LoggerInterface $logger = null
5361
) {
5462
$this->_routerList = $routerList;
5563
$this->response = $response;
5664
$this->requestValidator = $requestValidator
5765
?? ObjectManager::getInstance()->get(RequestValidator::class);
5866
$this->messages = $messageManager
5967
?? ObjectManager::getInstance()->get(MessageManager::class);
68+
$this->logger = $logger
69+
?? ObjectManager::getInstance()->get(LoggerInterface::class);
6070
}
6171

6272
/**
@@ -125,6 +135,10 @@ private function processRequest(
125135
}
126136
} catch (InvalidRequestException $exception) {
127137
//Validation failed - processing validation results.
138+
$this->logger->debug(
139+
'Request validation failed for action "'
140+
.get_class($actionInstance) .'"'
141+
);
128142
$result = $exception->getReplaceResult();
129143
if ($messages = $exception->getMessages()) {
130144
foreach ($messages as $message) {

0 commit comments

Comments
 (0)