Skip to content

Commit 0e60c83

Browse files
committed
AC-1271: Add rate limiting for payment information endpoint and mutation
1 parent 0d1ddc8 commit 0e60c83

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

app/code/Magento/GraphQl/Controller/GraphQl.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
2525
use Magento\Framework\GraphQl\Schema\SchemaGeneratorInterface;
2626
use Magento\Framework\Serialize\SerializerInterface;
27-
use Magento\Framework\Webapi\Exception;
2827
use Magento\Framework\Webapi\Response;
2928
use Magento\GraphQl\Helper\Query\Logger\LogData;
30-
use Magento\GraphQl\Model\Backpressure\GraphQlTooManyRequestsException;
3129
use Magento\GraphQl\Model\Query\ContextFactoryInterface;
3230
use Magento\GraphQl\Model\Query\Logger\LoggerPool;
3331

@@ -196,19 +194,6 @@ public function dispatch(RequestInterface $request): ResponseInterface
196194
$this->contextFactory->create(),
197195
$data['variables'] ?? []
198196
);
199-
200-
if (isset($result['errors']) && is_array($result['errors'])) {
201-
foreach ($result['errors'] as $error) {
202-
if (isset($error['extensions']) && is_array($error['extensions'])) {
203-
foreach ($error['extensions'] as $key => $value) {
204-
if (GraphQlTooManyRequestsException::EXCEPTION_CATEGORY === $value
205-
&& 'category' === $key) {
206-
$statusCode = Exception::HTTP_TOO_MANY_REQUESTS;
207-
}
208-
}
209-
}
210-
}
211-
}
212197
} catch (\Exception $error) {
213198
$result['errors'] = isset($result['errors']) ? $result['errors'] : [];
214199
$result['errors'][] = $this->graphQlError->create($error);

app/code/Magento/GraphQl/Model/Backpressure/BackpressureFieldValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public function __construct(
4141
}
4242

4343
/**
44+
* Validate resolver args
45+
*
4446
* @param Field $field
45-
* @param $args
47+
* @param array $args
4648
* @return void
4749
* @throws GraphQlTooManyRequestsException
4850
*/

app/code/Magento/GraphQl/Model/Backpressure/GraphQlTooManyRequestsException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
class GraphQlTooManyRequestsException extends LocalizedException implements ClientAware
1919
{
20-
const EXCEPTION_CATEGORY = 'graphql-too-many-requests';
20+
public const EXCEPTION_CATEGORY = 'graphql-too-many-requests';
2121

2222
/**
2323
* @var boolean
@@ -27,10 +27,10 @@ class GraphQlTooManyRequestsException extends LocalizedException implements Clie
2727
/**
2828
* @param Phrase $phrase
2929
* @param Exception|null $cause
30-
* @param $code
31-
* @param $isSafe
30+
* @param int $code
31+
* @param bool $isSafe
3232
*/
33-
public function __construct(Phrase $phrase, Exception $cause = null, $code = 0, $isSafe = true)
33+
public function __construct(Phrase $phrase, Exception $cause = null, int $code = 0, bool $isSafe = true)
3434
{
3535
$this->isSafe = $isSafe;
3636
parent::__construct($phrase, $cause, $code);

0 commit comments

Comments
 (0)