Skip to content

Fix: require token authentication, limit payload fields, and rate lim… - #232

Merged
Premshaw23 merged 1 commit into
Premshaw23:masterfrom
omnipotentchaos:feature/labels-auth-171
May 21, 2026
Merged

Fix: require token authentication, limit payload fields, and rate lim…#232
Premshaw23 merged 1 commit into
Premshaw23:masterfrom
omnipotentchaos:feature/labels-auth-171

Conversation

@omnipotentchaos

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • 🐛 Bug fix
  • ✨ New feature
  • 📚 Documentation
  • 🎨 UI/UX improvement
  • ⚡ Performance improvement
  • 🔒 Security fix

Description

Secures the /api/labels endpoint by requiring Firebase ID token authentication, enforcing data projections to prevent PII exposure, and adding rate limiting to block user enumeration attacks.

Related Issues

Closes #171

Changes Made

  • Authentication Check: Added Firebase token decoding on the /api/labels GET route to verify authenticated users. Returns 401 Unauthorized on failure.
  • PII Exposure Protection: Restricted output fields by applying a projection { _id: 0, name: 1, email: 1, image: 1 }, ensuring internal database IDs or metadata are never returned.
  • Enumeration Protection: Implemented client IP rate limiting (10 attempts per minute per IP), responding with 429 Too Many Requests when exceeded.
  • Client hook/component update: Updated useLabels hook to expect the logged-in user and include the Bearer token header in request fetching.
  • New Unit Tests: Created components/_tests_/labelsRoute.test.js checking missing headers, token errors, projection correctness, and rate limit triggers.

Testing

How did you test these changes?

  • Tested locally (Ran npm test - all 48 unit tests passed successfully)
  • Verified local production build compiles successfully via npm run build

Test Suite Output

PASS components/_tests_/labelsRoute.test.js
PASS components/_tests_/AuthForm.test.js
PASS components/_tests_/registerRoute.test.js
PASS components/_tests_/authUtils.test.js
PASS components/_tests_/formValidation.test.js

Test Suites: 5 passed, 5 total

Copilot AI review requested due to automatic review settings May 20, 2026 20:04
@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

@omnipotentchaos is attempting to deploy a commit to the Prem Shaw's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Premshaw23
Premshaw23 merged commit 6f4ab5a into Premshaw23:master May 21, 2026
6 of 9 checks passed
@Premshaw23

Copy link
Copy Markdown
Owner

done👍

@github-actions github-actions Bot added GSSoC'26 Part of GirlScript Summer of Code 2026 mentor:Ayushh-Sharmaa GSSoC: Mentor — @Ayushh-Sharmaa and removed mentor:Premshaw23 labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC'26 Part of GirlScript Summer of Code 2026 level:intermediate mentor:Ayushh-Sharmaa GSSoC: Mentor — @Ayushh-Sharmaa security type:feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SECURITY: Labels endpoint exposes full user list without authentication

3 participants