Skip to content

Require admin role for metrics#4279

Open
laughlife wants to merge 1 commit into
SecureBananaLabs:mainfrom
laughlife:fix/admin-metrics-role-guard
Open

Require admin role for metrics#4279
laughlife wants to merge 1 commit into
SecureBananaLabs:mainfrom
laughlife:fix/admin-metrics-role-guard

Conversation

@laughlife

Copy link
Copy Markdown

/claim #743

Summary

  • Fixes Admin metrics should require admin role #4278 by requiring the authenticated user to have role: "admin" before serving /api/admin/metrics.
  • Adds focused API tests that prove non-admin tokens receive 403 Forbidden while admin tokens still receive the metrics payload.
  • Updates the API test script to run *.test.js files explicitly so the standard workspace test command works in the current Node runner.

Verification

  • Red test before the fix: node --test apps/api/src/tests/admin.test.js failed because a client token received 200 instead of 403.
  • After the fix: npm run test -w apps/api passes.
  • git diff --check passes.

Demo

The automated tests exercise the protected endpoint end to end by starting the Express app, calling /api/admin/metrics with client and admin JWTs, and asserting the expected HTTP responses.

github-actions Bot added a commit that referenced this pull request Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin metrics should require admin role

1 participant