webhooksmith-axum
Axum integration for webhooksmith.
Verifies incoming webhooksmith HMAC-SHA256 signatures in an axum handler with one line. Handles replay protection, constant-time comparison, and body size limiting automatically.
[]
= "0.1"
= "0.7"
= { = "1", = ["full"] }
Setup
Add WebhookSecretLayer to your router, then use VerifiedWebhook or TypedWebhook<T>
in any route handler:
use ;
use ;
use Deserialize;
// Raw payload — verified, body returned as serde_json::Value
async
// Typed payload — verified and deserialized to your struct
async
async
WebhookPayload fields
VerifiedWebhook gives you a WebhookPayload:
Example usage:
async
What gets rejected
| Condition | HTTP status |
|---|---|
Missing x-hooksmith-signature header |
401 Unauthorized |
| Signature does not match | 401 Unauthorized |
| Timestamp older than 5 minutes (replay) | 401 Unauthorized |
| Timestamp more than 5 minutes in the future | 401 Unauthorized |
Missing x-hooksmith-timestamp header |
400 Bad Request |
| Body over 1 MB | 413 Payload Too Large |
| Body is not valid JSON | 422 Unprocessable Entity |
WebhookSecretLayer not on the router |
500 Internal Server Error |
Multiple secrets (secret rotation)
The sender can include multiple space-separated signatures in the header. The extractor accepts the request if any signature matches.
This is useful during secret rotation: old consumers receive the old signature, new consumers receive both. The extractor accepts either.
Admin HTTP router
webhooksmith-axum also ships an admin panel for operational visibility.
Mount it anywhere — no authentication built in, add your own middleware:
use Arc;
use Router;
use WebhookEngine;
use admin;
let app = new
.nest;
| Method | Path | Description |
|---|---|---|
GET |
/admin/stats |
Queue counts (pending, failed, dead, delivered) |
GET |
/admin/endpoints?limit=50&offset=0 |
Endpoints paginated, with circuit breaker state |
GET |
/admin/dlq/:endpoint_id?limit=50&offset=0 |
Dead events for one endpoint |
POST |
/admin/dlq/:endpoint_id/retry-all |
Re-queue dead events + reset circuit breaker |
GET |
/admin/metrics |
Prometheus scrape endpoint (text/plain, version 0.0.4) |
Returns 404 for unknown endpoint IDs. /metrics returns Prometheus text; all others return JSON.
Verifying without axum
If you're not using axum, verify signatures directly:
use signing;
License
MIT OR Apache-2.0