Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/common/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,10 @@ class PermissionConstants(Enum):
group=Group.SYSTEM_RES_APPLICATION, operate=Operate.EDIT, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_APPLICATION]
)
RESOURCE_APPLICATION_AUTH = Permission(
group=Group.SYSTEM_RES_APPLICATION, operate=Operate.AUTH, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_APPLICATION]
)
RESOURCE_APPLICATION_OVERVIEW_READ = Permission(
group=Group.SYSTEM_RES_APPLICATION_OVERVIEW, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_APPLICATION]
Expand Down Expand Up @@ -1339,6 +1343,10 @@ class PermissionConstants(Enum):
group=Group.SYSTEM_RES_KNOWLEDGE, operate=Operate.GENERATE, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_KNOWLEDGE]
)
RESOURCE_KNOWLEDGE_AUTH = Permission(
group=Group.SYSTEM_RES_KNOWLEDGE, operate=Operate.AUTH, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_KNOWLEDGE]
)
# 文档
RESOURCE_KNOWLEDGE_DOCUMENT_READ = Permission(
group=Group.SYSTEM_RES_KNOWLEDGE_DOCUMENT, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
Expand Down Expand Up @@ -1432,6 +1440,10 @@ class PermissionConstants(Enum):
group=Group.SYSTEM_RES_TOOL, operate=Operate.EXPORT, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_TOOL]
)
RESOURCE_TOOL_AUTH = Permission(
group=Group.SYSTEM_RES_TOOL, operate=Operate.AUTH, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_TOOL]
)
RESOURCE_MODEL_READ = Permission(
group=Group.SYSTEM_RES_MODEL, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_MODEL]
Expand All @@ -1444,6 +1456,10 @@ class PermissionConstants(Enum):
group=Group.SYSTEM_RES_MODEL, operate=Operate.DELETE, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_MODEL]
)
RESOURCE_MODEL_AUTH = Permission(
group=Group.SYSTEM_RES_MODEL, operate=Operate.AUTH, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_MODEL]
)
OPERATION_LOG_READ = Permission(
group=Group.OPERATION_LOG, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.OPERATION_LOG]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code you've provided is already comprehensive and well-organized, with clear structure for defining permissions related to various system components within an application. Here are some observations without suggesting additional changes:

  1. Duplicate ADMIN Role: The roles defined under each permission list include 'Admin'. It's good practice to ensure there are no duplicate values if they represent the same category of role.

  2. Consistent Naming Conventions: Ensure that all group names (e.g., .SYSTEM_RES_APPLICATION) follow consistent naming conventions, which can improve readability and maintainability.

  3. Clear Structure: Each permission has a unique identifier (RESOURCE_APPLICATION_AUTH, etc.), making it easy to track their purpose.

Overall, the current implementation appears to be correct given its intended functionality. If you want to enhance clarity or streamline further, here are minor adjustments:

Recommendations

  • Consider using more descriptive names for groups, such as "System Resource Application Auth" instead of "RESOURCE_APPLICATION_AUTH".

  • Since you're only granting admin access across all specified resources in your permissions, consider refactoring into a single set of common permissions rather than duplicating them multiple times.

For example:

class CommonPermissions(Enum):
    READ_ADMIN = Permission(group=Group.ADMIN_GROUP_READONLY, operate=Operate.READ)
    UPDATE_ADMIN = Permission(group=Group.ADMIN_GROUP_WRITEONLY, operate=Operate.UPDATE)

# Usage
for permission in CommonPermissions:
    # Add this permission instance to your overarching PermissionConstants enum where applicable

This approach reduces redundancy and makes it easier to manage and extend future permission requirements for administrative tasks.

Expand Down
Loading