-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Application read permission #4338
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 |
|---|---|---|
|
|
@@ -93,8 +93,8 @@ class ApplicationChatRecordOperateAPI(APIView): | |
| ) | ||
| @has_permissions(PermissionConstants.APPLICATION_CHAT_LOG_READ.get_workspace_application_permission(), | ||
| PermissionConstants.APPLICATION_CHAT_LOG_READ.get_workspace_permission_workspace_manage_role(), | ||
| PermissionConstants.APPLICATION_EDIT.get_workspace_application_permission(), | ||
| PermissionConstants.APPLICATION_EDIT.get_workspace_permission_workspace_manage_role(), | ||
| PermissionConstants.APPLICATION_READ.get_workspace_application_permission(), | ||
| PermissionConstants.APPLICATION_READ.get_workspace_permission_workspace_manage_role(), | ||
| ViewPermission([RoleConstants.USER.get_workspace_role()], | ||
| [PermissionConstants.APPLICATION.get_workspace_application_permission()], | ||
| CompareConstants.AND), | ||
|
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. There is one issue or change proposed in this code snippet: Original line: PermissionConstants.APPLICATION_EDIT.get_workspace_application_permission(),
PermissionConstants.APPLICATION_EDIT.get_workspace_permission_workspace_manage_role()Modified line: PermissionConstants.APPLICATION_READ.get_workspace_application_permission(),
PermissionConstants.APPLICATION_READ.get_workspace_permission_workspace_manage_role()Change Description: Optimization/Suggestion: However, as of now, the current modification removes edit capabilities from users who would typically need that level of permission. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,8 +88,8 @@ const workspace = { | |
| [ | ||
| new ComplexPermission([RoleConst.USER],[PermissionConst.APPLICATION.getApplicationWorkspaceResourcePermission(source_id)],[],'AND'), | ||
| RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, | ||
| PermissionConst.APPLICATION_EDIT.getWorkspacePermissionWorkspaceManageRole, | ||
| PermissionConst.APPLICATION_EDIT.getApplicationWorkspaceResourcePermission(source_id) | ||
| PermissionConst.APPLICATION_READ.getWorkspacePermissionWorkspaceManageRole, | ||
| PermissionConst.APPLICATION_READ.getApplicationWorkspaceResourcePermission(source_id) | ||
| ], | ||
| 'OR' | ||
| ), | ||
|
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 code provided has a couple of minor issues:
These changes will improve the clarity and maintainability of the code while resolving the identified issues. |
||
|
|
||
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 part of Django REST Framework views that handle CRUD (Create, Read, Update, Delete) operations on application prompts and applications within a workspace. Here are some observations:
Code Snippets Analysis
@has_permissions()Usage:PromptGenerateViewandOpenViewuse@has_permissions()decorator with similar logic but differing permission types.has_permissions()is for the edit operation (APPLICATION_EDIT), while the second argument covers manage role permissions.Permission Constants:
ApplicationConstants.APPLICATION_EDIT.get_workspace_application_permission()withApplicationConstants.APPLICATION_READ.get_workspace_application_permission().ApplicationConstants.APPLICATION_EDIT.get_workspace_permission_workspace_manage_role()withApplicationConstants.APPLICATION_READ.get_workspace_permission_workspace_manage_role().Tags in API Routes:
"_("Application")", which might not be necessary given their context. Consider using more specific tags.Role Permissions:
Summary
EDIT_APPLICATIONtoREAD_APPLICATION.WorkspaceManageRolechecks if they don't add any additional security.Updated Code Example
This revised code addresses the minor issue with permission constants and ensures clarity in the usage of the tags.