Skip to content

feat(entitlements): add metering auth guard#20728

Open
julianpoy wants to merge 1 commit into
mainfrom
ENT-21
Open

feat(entitlements): add metering auth guard#20728
julianpoy wants to merge 1 commit into
mainfrom
ENT-21

Conversation

@julianpoy

Copy link
Copy Markdown
Member

Because

  • We want a simple NestJS guard to validate incoming requests

This pull request

  • Adds an auth guard

Issue that this pull request solves

Closes ENT-21

@julianpoy julianpoy requested a review from a team as a code owner June 10, 2026 17:54
Copilot AI review requested due to automatic review settings June 10, 2026 17:54
Comment thread libs/entitlements/metering/src/lib/utils/extractBearerToken.ts Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a simple NestJS authentication guard to the entitlements/metering library to validate incoming Authorization: Bearer <token> requests against configured client secrets, and wires the guard/config into the Payments API module for DI.

Changes:

  • Introduces MeteringAuthGuard, a CurrentMeteringClient param decorator, and request attachment helpers.
  • Adds a reusable extractBearerToken utility with unit tests.
  • Exports the new guard/util from @fxa/entitlements/metering and registers guard/config providers in Payments API.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libs/entitlements/metering/src/lib/utils/extractBearerToken.ts Adds bearer-token parsing helper used by the guard.
libs/entitlements/metering/src/lib/utils/extractBearerToken.spec.ts Unit tests for bearer-token parsing behavior.
libs/entitlements/metering/src/lib/metering-auth.guard.ts Adds NestJS guard + request/decorator plumbing for metering client auth.
libs/entitlements/metering/src/lib/metering-auth.guard.spec.ts Unit tests for guard construction and authorization behavior.
libs/entitlements/metering/src/index.ts Exports the new guard and token utility from the package entrypoint.
apps/payments/api/src/app/app.module.ts Registers metering guard/config in the Payments API module providers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/entitlements/metering/src/lib/metering-auth.guard.ts Outdated
Comment thread libs/entitlements/metering/src/lib/utils/extractBearerToken.ts Outdated
Because:

- We want a simple NestJS guard to validate incoming requests

This commit:

- Adds an auth guard

Closes ENT-21
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.

3 participants