Skip to content

Commit

Permalink
Extend InvalidWebhookSignatureEvent with WebhookConfig parameter (#214)
Browse files Browse the repository at this point in the history
* Update README.md

* Add config to InvalidWebhookSignatureEvent
  • Loading branch information
jansgescheit authored May 21, 2024
1 parent a21e227 commit 14c7f77
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected $except = [

## Usage

With the installation out of the way, let's take a look at how this package handles webhooks. First, it will verify if the signature of the request is valid. If it is not, we'll throw an exception and fire off the `InvalidSignatureEvent` event. Requests with invalid signatures will not be stored in the database.
With the installation out of the way, let's take a look at how this package handles webhooks. First, it will verify if the signature of the request is valid. If it is not, we'll throw an exception and fire off the `InvalidWebhookSignatureEvent` event. Requests with invalid signatures will not be stored in the database.

Next, the request will be passed to a webhook profile. A webhook profile is a class that determines if a request should be stored and processed by your app. It allows you to filter out webhook requests that are of interest to your app. You can easily create [your own webhook profile](#determining-which-webhook-requests-should-be-stored-and-processed).

Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ class AddColumnsToWebhookCalls extends Migration
- the `Spatie\WebhookClient\Events\InvalidSignature` event has been renamed to `Spatie\WebhookClient\Events\InvalidWebhookSignatureEvent`

- the `Spatie\WebhookClient\ProcessWebhookJob` job has been moved to `Spatie\WebhookClient\Jobs\ProcessWebhookJob`

- the `Spatie\WebhookClient\Events\InvalidWebhookSignatureEvent` event get the `Spatie\WebhookClient\WebhookConfig` as parameter
4 changes: 3 additions & 1 deletion src/Events/InvalidWebhookSignatureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace Spatie\WebhookClient\Events;

use Illuminate\Http\Request;
use Spatie\WebhookClient\WebhookConfig;

class InvalidWebhookSignatureEvent
{
public function __construct(
public Request $request
public Request $request,
public WebhookConfig $config
) {
}
}
2 changes: 1 addition & 1 deletion src/WebhookProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function process(): Response
protected function ensureValidSignature(): self
{
if (! $this->config->signatureValidator->isValid($this->request, $this->config)) {
event(new InvalidWebhookSignatureEvent($this->request));
event(new InvalidWebhookSignatureEvent($this->request, $this->config));

throw InvalidWebhookSignature::make();
}
Expand Down

0 comments on commit 14c7f77

Please sign in to comment.