Skip to content

feat(webhook): Add Gitea/Forgejo webhook support (rebased from #66895) - #89427

Open
Leowr997 wants to merge 3 commits into
NousResearch:mainfrom
Leowr997:feat/webhook-gitea-forgejo-signature-support
Open

feat(webhook): Add Gitea/Forgejo webhook support (rebased from #66895)#89427
Leowr997 wants to merge 3 commits into
NousResearch:mainfrom
Leowr997:feat/webhook-gitea-forgejo-signature-support

Conversation

@Leowr997

Copy link
Copy Markdown

This is a rebased copy of #66895 (feat(webhook): Add Gitea webhook signature validation support) by MISAKIGA — all code and test work credit goes to them. We simply want this fix merged, as the original PR has been stalled for a month.

Why this PR exists

The author's original commits are cherry-picked verbatim onto current main
(authorship preserved — all three commits are MISAKIGA's), with
conflicts resolved:

  • 715f139cb4 feat(webhook): Add complete Gitea/Forgejo webhook support
  • ac97a43957 test(webhook): Add Gitea signature validation tests
  • d5a2f46493 feat(webhook): Add Gitea webhook signature validation support

What it does

Adds full Gitea/Forgejo webhook support to gateway/platforms/webhook.py (+24 lines):

  • Event-type detection for X-Gitea-Event / X-Forgejo-Event headers
  • Signature validation for X-Gitea-Signature / X-Forgejo-Signature (bare-hex HMAC-SHA256, the format Gitea/Forgejo actually send)

Plus regression tests (+226 lines in tests/gateway/test_webhook_adapter.py).

Verification

  • All 49 tests pass in tests/gateway/test_webhook_adapter.py on this branch (baseline on pristine main: 34 tests pass)
  • No test-suite deletions: diff is purely additive
  • Rebase conflict resolution: only test-file hunk placement (their base was July main); the webhook.py change applied cleanly

Request to maintainers

Either merge this, or — if you'd prefer the original — please ask @MISAKIGA to rebase #66895. We're happy to close this the moment the original lands; we're not trying to displace the author's credit, just get a month-old working fix merged.

Related: #83723, #66895, #18041, #66893

Hermes Agent added 3 commits August 18, 2026 22:57
Gitea sends X-Gitea-Signature header with HMAC-SHA256 hex digest.
This patch adds support for validating Gitea webhook signatures.

Fixes: Gitea webhooks fail with 'Invalid signature' error

Related-to: https://github.com/NousResearch/hermes-agent
- Add _gitea_signature() helper function
- Add test_validate_gitea_signature_valid
- Add test_validate_gitea_signature_invalid
- Add test_validate_gitea_signature_wrong_body_rejected
- Add X-Gitea-Signature to non-ASCII header rejection test
- Add comment explaining X-Hub-Signature-256 fallback for modern Gitea

All 30 signature validation tests pass.

Addresses PR review feedback on NousResearch#66895
This PR now provides full Gitea and Forgejo webhook support:

**Signature Validation:**
- X-Gitea-Signature (HMAC-SHA256 hex, no prefix)
- X-Forgejo-Signature (same format as Gitea)

**Event Type Extraction:**
- X-Gitea-Event header recognition
- X-Forgejo-Event header recognition

**Tests Added:**
- test_validate_gitea_signature_valid/invalid/wrong_body
- test_validate_forgejo_signature_valid/invalid/wrong_body
- test_event_filter_accepts_gitea_event/rejects_non_matching
- test_event_filter_accepts_forgejo_event/rejects_non_matching
- X-Gitea-Signature and X-Forgejo-Signature in non-ASCII test

**Test Results:**
- 33 signature validation tests pass
- 8 event filter tests pass

This supersedes NousResearch#63108 by providing complete implementation
with matching tests (no test/code gaps).

Closes NousResearch#66893
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/webhook Webhook / API server needs-decision Awaiting maintainer decision before any implementation sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 18, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

Clean provider addition: raw-hex HMAC verification for X-Gitea-Signature/X-Forgejo-Signature via timing-safe comparison, correctly positioned after the GitHub branch so modern senders that also emit X-Hub-Signature-256 hit that path first, event-type header recognition wired into filtering, and the test set covers valid/invalid/wrong-body plus non-ASCII-header rejection for every new header.

— reviewer-b (automated review)

No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists platform/webhook Webhook / API server sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants