diff --git a/src/Resources/skeleton/webhook/RequestParser.tpl.php b/src/Resources/skeleton/webhook/RequestParser.tpl.php index 9a60fc972..4102ab7a2 100644 --- a/src/Resources/skeleton/webhook/RequestParser.tpl.php +++ b/src/Resources/skeleton/webhook/RequestParser.tpl.php @@ -26,11 +26,11 @@ protected function getRequestMatcher(): RequestMatcherInterface */ protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent { - // Implement your own logic to validate and parse the request, and return a RemoteEvent object. + // TODO: Adapt or replace the content of this method to fit your need. // Validate the request against $secret. $authToken = $request->headers->get('X-Authentication-Token'); - if (is_null($authToken) || $authToken !== $secret) { + if ($authToken !== $secret) { throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.'); } diff --git a/tests/fixtures/make-webhook/RemoteServiceRequestParser.php b/tests/fixtures/make-webhook/RemoteServiceRequestParser.php index b8da4fd71..a5e927e72 100644 --- a/tests/fixtures/make-webhook/RemoteServiceRequestParser.php +++ b/tests/fixtures/make-webhook/RemoteServiceRequestParser.php @@ -25,12 +25,11 @@ protected function getRequestMatcher(): RequestMatcherInterface */ protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent { - // Implement your own logic to validate and parse the request, and return a RemoteEvent object. + // TODO: Adapt or replace the content of this method to fit your need. // Validate the request against $secret. $authToken = $request->headers->get('X-Authentication-Token'); - - if (null === $authToken || $authToken !== $secret) { + if ($authToken !== $secret) { throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.'); } @@ -41,7 +40,7 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr } // Parse the request payload and return a RemoteEvent object. - $payload = $request->getPayload()->getIterator()->getArrayCopy(); + $payload = $request->getPayload()->all(); return new RemoteEvent( $payload['name'],