Skip to content

Commit

Permalink
Merge pull request #28 from t3n/johannessteu-patch-1
Browse files Browse the repository at this point in the history
Check for correct endpoint in an options request
  • Loading branch information
johannessteu authored Feb 14, 2020
2 parents 1f4844e + 0e168b8 commit b64c080
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Classes/Controller/GraphQLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class GraphQLController extends ActionController
protected $requestLogger;

/**
* phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification
*
* @Flow\SkipCsrfProtection
*
* @param string $endpoint
* @param string $query
* @param array|null $variables
* @param string|null $operationName
* @param mixed[]|null $variables
*
* @throws \Neos\Flow\Mvc\Exception\NoSuchArgumentException
* @throws InvalidContextException
*
* @phpcsSuppress PEAR.Commenting.FunctionComment.MissingParamTag
*/
public function queryAction(string $endpoint, string $query, ?array $variables = null, ?string $operationName = null): string
{
Expand Down
7 changes: 5 additions & 2 deletions Classes/Http/HttpOptionsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public function handle(ComponentContext $componentContext): void
return;
}

$endpoint = ltrim($httpRequest->getRequestTarget(), '/');
// We explode the request target because custom routes like /some/custom/route/<endpoint> are
// are common. So we double check here if the last part in the route matches a configured
// endpoint
$endpoint = explode('/', ltrim($httpRequest->getRequestTarget(), '\/'));

if (! isset($this->endpoints[$endpoint])) {
if (! isset($this->endpoints[end($endpoint)])) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json.ci
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"neos/flow": "~6.0",
"neos/buildessentials": "~6.0",
"t3n/graphql": "@dev",
"t3n/coding-standard": "~1.0.0"
"t3n/coding-standard": "~1.1.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "~3.5",
Expand Down
7 changes: 6 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
<arg value="nps"/>

<file>Classes</file>
<rule ref="t3n"/>
<rule ref="t3n">
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="PEAR.Commenting.FunctionComment.Missing"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingReturn"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingParamTag"/>
</rule>
</ruleset>

0 comments on commit b64c080

Please sign in to comment.