fix(credentials): workspace admin users get 'member' role on credential_member instead of 'admin'

Đang mở
#4,698 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #5431 của @tsushanth — đã đóng, không merge

Đá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
42/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
api, authorization, backend

Hướng nghiên cứu

Start with ensureWorkspaceCredentialMemberships in apps/sim/lib/credentials/environment.ts and the POST handler in apps/sim/app/api/credentials/route.ts; trace how workspace permissions are read and how credential_member roles are assigned. Reproduce the owner, admin, write, and read cases, then verify that owner and admin users receive admin while write and read users receive member.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Description

When a workspace-scoped secret is created (via Settings > Secrets or syncWorkspaceEnvCredentials), the credential_member role is determined solely by whether the user is the workspace owner:

const targetRole = memberUserId === ownerUserId ? 'admin' : 'member'

This means workspace admin users are assigned member role on credential_member, making them unable to edit or delete the secret — even though they have admin access to the workspace.

Affected Code

  1. apps/sim/lib/credentials/environment.ts — ensureWorkspaceCredentialMemberships: only checks ownerUserId, ignores workspace permissions table
  2. apps/sim/app/api/credentials/route.ts — POST handler: same issue, only workspaceRow.ownerId || session.user.id gets admin

Expected Behavior

Credential member role should reflect workspace permissions:

Workspace Permission Credential Role
owner (workspace.ownerId) admin
admin (permissions table) admin
write member
read member

Steps to Reproduce

  1. Create a workspace with multiple members (owner + admin + write/read users)
  2. As the owner, go to Settings > Secrets and create a workspace-scoped secret
  3. Check credential_member table — only the owner has admin role
  4. Log in as a workspace admin user — cannot edit or delete the secret
Ngôn ngữ chính
TypeScript
Star
29.8k
Fork
3.9k
Merge trung bình
1 giờ 44 phút
Pull request đã merge (30 ngày)
841

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của simstudioai/sim

Tất cả issue của simstudioai/sim

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.