fix(sales-chat): derive companyId from session user and enforce role guard on markAsRead
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Start with markAsRead in apps/api/src/sales-chat/sales-chat.controller.ts, then trace the corresponding method in apps/api/src/sales-chat/sales-chat.service.ts and how assertConversationAccess checks roles and assignments. Update the controller and service to derive the company from the authenticated user, enforce the specified role and conversation access checks, and verify viewers receive 403 while authorized users can mark permitted conversations as read.
由索引模型根据 Issue 内容生成。
描述
Problem Description
In apps/api/src/sales-chat/sales-chat.controller.ts (markAsRead, lines 129-140):
-
Cross-Tenant IDOR via
x-company-idheader:
markAsReadaccepts@Headers('x-company-id') companyId?: stringand resolvesfinalCompanyId = companyId || (user ? this.getCompanyId(user) : undefined). Any authenticated user can pass another workspace's ID in thex-company-idheader along with aconversationIdto mark another tenant's inbound messages as read. -
Missing
@Roles(...)guard:
markAsReaddoes not enforce@Roles('OWNER', 'ADMIN', 'MAINTAINER'), allowingVIEWERusers to mutate conversation read state.
Expected Behavior
markAsReadmust ignore any client-suppliedx-company-idheader and always derivecompanyIdstrictly from the authenticated user (this.getCompanyId(user)).- Only
OWNER,ADMIN, andMAINTAINERroles (subject toassertConversationAccesswhenrestrictMaintainerToAssignedis enabled) should be allowed to mark conversations as read;VIEWERs should receive403 Forbidden.
Where to Look
apps/api/src/sales-chat/sales-chat.controller.ts(markAsRead)apps/api/src/sales-chat/sales-chat.service.ts(markAsRead)
Solution / Implementation Guide
- In
apps/api/src/sales-chat/sales-chat.controller.ts:- Add
@Roles('OWNER', 'ADMIN', 'MAINTAINER')tomarkAsRead. - Remove
@Headers('x-company-id') companyId?: stringand derivecompanyIdsolely fromthis.getCompanyId(user). - Pass
usertothis.salesChatService.markAsRead(companyId, conversationId, user).
- Add
- In
apps/api/src/sales-chat/sales-chat.service.ts:- Call
await this.assertConversationAccess(companyId, conversationId, user)before updating unread message state so restrictedMAINTAINERs cannot mark unassigned conversations as read.
- Call
- 主要语言
- TypeScript
- 星标
- 2
- 派生
- 1
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 27
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sumamakhan761/tryinstance 的其他 Issue
-
backend good first issue
难度 2/5 1-3 小时 新手友好度 82/100
sumamakhan761/tryinstance#65 ·
维护者通常 1 天内回复
-
backend good first issue
难度 2/5 1-3 小时 新手友好度 84/100
sumamakhan761/tryinstance#64 ·
维护者通常 1 天内回复
-
backend good first issue
难度 1/5 1-3 小时 新手友好度 88/100
sumamakhan761/tryinstance#63 ·
维护者通常 1 天内回复
-
backend good first issue
难度 2/5 1-3 小时 新手友好度 82/100
sumamakhan761/tryinstance#62 ·
维护者通常 1 天内回复
-
backend good first issue
难度 2/5 1-3 小时 新手友好度 82/100
sumamakhan761/tryinstance#60 ·
维护者通常 1 天内回复
查看 sumamakhan761/tryinstance 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 67/100
makecindy/cindy#15342 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 74/100
kwitsch/claude-code-plugin-tooling#219 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
no-repo-link tool-submission
难度 1/5 1 小时以内 新手友好度 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 85/100