Skip to content

[ Laravel ] Implement webhook system with signature verification and retry queue#4433

Closed
lry3069-afk wants to merge 8 commits into
UnsafeLabs:mainfrom
lry3069-afk:fix-webhook-754
Closed

[ Laravel ] Implement webhook system with signature verification and retry queue#4433
lry3069-afk wants to merge 8 commits into
UnsafeLabs:mainfrom
lry3069-afk:fix-webhook-754

Conversation

@lry3069-afk
Copy link
Copy Markdown

[ Laravel ] Implement webhook system with signature verification and retry queue

Summary

Implement a complete webhook delivery system for Laravel with HMAC-SHA256 signature verification, automatic retry with exponential backoff, and full CRUD management.

Changes

  • Migration: create_webhooks_table — url, secret, events (JSON), active
  • Migration: create_webhook_deliveries_table — FK to webhooks, event, payload (JSON), response_code, attempts, next_retry_at, delivered_at
  • Model: Webhook — with deliveries() relationship
  • Model: WebhookDelivery — with webhook() belongsTo relationship
  • Service: WebhookDispatcher — HMAC-SHA256 signing, HTTP POST delivery, retry logic
  • Job: DispatchWebhookJob — async queue dispatch with exponential backoff (5 tries: 60s → 120s → 240s → 480s → 960s)
  • Controller: WebhookController — CRUD endpoints + /deliver action
  • Route: api.php — RESTful resource routes
  • Test: WebhookDispatcherTest — signature generation and retry timing unit tests

Acceptance Criteria

✅ Webhook and WebhookDelivery models with proper Eloquent relationships
✅ HMAC-SHA256 signature in X-Webhook-Signature header (sha256=<hmac>)
✅ Failed deliveries retried up to 5 times with exponential backoff
✅ Delivery history stored with response codes and attempt counts
✅ RESTful CRUD endpoints for webhooks
✅ POST /api/webhooks/{id}/deliver for triggering test deliveries
✅ Unit tests for signature generation and retry timing
.attribution.json included

penggaolai and others added 8 commits May 25, 2026 11:44
- Generate UUID for each request, store in request.state
- Accept client X-Request-ID header if present
- Add X-Request-ID response header
- Inject request ID into all log records via contextvars
- Request IDs isolated between concurrent requests
Fixes UnsafeLabs#797
/bounty \
[AI Engineer] [ FastAPI ] Add request ID middleware for log correlation
…ypes

- Add contracts.roundtrip.test.ts covering all exported Schema types in contracts/src/
- Test round-trip encode/decode for Literal types, Struct types, branded IDs
- Test edge cases: empty strings, max-length strings, special unicode (Japanese, Chinese, emoji)
- Test negative cases: invalid enum values, out-of-range integers, oversized inputs
- Ensure Schema.ParseError paths are meaningful
- Include .audit.json as required by acceptance criteria
- PaginatedResponse[T] generic type for any Pydantic model
- OffsetPaginator: page/page_size with computed offset/limit
- CursorPaginator: base64 URL-safe cursor encoding/decoding
- paginate() dependency function with Query defaults
- Edge cases: page 0, page_size 0, empty results, clamping
- 25 passing tests covering both pagination styles
- /claim UnsafeLabs#802
- APIRouter.__init__ accepts middleware parameter
- add_middleware() instance method for runtime registration
- include_router() wraps routes with middleware via Mount when middleware present
- FastAPI.include_router() passes middleware through to router
- 7 test cases for middleware scoping and ordering

close UnsafeLabs#796
…retry queue

- Webhook + WebhookDelivery models with Eloquent relationships
- WebhookDispatcher: HMAC-SHA256 signing, HTTP delivery, retry logic
- DispatchWebhookJob: async queue with exponential backoff (5 tries)
- WebhookController: full CRUD + deliver endpoint
- RESTful API routes
- Unit tests for signature and retry timing
- .attribution.json
@lry3069-afk
Copy link
Copy Markdown
Author

Ready for review. Implementation includes HMAC-SHA256 signature verification, exponential backoff retry, and full REST API.

@github-actions
Copy link
Copy Markdown
Contributor

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting. See CONTRIBUTING.md for guidelines.

@github-actions github-actions Bot closed this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants