swh.webhooks.utils module#

swh.webhooks.utils.get_verified_webhook_payload(request_data: bytes | str, request_headers: Dict[str, str], secret: str) Dict[str, Any][source]#

Verify the authenticity of a webhook message and returns JSON payload.

Parameters:
  • request_data – Body of received POST request

  • request_hedaers – Headers of received POST request

Returns:

JSON payload as a dict

Raises:

ValueError – Webhook content verification failed

swh.webhooks.utils.sign_webhook_payload(payload: str, timestamp: datetime, msg_id: str, secret: str) str[source]#

Generate webhook payload signature.

Parameters:
  • payload – JSON representation of payload

  • timestamp – webhook message timestamp

  • msg_id – webhook message identifier

  • secret – key used to sign and verify payload

Returns:

webhook payload signature

swh.webhooks.utils.format_docstring(**substitutions)[source]#