-
Notifications
You must be signed in to change notification settings - Fork 3.2k
improvement(kb): workspace permissions system reused here #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR implements a comprehensive workspace permissions system for knowledge bases by reusing the existing workspace permissions infrastructure. The changes introduce granular access controls where users need different permission levels for different operations:
- Read access: Required to view knowledge bases and documents
- Write access: Required to create, upload, modify, or delete documents and knowledge bases
- Admin access: Required for advanced operations like workspace-level knowledge base management
The implementation involves several key architectural changes:
-
Provider restructuring: The
WorkspacePermissionsProviderwas moved fromw/components/providers/tocomponents/providers/(one level up) to make it accessible to both workflow and knowledge base components without same-level imports -
Import standardization: All real application files (excluding test files) were updated to use aliased imports (
@/app/workspace/[workspaceId]/components/providers/) instead of relative imports, following established path alias patterns -
Permission enforcement: Knowledge base API routes now use distinct access control functions:
checkKnowledgeBaseAccessfor read operations (GET requests)checkKnowledgeBaseWriteAccessfor write operations (POST, PUT, DELETE requests)- Similar patterns applied to document and chunk operations
-
UI integration: Knowledge base components now disable buttons and show appropriate tooltips when users lack required permissions, maintaining consistent UX patterns with the rest of the application
The system integrates with the existing workspace permissions model where knowledge bases can belong to workspaces and inherit permission structures. Users can access knowledge bases through direct ownership OR through workspace membership with appropriate permission levels. This creates a unified authorization model across workflows, knowledge bases, and other workspace features.
Confidence score: 4/5
- This PR appears safe to merge with proper permission controls implemented throughout the knowledge base system
- The confidence score reflects the comprehensive nature of the changes and proper separation of read/write access controls
- The files that need most attention are the API route handlers (
apps/sim/app/api/knowledge/*/route.ts) and the permissions utility functions (apps/sim/app/api/knowledge/utils.ts) as they contain the core security logic
29 files reviewed, 5 comments
…i#761) * improvement(kb-perms): use workspace perms system for kbs * readd test file * fixed test * address greptile comments * fix button disabling logic * update filter condition for legacy kbs * fix kb selector to respect the workspace scoping * remove testing code * make workspace selection and prevent cascade deletion * make workspace selector pass lint * lint fixed * fix type error
Description
Type of change
How Has This Been Tested?
Screen.Recording.2025-07-23.at.8.08.26.PM.mov
Checklist:
bun run test)Security Considerations: