Summary
Address the FIXME in backend/api/resources/cell.py (lines 71–74): cell creation should use the authenticated user as the cell owner instead of trusting userEmail from the request body, and the POST /cell/ endpoint should be behind the authenticate decorator.
Current behavior
Cell.post is not in method_decorators; only get, put, and delete use authenticate.
- Cell owner is taken from the request:
userEmail = cell_data["userEmail"] and passed to add_cell_by_user_email(..., userEmail).
- A client can create cells and assign them to any email, which is a security and consistency issue.
Desired behavior
-
Require authentication on POST
- Add
"post": [authenticate] to Cell.method_decorators.
- Change
post(self) to post(self, user) and use user (e.g. user.email) as the cell owner.
-
Set owner from authenticated user
- Do not use
userEmail from the request body for ownership. Derive it from the authenticated user (e.g. user.email).
-
Schema (optional)
- Relax or update
AddCellSchema so userEmail is not required when the user is authenticated (or remove it from the request contract for creation).
Location
- File:
backend/api/resources/cell.py
- Lines: 71–74 (FIXME and related logic in
post)
Acceptance criteria
Summary
Address the FIXME in
backend/api/resources/cell.py(lines 71–74): cell creation should use the authenticated user as the cell owner instead of trustinguserEmailfrom the request body, and thePOST /cell/endpoint should be behind theauthenticatedecorator.Current behavior
Cell.postis not inmethod_decorators; onlyget,put, anddeleteuseauthenticate.userEmail = cell_data["userEmail"]and passed toadd_cell_by_user_email(..., userEmail).Desired behavior
Require authentication on POST
"post": [authenticate]toCell.method_decorators.post(self)topost(self, user)and useuser(e.g.user.email) as the cell owner.Set owner from authenticated user
userEmailfrom the request body for ownership. Derive it from the authenticateduser(e.g.user.email).Schema (optional)
AddCellSchemasouserEmailis not required when the user is authenticated (or remove it from the request contract for creation).Location
backend/api/resources/cell.pypost)Acceptance criteria
POST /cell/requires authentication (same as get/put/delete).user.email), not from request body.userEmailis no longer accepted or required for creation.