Three more mutating routes were ungated:
- POST /shared-agents/disabled — sets the "disabled by me" preference
for a shared agent. Despite the "by me" naming this writes a
tenant-level row (tenant_disabled_shared_agents) that hides the
agent from every member of the tenant's chat dropdown. So a Viewer
could silently nuke an agent for the entire tenant. Now Admin+
only.
- POST /knowledge-bases/:id/shares — sharing a KB to an organization
exposes its content to every member of that org. The service layer
only checked "is this KB inside the caller's tenant", so any Viewer
could share any tenant KB. Gate matches the KB-update matrix:
OwnedKBOrAdmin (creator OR Admin+).
- POST /agents/:id/shares — same problem, same fix:
OwnedAgentOrAdmin. PUT /shares/:share_id and DELETE /shares/:share_id
for both KB and agent share routes get the same matrix — changing
permission or revoking a share is at least as sensitive as
creating one.
GET /knowledge-bases/:id/shares and GET /agents/:id/shares stay
Viewer+ since they're read-only.
The /organizations/* routes are intentionally left unchanged: they
implement organization-level RBAC (org owner / admin / editor /
viewer) inside the service layer, which is a different matrix from
tenant RBAC and not in scope for this PR.