-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: Common user folder permission #4288
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ class FolderView(APIView): | |
| ), | ||
| lambda r, kwargs: ViewPermission([RoleConstants.USER.get_workspace_role()], | ||
| [Permission(group=Group(f"{kwargs.get('source')}_FOLDER"), | ||
| operate=Operate.SELF, | ||
| operate=Operate.EDIT, | ||
| resource_path=f"/WORKSPACE/{kwargs.get('workspace_id')}/{kwargs.get('source')}/{r.data.get('parent_id')}" | ||
| )], CompareConstants.AND), | ||
| RoleConstants.WORKSPACE_MANAGE.get_workspace_role() | ||
|
|
@@ -107,7 +107,7 @@ class Operate(APIView): | |
| ), | ||
| lambda r, kwargs: ViewPermission([RoleConstants.USER.get_workspace_role()], | ||
| [Permission(group=Group(f"{kwargs.get('source')}_FOLDER"), | ||
| operate=Operate.SELF, | ||
| operate=Operate.EDIT, | ||
| resource_path=f"/WORKSPACE/{kwargs.get('workspace_id')}/{kwargs.get('source')}/{kwargs.get('folder_id')}" | ||
| )], CompareConstants.AND), | ||
| RoleConstants.WORKSPACE_MANAGE.get_workspace_role() | ||
|
|
@@ -159,7 +159,7 @@ def get(self, request: Request, workspace_id: str, source: str, folder_id: str): | |
| ), | ||
| lambda r, kwargs: ViewPermission([RoleConstants.USER.get_workspace_role()], | ||
| [Permission(group=Group(f"{kwargs.get('source')}_FOLDER"), | ||
| operate=Operate.SELF, | ||
| operate=Operate.EDIT, | ||
| resource_path=f"/WORKSPACE/{kwargs.get('workspace_id')}/{kwargs.get('source')}/{kwargs.get('folder_id')}" | ||
| )], CompareConstants.AND), | ||
| RoleConstants.WORKSPACE_MANAGE.get_workspace_role() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code appears correct and does not contain significant issues or optimizations at this time. It sets up permissions that allow users to view their own folders within a workspace, but it allows others (Workspace Managers) to edit any folder regardless of who owns it. Suggestions:
By implementing some of the proposed changes, you can further enhance the security and flexibility of your application's access control mechanisms. |
||
|
|
||
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.
The code appears to be functioning correctly, but I can suggest a few improvements:
Functionality Duplication: The logic within
get_first_non_nullandset_variable_to_jsonmight become redundant if you combine them into one function based on some conditions.Error Handling: Consider adding error handling to manage cases where the input values or references cannot be retrieved from
workflow_manage.Here's an improved version incorporating these comments and suggestions:
This revised code includes the suggested improvements and organizes the functionality into methods that perform specific tasks related to processing and managing workflows and their variables.