Skip to content

fix(webhooks): wire API key scope enforcement for webhook routes - #1756

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
abimbolaalabi:fix/api-key-scope-enforcement
Aug 27, 2026
Merged

fix(webhooks): wire API key scope enforcement for webhook routes#1756
Olowodarey merged 1 commit into
Arena1X:mainfrom
abimbolaalabi:fix/api-key-scope-enforcement

Conversation

@abimbolaalabi

Copy link
Copy Markdown
Contributor

Overview

This PR fixes per-endpoint API Key Scope Enforcement for the webhook routes. The ApiKeyGuard (which validates the presented X-API-Key and rejects requests whose key lacks a required route scope with 403) was never wired into the webhooks module, so a limited key could bypass scope checks on webhooks endpoints.

Related Issue

Closes #1639

Changes

  • [MODIFY] \�ackend/src/webhooks/webhooks.module.ts\
    • Import \AuthModule\ so \ApiKeyService\ (a dependency of \ApiKeyGuard) is resolvable in the webhooks module context.
    • Register \ApiKeyGuard\ as a provider so the guard used by \WebhooksController\ can be instantiated by Nest DI.
  • [ADD] \�ackend/src/webhooks/webhooks.module.spec.ts\
    • Route-level integration tests through the real \ApiKeyGuard:
      • in-scope key (\webhooks:write) is allowed;
      • out-of-scope key (only \markets:read) is rejected with \403\ and the missing scope in the response.

Verification Results

\
pnpm run test # 112 suites / 1409 tests passed
pnpm run build # passed
eslint changed files # 0 errors, 0 warnings
\\

Acceptance Criteria

Criteria Status
API keys can only call routes within their scope ✅ enforced by \ApiKeyGuard\ on webhook + public-market routes
Covered by tests ✅ in-scope allowed / out-of-scope rejected (unit + route-level integration)

WebhooksController is guarded by ApiKeyGuard, but WebhooksModule never
imported AuthModule (which exports ApiKeyService) nor registered the
guard as a provider. As a result the guard could not be resolved at
runtime and per-route API-key scope checks were not enforced on the
webhook endpoints.

- Import AuthModule into WebhooksModule
- Register ApiKeyGuard as a provider

Adds route-level integration tests proving an in-scope key is allowed
and an out-of-scope key receives 403 with the missing scope.
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview Aug 27, 2026 4:53pm

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@abimbolaalabi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Olowodarey
Olowodarey merged commit bb186f5 into Arena1X:main Aug 27, 2026
5 checks passed
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.

[Backend] — API Key Scope Enforcement

2 participants