Skip to content

Commit

Permalink
Fix signing by amazon
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbeckers committed Nov 26, 2021
1 parent 77726dd commit be752b0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/RequestTransformer/RequestTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MaxBeckers\AmazonAlexaBundle\RequestTransformer;

use MaxBeckers\AmazonAlexa\Exception\MissingRequestDataException;
use MaxBeckers\AmazonAlexa\Request\Request as AlexaRequest;
use MaxBeckers\AmazonAlexa\RequestHandler\RequestHandlerRegistry;
use MaxBeckers\AmazonAlexa\Response\Response;
Expand Down Expand Up @@ -48,12 +49,20 @@ public function __construct(RequestHandlerRegistry $requestHandlerRegistry, Requ
*/
public function transformRequest(Request $request): Response
{
if (!$request->getContent()) {
throw new MissingRequestDataException();
}

$alexaRequest = AlexaRequest::fromAmazonRequest(
$request->getContent(),
$request->server->get('HTTP_SIGNATURECERTCHAINURL', ''),
$request->server->get('HTTP_SIGNATURE', '')
);

if (!$alexaRequest) {
throw new MissingRequestDataException();
}

$this->requestValidator->validate($alexaRequest);
$handler = $this->requestHandlerRegistry->getSupportingHandler($alexaRequest);

Expand Down

0 comments on commit be752b0

Please sign in to comment.