Dynamic authority management method and device, electronic equipment and storage medium
Through dynamic permission management methods, a permission tree is generated and a menu bar is generated recursively, which solves the problems of cross-domain communication complexity and redundant code in traditional permission management systems, reduces development costs and improves system security.
Patent Information
- Application Number
- CN202411175158.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-11-08
AI Technical Summary
Traditional permission management systems have problems such as cross-domain communication complexity, information interaction delay, redundant code and development complexity in multi-tenant systems, resulting in high cost and low security.
Dynamic permission management method is adopted to generate permission trees by receiving permission configuration files uploaded by users, and recursively generate menu bars based on tenant list and user permissions to avoid cross-domain communication delays and redundant codes, ensuring security.
It reduces development costs, reduces redundant code, improves the security and reliability of the system, and avoids the problem of delay in information interaction.
Smart Images

Figure CN118916897A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of rights management, and in particular to a dynamic rights management method, device, electronic device and storage medium. Background Art
[0002] In modern enterprise applications, permission management is a crucial part, especially in complex applications such as multi-tenant systems, enterprise internal management systems, B2B platforms, etc., the need for permission management is more prominent. Traditional permission management systems are usually separated from business systems and implement permission verification and control through cross-domain communication. However, this approach has many problems in actual applications:
[0003] Browser security policy: Modern browsers implement strict security policies to restrict cross-domain requests. This complicates the communication between the business system and the rights management system, and requires handling authentication and authorization issues for cross-domain requests, increasing development and maintenance costs.
[0004] Information interaction delay: Embedding the permission management system through iframe will cause information interaction delay. Each permission verification and permission menu generation requires a cross-domain request, which not only affects the user experience, but may also cause performance bottlenecks.
[0005] Redundant code: Business systems often contain a lot of redundant code related to permission management. These codes not only increase the complexity of the system, but also make the system difficult to maintain and expand. When the permission management requirements change, both the business system and the permission system need to be modified accordingly, which increases the development cost.
[0006] Development complexity: When developers modify functions related to permission management, they need to study two sets of codes, the business system and the permission system. This double burden not only increases the complexity of development, but also easily leads to errors and security vulnerabilities.
[0007] The main solutions to the above problems are as follows:
[0008] Centralized permission management system: In this solution, all permission management logic is centralized in an independent permission management system. The business system interacts with the permission management system through API or iframe.
[0009] Distributed permission management system: In this solution, permission management logic is distributed among various business systems, and permission data is synchronized to each system.
[0010] Front-end permission control: Some systems implement permission control on the front-end, store user permission information in the browser, and use JavaScript to dynamically generate menus and control page access.
[0011] Then the cross-domain communication of the centralized permission management system will bring complexity and delay problems, as well as increase system maintenance and development costs. Although the distributed permission management system reduces the cross-domain communication problem, this approach brings data consistency problems, and the redundant code and logic in each business system are difficult to manage uniformly. Although the front-end permission control solution reduces the burden on the server, it has serious security risks. Users can bypass permission control by modifying the front-end code. Summary of the invention
[0012] The present invention provides a dynamic permission management method, device, electronic device and storage medium, which are used to solve the technical problems of information interaction delay, code redundancy, high development cost and low security.
[0013] The present invention provides a dynamic permission management method, which is applied to a permission management navigation bar component; the method comprises:
[0014] Receiving a rights configuration file uploaded by a user; the rights configuration file includes file data of different levels;
[0015] Generate a permission tree using the file data;
[0016] Generate user rights for each user according to the permission tree;
[0017] When receiving an access request initiated by a target user, obtaining a target tenant list corresponding to the access request;
[0018] A permission menu bar for the user is generated according to the tenant list and the target user permission of the target user.
[0019] Optionally, the step of using the file data to generate a permission tree includes:
[0020] Acquire the hierarchical relationship of the file data;
[0021] Constructing a tree structure according to the hierarchical relationship;
[0022] The file data is added into the tree structure to generate a permission tree of the permission configuration file.
[0023] Optionally, the step of generating user rights for each user according to the permission tree includes:
[0024] Receive selection information for the permission tree, and determine user permissions for each user based on the selection information.
[0025] Optionally, the step of generating the user's permission menu bar according to the tenant list and the target user's target user's permission includes:
[0026] Acquire a resource code list according to the tenant list;
[0027] Filtering menu resources with access rights from the resource code list according to the target user's rights;
[0028] The menu resource is used to recursively generate a permission menu bar.
[0029] The present invention also provides a dynamic rights management device, which is applied to a rights management navigation bar component; the device comprises:
[0030] A rights configuration file receiving module, used to receive a rights configuration file uploaded by a user; the rights configuration file contains file data of different levels;
[0031] A permission tree generation module, used to generate a permission tree using the file data;
[0032] A user authority generation module, used to generate user authority for each user according to the authority tree;
[0033] A target tenant list acquisition module is used to acquire a target tenant list corresponding to an access request when receiving an access request initiated by a target user;
[0034] The permission menu bar generating module is used to generate the permission menu bar of the user according to the tenant list and the target user permission of the target user.
[0035] Optionally, the permission tree generation module includes:
[0036] A hierarchical relationship acquisition submodule, used to acquire the hierarchical relationship of the file data;
[0037] A tree structure component submodule, used to construct a tree structure according to the hierarchical relationship;
[0038] The permission tree generation submodule is used to add the file data into the tree structure to generate a permission tree for the permission configuration file.
[0039] Optionally, the user authority generation module includes:
[0040] The user authority generation submodule is used to receive selection information for the authority tree and generate user authority for each user according to the selection information.
[0041] Optionally, the permission menu bar generation module includes:
[0042] A resource code list acquisition submodule, used to acquire a resource code list according to the tenant list;
[0043] A menu resource filtering submodule, used to filter menu resources with access rights from the resource code list according to the target user's rights;
[0044] The permission menu bar generation submodule is used to recursively generate a permission menu bar using the menu resources.
[0045] The present invention also provides an electronic device, the device comprising a processor and a memory:
[0046] The memory is used to store program code and transmit the program code to the processor;
[0047] The processor is used to execute the dynamic rights management method as described above according to the instructions in the program code.
[0048] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program code, and the program code is used to execute the dynamic permission management method as described in any one of the above items.
[0049] It can be seen from the above technical solutions that the present invention has the following advantages: the present invention provides a dynamic permission management method, which can specifically include the following steps: receiving a permission configuration file uploaded by a user; the permission configuration file contains file data of different levels; using the file data to generate a permission tree; generating user permissions for each user according to the permission tree; when receiving an access request initiated by a target user, obtaining a target tenant list corresponding to the access request; generating a user's permission menu bar according to the tenant list and the target user's target user permissions. The present invention performs permission management by setting a permission management navigation bar component to avoid the information interaction delay problem caused by using iframe. Compared with a distributed permission management system, a business system no longer needs to include a large amount of permission management code that is not related to the business, which reduces redundant code and facilitates maintenance and expansion. In addition, when developers modify functions related to permission management, they only need to focus on the business system itself, without having to study the implementation details of the permission system, thereby reducing development costs. In addition, the present invention recursively generates a menu bar and distributes permissions to ensure that users can only access functions for which they have permissions, thereby providing system security and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0051] Figure 1A flowchart of a dynamic rights management method provided by an embodiment of the present invention;
[0052] Figure 2 A flowchart of a dynamic rights management method provided by another embodiment of the present invention;
[0053] Figure 3 A schematic diagram of generating a permission menu bar provided by an embodiment of the present invention;
[0054] Figure 4 A structural block diagram of a dynamic rights management device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The embodiments of the present invention provide a dynamic permission management method, device, electronic device and storage medium, which are used to solve the technical problems of information interaction delay, code redundancy, high development cost and low security.
[0056] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] See also Figure 1 , Figure 1 A flowchart of the steps of a dynamic rights management method provided by an embodiment of the present invention.
[0058] The present invention provides a dynamic permission management method, which is applied to a permission management navigation bar component, wherein the permission management navigation bar component includes the following three sections:
[0059] 1. Header top bar area: provides users with tenant switching capabilities;
[0060] 2. Menu bar area: dynamically generate the menu bar with permissions according to the user configuration. Among them, the default menus are role management, resource management, and employee management under permission management, providing users with the ability to configure permissions;
[0061] 3. Permission page area: Role management, resource management, and employee management are the basic management pages provided by the component. Users can have configuration capabilities when they access the component.
[0062] The permission management navigation bar component can be published as an npm package to the company's internal private domain warehouse, which not only ensures data security but also reduces development access costs.
[0063] The method may specifically include the following steps:
[0064] Step 101, receiving a rights configuration file uploaded by a user; the rights configuration file includes file data of different levels;
[0065] In the embodiment of the present invention, in the resource management stage, it is necessary to upload and configure the unique resource identifier ResourceCode of each resource and the corresponding parent node. A flexible permission configuration function is provided. The administrator can configure the user's permissions through the interface of the permission management navigation bar component.
[0066] In one example, the permission configuration file may be an Excel file, which includes file data at different levels.
[0067] Step 102, generating a permission tree using file data;
[0068] After collecting file data from the permission configuration file, the file data can be used to generate a permission tree. Specifically, the front end uploads the Excel file to the back end through the upload control. After receiving the Excel file, the back end performs basic verification and storage processing, and builds a tree structure according to the hierarchical information in the Excel file to obtain the permission tree.
[0069] Step 103, generating user rights for each user according to the rights tree;
[0070] After generating the permission tree, users can generate user permissions for each user by selecting permissions in the permission tree on the role management page.
[0071] Step 104, when an access request initiated by a target user is received, a target tenant list corresponding to the access request is obtained;
[0072] Step 105: Generate a user permission menu bar according to the tenant list and the target user permission of the target user.
[0073] After completing the rights allocation for each user, when receiving an access request initiated by a target user, a target tenant list corresponding to the access request may be obtained to generate a rights menu bar according to the target tenant list and the target user rights of the target user.
[0074] The present invention performs permission management by setting a permission management navigation bar component, avoiding the information interaction delay problem caused by using iframe. Compared with the distributed permission management system, the business system no longer needs to include a large amount of permission management code that is irrelevant to the business, reducing redundant code and facilitating maintenance and expansion. In addition, when modifying functions related to permission management, developers only need to pay attention to the business system itself, without studying the implementation details of the permission system, thereby reducing development costs. In addition, the present invention recursively generates a menu bar and distributes permissions to ensure that users can only access functions for which they have permission, thereby providing system security and reliability.
[0075] See also Figure 2 , Figure 2 A flowchart of a dynamic rights management method provided by another embodiment of the present invention. Specifically, the following steps may be included:
[0076] Step 201, receiving a rights configuration file uploaded by a user; the rights configuration file includes file data of different levels;
[0077] Step 201 is the same as step 101. For details, please refer to the description of step 101, which will not be repeated here.
[0078] Step 202, obtaining the hierarchical relationship of the file data;
[0079] Step 203, constructing a tree structure according to the hierarchical relationship;
[0080] Step 204, adding the file data into the tree structure to generate a permission tree for the permission configuration file;
[0081] In the embodiment of the present invention, each row of data in the rights configuration file can be mapped to a node or a leaf node. Specifically, a tree structure can be constructed according to the hierarchical relationship in the rights configuration file, starting from the root node, and recursively creating each child node.
[0082] Step 205, receiving selection information for the permission tree, and determining user permissions for each user according to the selection information;
[0083] In the embodiment of the present invention, after the permission tree is generated, the user can generate user permissions for each user by selecting permissions in the permission tree on the role management page.
[0084] Step 206, when receiving an access request initiated by a target user, obtaining a target tenant list corresponding to the access request;
[0085] Step 207: Generate a user permission menu bar according to the tenant list and the target user permission of the target user.
[0086] After completing the rights allocation for each user, when receiving an access request initiated by a target user, a target tenant list corresponding to the access request may be obtained to generate a rights menu bar according to the target tenant list and the target user rights of the target user.
[0087] In one example, step 207 may include the following sub-steps:
[0088] S71, obtaining a resource code list according to the tenant list;
[0089] S72, filtering menu resources with access rights from a resource code list according to the target user's rights;
[0090] S73, recursively generate a permission menu bar using menu resources.
[0091] In the specific implementation, Figure 3 As shown, when the target user requests or logs in, he can obtain the tenant list that the user has access to, and request the permission system to obtain the resource code list based on the tenant list; then perform a pre-check: filter out the menu resources that the user has access to based on the user's permissions; if the new menu is empty after filtering, the user is prompted that he does not have the current system permissions; if the new menu list is not empty after filtering, the permission menu bar is recursively generated. Since the permission menu bar is dynamically generated based on the user's role and permissions, it can ensure that the user can only see and access the functions for which he has permissions.
[0092] In the specific implementation, the recursive process can include recursive pruning of vue-router data and recursive rendering of vue views.
[0093] Recursive pruning of vue-router data: The permission management navigation bar component needs to receive two fields of data, one is the router object representing the project route, and the other is the permission identifier list resource_code_list that the current user has access to. Since the vue-router object is a nested array, in order to completely traverse the data, it is necessary to recursively check whether the permission identifier ResourceCode of each sub-item exists in the permission identifier list resource_code_list during the preprocessing process. If it exists, no processing is required. If not, the route is skipped.
[0094] Recursive rendering of vue views: A recursive component is a special component that calls itself in its own template. This component structure can easily handle data with nested hierarchical relationships. For multi-level menus in the navigation menu, the function of dynamically generating multi-level navigation menus can be achieved by recursively rendering each menu item and their submenus.
[0095] The present invention performs permission management by setting a permission management navigation bar component, avoiding the information interaction delay problem caused by using iframe. Compared with the distributed permission management system, the business system no longer needs to include a large amount of permission management code that is irrelevant to the business, reducing redundant code and facilitating maintenance and expansion. In addition, when modifying functions related to permission management, developers only need to pay attention to the business system itself, without studying the implementation details of the permission system, thereby reducing development costs. In addition, the present invention recursively generates a menu bar and distributes permissions to ensure that users can only access functions for which they have permission, thereby providing system security and reliability.
[0096] See also Figure 4 , Figure 4 A structural block diagram of a dynamic rights management device provided by an embodiment of the present invention.
[0097] The embodiment of the present invention provides a dynamic permission management device, which is applied to a permission management navigation bar component; the device includes:
[0098] The rights configuration file receiving module 401 is used to receive the rights configuration file uploaded by the user; the rights configuration file contains file data of different levels;
[0099] A permission tree generation module 402, used to generate a permission tree using file data;
[0100] A user authority generation module 403 is used to generate user authority for each user according to the authority tree;
[0101] The target tenant list acquisition module 404 is used to acquire the target tenant list corresponding to the access request when receiving an access request initiated by a target user;
[0102] The permission menu bar generating module 405 is used to generate a user's permission menu bar according to the tenant list and the target user's permission of the target user.
[0103] In the embodiment of the present invention, the permission tree generation module 402 includes:
[0104] A hierarchical relationship acquisition submodule is used to obtain the hierarchical relationship of file data;
[0105] The tree structure component submodule is used to construct a tree structure based on the hierarchical relationship;
[0106] The permission tree generation submodule is used to add file data into the tree structure and generate a permission tree for the permission configuration file.
[0107] In the embodiment of the present invention, the user authority generation module 403 includes:
[0108] The user authority generation submodule is used to receive selection information for the authority tree and generate user authority for each user according to the selection information.
[0109] In the embodiment of the present invention, the permission menu bar generation module 405 includes:
[0110] The resource code list acquisition submodule is used to obtain the resource code list according to the tenant list;
[0111] The menu resource filtering submodule is used to filter menu resources with access rights from the resource code list according to the target user's permissions;
[0112] The permission menu bar generation submodule is used to recursively generate the permission menu bar using menu resources.
[0113] An embodiment of the present invention further provides an electronic device, the device comprising a processor and a memory:
[0114] The memory is used to store the program code and transmit the program code to the processor;
[0115] The processor is used to execute the dynamic rights management method of the embodiment of the present invention according to the instructions in the program code.
[0116] The embodiment of the present invention further provides a computer-readable storage medium, which is used to store program codes, and the program codes are used to execute the dynamic permission management method of the embodiment of the present invention.
[0117] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0118] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0119] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0120] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0121] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0123] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0124] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0125] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A dynamic rights management method, characterized in that: Applied to the permission management navigation bar component; the method includes: Receiving a rights configuration file uploaded by a user; the rights configuration file includes file data of different levels; Generate a permission tree using the file data; Generate user rights for each user according to the permission tree; When receiving an access request initiated by a target user, obtaining a target tenant list corresponding to the access request; A permission menu bar for the user is generated according to the tenant list and the target user permission of the target user.
2. The method according to claim 1, characterized in that The step of using the file data to generate a permission tree comprises: Acquire the hierarchical relationship of the file data; Constructing a tree structure according to the hierarchical relationship; The file data is added into the tree structure to generate a permission tree of the permission configuration file.
3. The method according to claim 1, characterized in that The step of generating user rights for each user according to the permission tree comprises: Receive selection information for the permission tree, and determine user permissions for each user based on the selection information.
4. The method according to claim 1, characterized in that The step of generating the user's permission menu bar according to the tenant list and the target user's target user's permission includes: Acquire a resource code list according to the tenant list; Filtering menu resources with access rights from the resource code list according to the target user's rights; The menu resource is used to recursively generate a permission menu bar.
5. A dynamic rights management device, characterized in that: Applicable to the permission management navigation bar component; the device comprises: A rights configuration file receiving module, used to receive a rights configuration file uploaded by a user; the rights configuration file contains file data of different levels; A permission tree generation module, used to generate a permission tree using the file data; A user authority generation module, used to generate user authority for each user according to the authority tree; A target tenant list acquisition module is used to acquire a target tenant list corresponding to an access request when receiving an access request initiated by a target user; The permission menu bar generating module is used to generate the permission menu bar of the user according to the tenant list and the target user permission of the target user.
6. The device according to claim 5, characterized in that The permission tree generation module includes: A hierarchical relationship acquisition submodule, used to acquire the hierarchical relationship of the file data; A tree structure component submodule, used to construct a tree structure according to the hierarchical relationship; The permission tree generation submodule is used to add the file data into the tree structure to generate a permission tree for the permission configuration file.
7. The device according to claim 5, characterized in that The user authority generation module includes: The user authority generation submodule is used to receive selection information for the authority tree and generate user authority for each user according to the selection information.
8. The device according to claim 5, characterized in that The permission menu bar generation module includes: A resource code list acquisition submodule, used to acquire a resource code list according to the tenant list; A menu resource filtering submodule, used to filter menu resources with access rights from the resource code list according to the target user's rights; The permission menu bar generation submodule is used to recursively generate a permission menu bar using the menu resources.
9. An electronic device, characterized in that: The device comprises a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the dynamic rights management method according to any one of claims 1 to 4 according to the instructions in the program code.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program code, and the program code is used to execute the dynamic rights management method according to any one of claims 1 to 4.
