Fix: secure settings update endpoint with Firebase authentication, ro… - #233
Merged
Premshaw23 merged 5 commits intoMay 21, 2026
Merged
Conversation
…rate limits on registration endpoint Premshaw23#170
…le-based authorization check, and audit logs Premshaw23#172
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. |
…-172 # Conflicts: # components/_tests_/registerRoute.test.js
Premshaw23
approved these changes
May 21, 2026
Owner
|
done👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Description
Secures the
/api/settingsPATCH update endpoint to mitigate IDOR (Insecure Direct Object Reference) vulnerabilities.Previously, unauthenticated clients or regular users could overwrite arbitrary user settings by supplying a target
userId. This change introduces strict authentication, checks settings ownership, implements role-based privilege checks for administrators, and outputs detailed audit trails for every successful modification.Related Issues
Closes #172
Changes Made
app/api/settings/route.jsusingverifyFirebaseToken. Rejected unauthenticated requests early with401 Unauthorized.userIdthat differs from the authenticated user'suid, the operator's Firestore profile is fetched viagetUserProfileto verify if they have an"admin"role. If not, the request returns a403 Forbiddenresponse.components/_tests_/settingsRoute.test.jsvalidating authentication checks, valid self-settings updates, non-admin cross-user rejections (403), admin settings updates, and correct audit log emission.Testing
How did you test these changes?
All Jest unit tests (including the 6 new settings security tests) pass successfully: