fix(sales-chat): derive companyId from session user and enforce role guard on markAsRead
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- authentication, backend, security
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 2
- Fork
- 1
- Merge trung bình
- 6 phút
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sumamakhan761/tryinstance
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sumamakhan761/tryinstance#65 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
sumamakhan761/tryinstance#64 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
sumamakhan761/tryinstance#63 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sumamakhan761/tryinstance#62 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sumamakhan761/tryinstance#60 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của sumamakhan761/tryinstance
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
makecindy/cindy#15342 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
kwitsch/claude-code-plugin-tooling#219 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
no-repo-link tool-submission
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100