You are here

public function Webhook::getSignature in Webhooks 8

Get the payload signature from headers.

Return value

string The signature string, e.g. sha1=de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 or sha256=e7835683d84a9bf0e44befd318eaf78ad631a820c4a17a8b916f5f79bed30901

File

src/Webhook.php, line 341

Class

Webhook
Class Webhook .

Namespace

Drupal\webhooks

Code

public function getSignature() {
  $headers = $this
    ->getHeaders();
  $headers = array_change_key_case($headers, CASE_LOWER);

  // Use the more secure SHA256 hash if available.
  if (isset($headers['x-hub-signature-256'])) {
    return $headers['x-hub-signature-256'];
  }
  elseif (isset($headers['x-hub-signature'])) {
    return $headers['x-hub-signature'];
  }
  return '';
}