mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix(webhooks): compute HMAC signature over undecoded raw URL (#13196)
This commit is contained in:
1 parent
7cb6f311ac
commit
3dae12ab99
1 file changed
+5
-5
@@ -102,10 +102,10 @@ class Webhooks extends Action
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = \rawurldecode($webhook->getAttribute('url'));
|
||||
$rawUrl = $webhook->getAttribute('url');
|
||||
|
||||
if (System::getEnv('_APP_ENV', 'development') === 'production') {
|
||||
$host = \parse_url($url, PHP_URL_HOST) ?? '';
|
||||
$host = \parse_url($rawUrl, PHP_URL_HOST) ?? '';
|
||||
$hostnameValidator = new PublicHostname();
|
||||
if (!$hostnameValidator->isValid($host)) {
|
||||
return 'Webhook target ' . $host . ' rejected: ' . $hostnameValidator->getDescription();
|
||||
@@ -113,10 +113,10 @@ class Webhooks extends Action
|
||||
}
|
||||
|
||||
$signatureKey = $webhook->getAttribute('signatureKey');
|
||||
$signature = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true));
|
||||
$signature = base64_encode(hash_hmac('sha1', $rawUrl . $payload, $signatureKey, true));
|
||||
$httpUser = $webhook->getAttribute('httpUser');
|
||||
$httpPass = $webhook->getAttribute('httpPass');
|
||||
$ch = \curl_init($webhook->getAttribute('url'));
|
||||
$ch = \curl_init($rawUrl);
|
||||
|
||||
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||
\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
@@ -167,7 +167,7 @@ class Webhooks extends Action
|
||||
$attempts = $webhook->getAttribute('attempts');
|
||||
|
||||
$logs = '';
|
||||
$logs .= 'URL: ' . $webhook->getAttribute('url') . "\n";
|
||||
$logs .= 'URL: ' . $rawUrl . "\n";
|
||||
$logs .= 'Method: ' . 'POST' . "\n";
|
||||
|
||||
if (!empty($curlError)) {
|
||||
|
||||
Reference in new issue
Block a user