Beispiel #1
0
 /**
  * @param mixed[] $headers
  * @param string  $body
  */
 public function handle(array $headers, $body)
 {
     if (!$this->firewall->authorize($headers, $body)) {
         throw new BadRequestHttpException('The request signature is not valid.');
     }
     if (!is_array($payload = json_decode($body, true))) {
         throw new BadRequestHttpException('The request json body cannot be decoded.');
     }
     $this->eventDispatcher->dispatch(WebhookEvents::HOOK, $event = new WebhookEvent($payload));
     foreach ($event->getProcesses() as $process) {
         $this->processProducer->publish($process);
     }
 }
 public function testAuthorizeWithUnsupportedAlgorithm()
 {
     $this->assertFalse($this->firewall->authorize(['X-Hub-Signature' => ['unsupported=52b582138706ac0c597c315cfc1a1bf177408a4d']], '{"foo":"bar"}'));
 }