mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-30 20:02:16 +00:00
Different header access method
This commit is contained in:
@@ -411,7 +411,7 @@ class RecieveForumWebhook(generic.View):
|
|||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
computed = f"sha256={hmac.new(env('FORUM_WEBHOOK_SECRET').encode(), request.body, hashlib.sha256).hexdigest()}"
|
computed = f"sha256={hmac.new(env('FORUM_WEBHOOK_SECRET').encode(), request.body, hashlib.sha256).hexdigest()}"
|
||||||
print(computed)
|
print(computed)
|
||||||
if not hmac.compare_digest(request.POST.get('X-Discourse-Event-Signature'), computed):
|
if not hmac.compare_digest(request.headers.get('X-Discourse-Event-Signature'), computed):
|
||||||
return HttpResponseForbidden('Invalid signature header')
|
return HttpResponseForbidden('Invalid signature header')
|
||||||
body = json.loads(request.body.decode('utf-8'))
|
body = json.loads(request.body.decode('utf-8'))
|
||||||
event_id = int(body['title'][1:5]) # find the ID, force convert it to an int to eliminate leading zeros
|
event_id = int(body['title'][1:5]) # find the ID, force convert it to an int to eliminate leading zeros
|
||||||
|
|||||||
Reference in New Issue
Block a user