mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Fixes #2320: TypeError when dispatching a webhook with a secret key configured
This commit is contained in:
parent
db7148350e
commit
d5239191fe
@ -37,8 +37,12 @@ def process_webhook(webhook, data, model_class, event, timestamp):
|
|||||||
prepared_request = requests.Request(**params).prepare()
|
prepared_request = requests.Request(**params).prepare()
|
||||||
|
|
||||||
if webhook.secret != '':
|
if webhook.secret != '':
|
||||||
# sign the request with the secret
|
# Sign the request with a hash of the secret key and its content.
|
||||||
hmac_prep = hmac.new(bytearray(webhook.secret, 'utf8'), prepared_request.body, digestmod=hashlib.sha512)
|
hmac_prep = hmac.new(
|
||||||
|
key=webhook.secret.encode('utf8'),
|
||||||
|
msg=prepared_request.body.encode('utf8'),
|
||||||
|
digestmod=hashlib.sha512
|
||||||
|
)
|
||||||
prepared_request.headers['X-Hook-Signature'] = hmac_prep.hexdigest()
|
prepared_request.headers['X-Hook-Signature'] = hmac_prep.hexdigest()
|
||||||
|
|
||||||
with requests.Session() as session:
|
with requests.Session() as session:
|
||||||
|
Loading…
Reference in New Issue
Block a user