Skip to content

Add documentation for the Server part of the webhook component #19921

Open
@stof

Description

@stof

The webhook component has 2 parts:

  • the client part, which handles receiving webhooks in a controller (provided in the component) which parses the payload into a RemoteEvent with a request parser (which is the integration point of that component) and then dispatches that RemoteEvent in a messenger message bus
  • the server part, which allows sending webhooks to other systems

The documentation at https://symfony.com/doc/current/webhook.html covers only the client part (and does not really explain the case of custom events rather than the mailer and notifier events, as the section just has a note saying MakerBundle can help you)
This server part is currently totally undocumented.

The server part works by creating a Subscriber (representing the recipient of that webhook, potentially instantiated based on settings stored in an entity for instance) and a RemoteEvent. It can then be sent:

  • when using messenger, this is a matter of publishing a SendWebhookMessage in the bus (the component provides the handler for that message that will call the TransportInterface)
  • otherwise, it is your responsibility to use Symfony\Component\Webhook\Server\TransportInterface to send the event to the subscriber in the place where this is relevant in your architecture.

When sending a webhook, the POST request has the remote event as JSON body and the following headers (by default, as event names are configurable):

  • Webhook-Event with the event name
  • Webhook-Id with the id of the event
  • Webhook-Signature with the signature, generated as a hmac (using sha256 by default) of the concatenation of the event name, event id and body, using the secret of the subscriber. The value of the header provides the algorithm used for the signature (it looks like sha256=...)

Activity

OskarStark

OskarStark commented on May 29, 2024

@OskarStark
Contributor

cc @TimoBakx 🖖😊

javiereguiluz

javiereguiluz commented on Jun 18, 2024

@javiereguiluz
Member

Please, nobody work on this because we'll receive a PR for this soon. Thanks.

Update: this is the PR #19974

added
hasPRA Pull Request has already been submitted for this issue.
on Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @javiereguiluz@stof@OskarStark

        Issue actions

          Add documentation for the Server part of the webhook component · Issue #19921 · symfony/symfony-docs