Construct an ID for Gitlab webhooks

by taking the SHA1 of the body of the webhook request.
This commit is contained in:
Jeff Bradberry 2019-08-29 11:38:24 -04:00
parent 992c414737
commit 8836ed44ce

View File

@ -138,8 +138,10 @@ class GitlabWebhookReceiver(WebhookReceiverBase):
return self.request.META.get('HTTP_X_GITLAB_EVENT')
def get_event_guid(self):
# Gitlab does not provide a unique identifier on events.
return ''
# Gitlab does not provide a unique identifier on events, so construct one.
h = sha1()
h.update(force_bytes(self.request.read()))
return h.hexdigest()
def get_signature(self):
return force_bytes(self.request.META.get('HTTP_X_GITLAB_TOKEN'))