Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend InvalidWebhookSignatureEvent with WebhookConfig parameter #214

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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