Skip to content

Commit f7dba72

Browse files
committed
Revert "LYNX-319 401 and 403 HTTP response codes for GraphQL API"
This reverts commit 5d0d716.
1 parent f2cc975 commit f7dba72

File tree

8 files changed

+22
-352
lines changed

8 files changed

+22
-352
lines changed

app/code/Magento/CustomerGraphQl/Controller/HttpRequestValidator/AuthorizationRequestValidator.php

-60
This file was deleted.

app/code/Magento/CustomerGraphQl/etc/graphql/di.xml

-7
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,4 @@
214214
<plugin name="merge_order_after_customer_signup"
215215
type="Magento\CustomerGraphQl\Plugin\Model\MergeGuestOrder" />
216216
</type>
217-
<type name="Magento\GraphQl\Controller\HttpRequestProcessor">
218-
<arguments>
219-
<argument name="requestValidators" xsi:type="array">
220-
<item name="authorizationValidator" xsi:type="object">Magento\CustomerGraphQl\Controller\HttpRequestValidator\AuthorizationRequestValidator</item>
221-
</argument>
222-
</arguments>
223-
</type>
224217
</config>

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

+2-32
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Magento\Framework\App\ResponseInterface;
2020
use Magento\Framework\Controller\Result\JsonFactory;
2121
use Magento\Framework\GraphQl\Exception\ExceptionFormatter;
22-
use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
23-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
2422
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
2523
use Magento\Framework\GraphQl\Query\Fields as QueryFields;
2624
use Magento\Framework\GraphQl\Query\QueryParser;
@@ -187,7 +185,7 @@ public function dispatch(RequestInterface $request): ResponseInterface
187185
$statusCode = 200;
188186
$jsonResult = $this->jsonFactory->create();
189187
$data = [];
190-
$result = ['errors' => []];
188+
$result = null;
191189
$schema = null;
192190
$query = '';
193191

@@ -213,13 +211,6 @@ public function dispatch(RequestInterface $request): ResponseInterface
213211
$data['variables'] ?? []
214212
);
215213
}
216-
$statusCode = $this->getHttpResponseCode($result);
217-
} catch (GraphQlAuthenticationException $error) {
218-
$result['errors'][] = $this->graphQlError->create($error);
219-
$statusCode = 401;
220-
} catch (GraphQlAuthorizationException $error) {
221-
$result['errors'][] = $this->graphQlError->create($error);
222-
$statusCode = 403;
223214
} catch (SyntaxError|GraphQlInputException $error) {
224215
$result = [
225216
'errors' => [FormattedError::createFromException($error)],
@@ -239,35 +230,14 @@ public function dispatch(RequestInterface $request): ResponseInterface
239230
$jsonResult->renderResult($this->httpResponse);
240231

241232
// log information about the query, unless it is an introspection query
242-
if (!str_contains($query, 'IntrospectionQuery')) {
233+
if (strpos($query, 'IntrospectionQuery') === false) {
243234
$queryInformation = $this->logDataHelper->getLogData($request, $data, $schema, $this->httpResponse);
244235
$this->loggerPool->execute($queryInformation);
245236
}
246237

247238
return $this->httpResponse;
248239
}
249240

250-
/**
251-
* Retrieve http response code based on the error categories
252-
*
253-
* @param array $result
254-
* @return int
255-
*/
256-
private function getHttpResponseCode(array $result): int
257-
{
258-
foreach ($result['errors'] ?? [] as $error) {
259-
if (isset($error['extensions']['category'])) {
260-
return match ($error['extensions']['category']) {
261-
GraphQlAuthenticationException::EXCEPTION_CATEGORY => 401,
262-
GraphQlAuthorizationException::EXCEPTION_CATEGORY => 403,
263-
default => 200,
264-
};
265-
}
266-
}
267-
268-
return 200;
269-
}
270-
271241
/**
272242
* Get data from request body or query string
273243
*

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/AuthenticationTest.php

-229
This file was deleted.

0 commit comments

Comments
 (0)