Skip to content

Add role/permission-based authorization for bulk-delete Brains endpoint (DELETE /web/brains/deleteall)#151

Open
SinghCod3r wants to merge 1 commit into
weam-ai:mainfrom
SinghCod3r:feat/brain-deleteall-authorization
Open

Add role/permission-based authorization for bulk-delete Brains endpoint (DELETE /web/brains/deleteall)#151
SinghCod3r wants to merge 1 commit into
weam-ai:mainfrom
SinghCod3r:feat/brain-deleteall-authorization

Conversation

@SinghCod3r

Copy link
Copy Markdown

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

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.

[Enhancement]: Example Feature Using Template

1 participant