Add role/permission-based authorization for bulk-delete Brains endpoint (DELETE /web/brains/deleteall)#151
Open
SinghCod3r wants to merge 1 commit into
Conversation
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.
Description Summary • Implements fine-grained authorization on the DELETE /web/brains/deleteall endpoint to prevent accidental or unauthorized mass deletion of Brains. • Allows only COMPANY or MANAGER roles (or any role mapped to the descriptor brain.delete_all) to invoke the operation.
Key Changes
Route security • Added checkPermission middleware to nodejs/src/routes/web/brains.js. • Attached descriptor 'brain.delete_all' for RBAC mapping.
Controller defense-in-depth • Added a secondary role check (COMPANY or MANAGER) inside deleteAllBrain in nodejs/src/controller/web/brainController.js to ensure only privileged roles can execute, even if route registration is altered.
Commit message feat: add role/permission-based authorization for bulk delete brains endpoint ([Enhancement]: Example Feature Using Template #62)Benefits • Guards a destructive operation with least-privilege access. • Aligns with the project’s existing descriptor-based RBAC pattern. • Provides layered defense: route-level middleware + controller-level verification.
Testing • Verified that authorized roles receive 200 OK and data deleted as expected. • Verified that unauthorized roles receive 403 Forbidden. • Confirmed descriptor is picked up by existing permission seeder/service.
Closes #62