Skip to content

fix(api): include required scope in API key 403 error messages - #528

Open
Ayomide3271 wants to merge 1 commit into
Ignition-World:mainfrom
Ayomide3271:fix/440-scope-error-messages
Open

fix(api): include required scope in API key 403 error messages#528
Ayomide3271 wants to merge 1 commit into
Ignition-World:mainfrom
Ayomide3271:fix/440-scope-error-messages

Conversation

@Ayomide3271

Copy link
Copy Markdown

Description

Closes #440

The ApiKeyScopeGuard 403 responses were opaque — they did not indicate which scope was required. Specifically, when a request reached a @RequireScope(...) route without an attached API key scope, the guard returned a generic 403 ("API key scope information is missing") that named no required scope at all.

This change makes every 403 raised by API key scope enforcement identify the required scope:

  • Missing scope: API key is missing a scope. Required: write.
  • Insufficient scope: API key scope 'read' is insufficient. Required: write.

Changes

  • ignition-api/src/api-keys/api-key-scope.guard.ts — the missing-scope error now includes the required scope(s); the insufficient-scope error shares the same message builder.
  • ignition-api/src/api-keys/api-key-scope.guard.spec.ts — added regression tests asserting the 403 message names the required scope in both the missing-user and missing-scope cases.

Testing

  • ApiKeyScopeGuard unit tests: 10/10 pass
  • ESLint on changed files: clean (0 errors, 0 warnings)

PR Checklist

  • Code follows project coding standards
  • Tests added/updated for new behavior
  • All existing tests pass
  • Lint checks pass
  • Documentation updated (if applicable) — no user-facing docs required for an error-message fix
  • Changeset added (for packages with versioned releases) — not applicable to this change

Make ApiKeyScopeGuard 403 responses indicate which scope was required.
The missing-scope path previously returned an opaque message, and the
insufficient-scope path now shares a consistent message builder.
Fixes Ignition-World#440
@drips-wave

drips-wave Bot commented Aug 24, 2026

Copy link
Copy Markdown

@Ayomide3271 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

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.

[P2] require-scope.decorator.ts errors are opaque

1 participant