Skip to content

Commit b696c3f

Browse files
authored
Update webhooks.md
1 parent 5934eb4 commit b696c3f

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

docs/features/webhooks.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ class ShipOrderActivity extends Activity
113113
```
114114

115115
## Webhook Authentication
116-
By default, webhooks don't require authentication but this can be configured in `config/workflows.php`.
116+
By default, webhooks don't require authentication, but you can configure one of several strategies in `config/workflows.php`.
117117

118118
### Authentication Methods
119119
Laravel Workflow supports:
120120
1. No Authentication (none)
121121
2. Token-based Authentication (token)
122122
3. HMAC Signature Verification (signature)
123+
4. Custom Authentication (custom)
123124

124125
### Token Authentication
125126
For token authentication, webhooks require a valid API token in the request headers. The default header is `Authorization` but you can change this in the configuration settings.
@@ -146,6 +147,30 @@ curl -X POST "https://example.com/webhooks/start/order-workflow" \
146147
-d "$BODY"
147148
```
148149

150+
### Custom Authentication
151+
To use a custom authenticator, create a class that implements the following interface:
152+
153+
```php
154+
use Illuminate\Http\Request;
155+
156+
interface WebhookAuthenticator {
157+
public function validate(Request $request): Request;
158+
}
159+
```
160+
161+
Then configure it in `config/workflows.php`:
162+
163+
```php
164+
'webhook_auth' => [
165+
'method' => 'custom',
166+
'custom' => [
167+
'class' => App\Your\CustomAuthenticator::class,
168+
],
169+
],
170+
```
171+
172+
The `validate()` method should return the `Request` if valid, or call `abort(401)` if unauthorized.
173+
149174
## Configuring Webhook Routes
150175
By default, webhooks are accessible under `/webhooks`. You can customize the route path in `config/workflows.php`:
151176

0 commit comments

Comments
 (0)