Skip to content

Instantly share code, notes, and snippets.

@felixdorn
Created March 21, 2020 13:03
Show Gist options
  • Save felixdorn/c7b37cedfe0d9aba601345460037c148 to your computer and use it in GitHub Desktop.
Save felixdorn/c7b37cedfe0d9aba601345460037c148 to your computer and use it in GitHub Desktop.
<?php
require __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
$payload = file_get_contents('php://input');
$hash = explode(
'=',
array_key_exists('X-Hub-Signature', getallheaders()) ? getallheaders()['X-Hub-Signature'] : "="
)[1];
if ($hash !== hash_hmac('sha1', $payload, 'secret')) {
http_response_code(403);
die(403);
}
@felixdorn
Copy link
Author

This is crap code for a test, but it's the good way to secure a webhook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment