fix(contract-drift): MCP read-only scope, shared-note writes, event TZ
Drift-audit Group 5 (high-severity contract drift): - MCP read-only keys could call every write tool: the Bearer resolver discarded api_key.scope and dispatch had no gate. Add resolve_bearer() (returns user_id + scope) and a scope gate in the /mcp ASGI wrapper that buffers the JSON-RPC body and rejects tools/call for any tool outside a read all-list when scope=='read' (default-deny for unknown/new tools). - Shared project notes/tasks panel was empty for non-owners: get_project_notes_route now queries notes/milestones with the project OWNER's uid (mirrors the already-fixed milestones route). - Shared editors couldn't save/delete shared NOTES (tasks worked): the three notes write routes now resolve via get_note_for_user, gate on can_write_note, and write as the owner — matching the tasks routes. - Event timezone drift: naive datetimes from the MCP date+time split are now localized to the user's tz at a single canonical service point (create_event /update_event), so MCP- and UI-created events agree. tz-aware inputs (REST/CalDAV) pass through untouched. - create_note validates status/priority (TaskStatus/TaskPriority), closing the MCP create_task path that let out-of-enum values persist (no DB CHECK). Tests cover resolve_bearer scope + the write-tool classifier. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,6 +116,9 @@ async def get_project_notes_route(project_id: int):
|
||||
if result is None:
|
||||
return not_found("Project")
|
||||
project, _ = result
|
||||
# Use the project owner's uid so the ownership filter on notes/milestones
|
||||
# matches for shared collaborators (who'd otherwise see an empty panel).
|
||||
owner_uid = project.user_id or uid
|
||||
|
||||
# type filter: "note", "task", or None (both)
|
||||
type_filter = request.args.get("type")
|
||||
@@ -128,11 +131,11 @@ async def get_project_notes_route(project_id: int):
|
||||
elif type_filter == "note":
|
||||
is_task = False
|
||||
|
||||
ms_list = await list_milestones(uid, project_id)
|
||||
ms_list = await list_milestones(owner_uid, project_id)
|
||||
milestone_ids = [m.id for m in ms_list]
|
||||
|
||||
notes, total = await list_notes(
|
||||
uid,
|
||||
owner_uid,
|
||||
is_task=is_task,
|
||||
status=status_filter,
|
||||
project_id=project_id,
|
||||
|
||||
Reference in New Issue
Block a user