Skip to content

Commit 31112be

Browse files
committed
Webhook fix + documentation fix
1 parent b309832 commit 31112be

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

api.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Request body:
6767
}
6868

6969
To validate the signature, take the request body as-is (before parsing the json), calculate its SHA-256 hash,
70-
and then compare that hash to the decrypted hash from the X-Signature request header (base64-decode then decrypt
70+
and then compare that hash to the decrypted hash from the X-Webhook-Signature request header (base64-decode then decrypt
7171
using the known public key using ed25519). If any of the following is true, the endpoint should reject the webhook
7272
and take no action:
7373
1. Decrypted signature does not match calculated signature
@@ -78,4 +78,4 @@ and take no action:
7878
The endpoint should return HTTP 200 OK if the webhook is successful and a 4xx or 5xx error code otherwise.
7979
An optional response body may be sent, but it is currently ignored
8080
This software does not currently examine or do anything about the error or response body, but that may change
81-
in the future.
81+
in the future.

webhook.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def send_newpaste(url: str) -> None:
3838
"nonce": secrets.token_hex(),
3939
"date": datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")}
4040
json_data = json.dumps(data)
41-
digest.update(json_data)
41+
digest.update(json_data.encode("utf-8"))
4242
sig = base64.b64encode(key.sign(digest.finalize()))
4343
headers = {"Content-Type": "application/json; charset=utf-8",
4444
"X-Webhook-Version": "1.0.0",

0 commit comments

Comments
 (0)