fix(sales-chat): derive companyId from session user and enforce role guard on markAsRead
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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分
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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