You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/webhooks.md
+26-1Lines changed: 26 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -113,13 +113,14 @@ class ShipOrderActivity extends Activity
113
113
```
114
114
115
115
## 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`.
117
117
118
118
### Authentication Methods
119
119
Laravel Workflow supports:
120
120
1. No Authentication (none)
121
121
2. Token-based Authentication (token)
122
122
3. HMAC Signature Verification (signature)
123
+
4. Custom Authentication (custom)
123
124
124
125
### Token Authentication
125
126
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" \
146
147
-d "$BODY"
147
148
```
148
149
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
+
149
174
## Configuring Webhook Routes
150
175
By default, webhooks are accessible under `/webhooks`. You can customize the route path in `config/workflows.php`:
0 commit comments