Authorization information management method for military camp management system
By using graph databases in the military camp management system to organize permission information in a directed graph form, the problems of data structure complexity and inefficiency in the existing technology are solved, and rapid query and large number of role support are realized, which is suitable for complex scenarios. Permission management.
Patent Information
- Application Number
- CN202410238707.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-01
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-03-01
AI Technical Summary
The existing military camp management system based on the RBAC model has problems of complexity in data structure and low query efficiency when creating roles and management permissions. Especially in scenarios where there are many types of personnel and complex business rules, it cannot effectively support a large number of people. Role creation and quick query permission information.
Use graph databases (such as Nebula Graph) to organize permission information in the form of directed graphs, build, update, compress and cache through topological graph structures, reduce association queries, improve query efficiency, and do not require manual assistance when creating roles.
It realizes rapid query of complex relationship data, supports the creation of a large number of roles, improves the efficiency and scope of application of the permission management system, and is suitable for scenarios with a wide variety of positions and complex business rules.
Smart Images

Figure CN118193550B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of authority management, and in particular to an authority information management method for a military camp management system. Background Art
[0002] Permission management generally refers to the fact that users can access and can only access the resources they are authorized to access according to the security rules or security policies set by the system. Permission management appears in almost any system and is an important part of the system.
[0003] At present, the military camp management system uses the existing data structure in the original RBAC model (i.e., the role-based access control model) to manage permission information. Among them, the unit table: stores basic unit information and parent unit ID; the camp table: stores basic camp information; the camp-unit table: stores the association between units and camps, indicating that a certain unit can manage a certain camp; the role table: stores role information; the role-function association table: stores the functions that a role can have; the function-permission association table: the association information between function points and permission capabilities; for example: the function of adding, deleting, modifying and checking subordinate camp information has the search permission and visibility permission for the corresponding camp.
[0004] The data structure currently used only supports the creation of a small number of roles (usually 10 to 20), and requires manual assistance when creating roles. It is not suitable for scenarios with a wide variety of personnel positions and complex business rules. For example, when you need to obtain the parent-child tree structure of the units that the current account can manage, recursion or loop table lookup may be involved to complete the tree structure. Especially in scenarios with many levels of permission systems, the problem will be more obvious. For example: the association path is: account-) role->organization->first-level sub-organization->...n-level sub-organization->accessed resource (resource instance). Obviously, multiple association queries will result in a longer time to return the query results and it is unacceptable. Summary of the invention
[0005] The purpose of the present invention is to provide an authority information management method for a military camp management system. A graph database organizes data in the form of a directed graph. In addition to labels and attributes, a data node directly includes relationship data. There is no need to perform associated queries to query complex relationship data. All "relationship" data can be obtained through one query, which improves query efficiency and supports the creation of a large number of roles. No manual assistance is required when creating roles. The method is suitable for scenarios with a wide variety of personnel positions and complex business rules, and has a wide range of applications.
[0006] To achieve the above object, the present invention provides a method for managing authority information of a military camp management system, comprising the following steps:
[0007] S1. Construction of the topological graphical structure of permission information: Convert the permission information association structure into the storage form of Nebula Graph database to form a topological mesh graphical structure;
[0008] S2. Update of the topological structure of permission information: There are two forms: one is to update the topological structure in full at 0:00 every day; the other is to update the topological structure in real time;
[0009] S3. Compression of the calculation result of the permission information: After obtaining the permission set data, determine whether to perform data compression according to actual needs;
[0010] S4, permission information cache: Based on the Redis database, the calculated permission data is cached in key-value format;
[0011] S5. Use of permission information: When permission data is used in a business process, the permission key is assembled in the form of the permission type prefix plus the ID to be used, and then queried from the Redis cache.
[0012] Preferably, in step S1, in building the authority information topology graphical structure, the following steps are specifically included:
[0013] S11, creating a permission information topology graphic structure, setting logical objects included in the permission information topology graphic structure, and association relationships between logical objects; wherein the permission information topology graphic structure adopts a Nebula Graph graph database model;
[0014] S12. Traverse the permission information topology graph structure and convert the permission information topology graph structure into a graph database model.
[0015] Preferably, in step S12, the permission information topology graph structure is converted into a graph database model, and the specific steps are as follows:
[0016] S121, obtaining entities in the permission information topology graph structure, marking the entities as nodes in the graph database model, parsing entity attributes of the marked entities, and marking the entity attributes as node attributes of the nodes in the graph database model;
[0017] S122. Obtain the relationships in the permission information topological graph structure, mark the relationships as edges in the graph database model; according to the graph database model, transfer and store the permission management information corresponding to the specific user into the nodes of the graph database, and establish edges between the corresponding nodes in the graph database.
[0018] Preferably, in the updating of the authority data topology structure in step S2, the topology structure is updated in full at 0:00 every day:
[0019] S211. When deleting a Tag node, the Nebula Graph database automatically deletes the associated edges. At 0:00 every day, the permission data table in the original MySQL database is fully scanned, and the Tag node information is obtained by creating a topological mesh structure based on step S1:
[0020] S212, delete the old Tag node;
[0021] S213, adding a new Tag node;
[0022] S214, adding a new Tag node associated edge;
[0023] Based on the above steps, each node is deleted and rebuilt to complete the update of the entire topology graph structure.
[0024] Preferably, in the updating of the authority data topology structure in step S2, the topology structure is updated in real time:
[0025] S221, when the system updates the information of the node, initiates real-time update of the topology structure;
[0026] S222, according to the updated object, obtain object information from the original MySQL database;
[0027] S223, parsing to obtain new Tag nodes and Edge information that need to be added;
[0028] S224, delete the old Tag node;
[0029] S225, add a new Tag node;
[0030] S226. Add a new Tag node associated edge.
[0031] Preferably, in the compression of the calculation result of the permission information in step S3, the permission information is first acquired, a calculation script is written according to actual needs, the required permission range is quickly acquired from the topological structure, and it is determined whether to perform data compression;
[0032] When not compressed, it is expressed in the form of a set;
[0033] When compressing, it is expressed in the form of a mapping relationship.
[0034] Preferably, in step S4, in the permission information cache:
[0035] Use redis collection type to store uncompressed collection type results;
[0036] Use the redis string type to store compressed data.
[0037] Preferably, in the use of the permission information in step S5, the index is enabled, and when the graph database is searched, the nodes in the graph database are searched based on the index.
[0038] Preferably, the topological graphical structure of the permission information is visualized to generate a logical model er diagram for the administrator to check the abstract permission management model.
[0039] Therefore, the present invention adopts the above-mentioned method for managing the authority information of the military camp management system. The graph database organizes data in the form of a directed graph. In addition to labels and attributes, a data node also directly includes relationship data. There is no need to perform associated queries to query complex relationship data. One query can obtain all "relationship" data, which improves query efficiency and supports the creation of a large number of roles. No manual assistance is required when creating roles. It is suitable for scenarios with a wide variety of personnel positions and complex business rules, and has a wide range of applications.
[0040] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a topological structure example diagram of the authority information management method of the military camp management system;
[0042] Figure 2 It is a flowchart of the authority information update of the authority information management method of the military camp management system;
[0043] Figure 3 This is an example diagram of permission information compression of the permission information management method of the military camp management system. DETAILED DESCRIPTION
[0044] The technical solution of the present invention is further described below through the accompanying drawings and embodiments.
[0045] Unless otherwise defined, technical or scientific terms used in the present invention shall have the common meanings understood by one having ordinary skills in the field to which the present invention belongs.
[0046] The method for managing authority information of a military camp management system provided by the present invention comprises the following steps:
[0047] S1. Construction of the topological graphical structure of permission information: Convert the permission information association structure into the storage form of Nebula Graph database to form a topological mesh graphical structure;
[0048] S2. Update of the topological structure of permission information: There are two forms: one is to update the topological structure in full at 0:00 every day; the other is to update the topological structure in real time;
[0049] S3. Compression of the calculation result of the permission information: After obtaining the permission set data, determine whether to perform data compression according to actual needs;
[0050] S4, permission information cache: Based on the Redis database, the calculated permission data is cached in key-value format;
[0051] S5. Use of permission information: When permission data is needed in the business process, assemble the permission key in the form of the permission type prefix plus the ID to be used, and then query it from the Redis cache.
[0052] Example
[0053] S1. Construction of permission information topological graphic structure.
[0054] The permission association structure is converted into the Nebula Graph database for storage to form a topological structure. In the NebulaGraph database, the Tag data type is used to represent nodes, and the Edge data type is used to represent edges. Nodes and edges are connected to form a topological mesh graph structure that includes all permission point information.
[0055] S11, creating a permission information topology graphic structure, setting logical objects included in the permission information topology graphic structure, and association relationships between logical objects; wherein the permission information topology graphic structure adopts a Nebula Graph graph database model;
[0056] S12, traverse the permission information topology graph structure, and convert the permission information topology graph structure into a graph database model. The specific steps are as follows:
[0057] S121, obtaining entities in the permission information topology graph structure, marking the entities as nodes in the graph database model, parsing entity attributes of the marked entities, and marking the entity attributes as node attributes of the nodes in the graph database model;
[0058] S122, obtain the relationship in the topological graph structure of the permission information, mark the relationship as an edge in the graph database model; according to the graph database model, transfer the permission management information corresponding to the specific user to the node of the graph database, and establish edges between the corresponding nodes in the graph database. Tags can be used as nodes, such as: unit nodes, personnel nodes, camp nodes;
[0059] Edge can be used to represent the relationship between the nodes on both sides of the edge, as shown below:
[0060] Unit-unit parent-child relationship association edge;
[0061] Unit-camp management relationship associated edge;
[0062] Person-person visibility association;
[0063] Unit-personnel association edge;
[0064] Camp-personnel association edge;
[0065] other……
[0066] Based on the Nebula Graph graph database syntax, create a Tag node. The example statement is as follows:
[0067] CREATE TAG department(name string, other unit attributes);
[0068] Among them, department is a unit node, indicating the node type, and contains attributes such as department name, etc.
[0069] Based on the Nebula Graph database syntax, create an Edge. The example statement is as follows:
[0070] CREATE EDGE deptRealtionEdge(degree int);Unit dependency edge;
[0071] CREATE EDGE userVisibleEdge(visited Boolean); Person-person visibility association edge;
[0072] Among them, deptRealtionEdge is a unit association edge, indicating the edge type, and including the following attributes: number of levels; userVisibleEdge is a person-person visibility association edge, indicating the type, and including the following attributes: yes / no.
[0073] In this way, create all the required Tag nodes and Edge data types, and then convert the data in the original database and store it in Nebula Graph to get the following: Figure 1 The topological mesh structure shown.
[0074] There is no restriction on the language used for conversion. It can read the permission data in the source database one by one, obtain the data in the corresponding database record according to business needs, create a new Nebula Graph node and associated edge and assign values.
[0075] The original MySQL database has the following table structure:
[0076] Table 1 Unit table
[0077] ID Unit Name Person in charge ID Name of person in charge Parent unit ID 100 National large units 333 Zhang XX 0 101 Beijing Unit 444 Li XX 100 102 Haidian Unit 555 Wang XX 101
[0078] Table 2 Personnel visibility table
[0079] ID User AID User BID Visibility 1 100 200 true 2 100 300 true 3 200 300 false
[0080] The camp table and other tables are not given as examples and are similar to the above table.
[0081] Example 1: Add a new department tag example statement:
[0082] INSERT VERTEX department(name,other attributes) VALUES "dept_100":("TimDuncan",42).
[0083] Here, dept_100 is the unique code of the node. Different node types are given different prefixes and matched with the object ID to ensure the uniqueness of the code.
[0084] Example 2: Add a new department-associated Edge example statement:
[0085] INSERT EDGE deptRelationEdge(degree)VALUES"dept_100"->"dept_101":(1);
[0086] INSERT EDGE deptRelationEdge(degree)VALUES"dept_101"->"dept_100":(-1).
[0087] Example 3: Add a new person-person visibility association example statement:
[0088] INSERT EDGE userVisibleEdge(degree)VALUES"user_100"->"user_200":(true).
[0089] S2. Update of the permission information topology structure.
[0090] S21. Update the topology structure regularly at 0:00 every day to solve data anomalies and provide data backup.
[0091] S211. Nebula Graph has the feature that when a tag node is deleted, the edges associated with it will be automatically deleted. Using this feature, the permission data table in the original MySQL database is fully scanned at 0:00 every day, and the tag node information is obtained by parsing and creating a topological mesh structure in the same way as above;
[0092] S212, delete the old Tag node;
[0093] S213, adding a new Tag node;
[0094] S214. Add a new Tag node associated edge.
[0095] By deleting and rebuilding each node, the entire topology graph structure can be updated.
[0096] S22, real-time update of topology structure: used to update permission relationship change information in real time;
[0097] S221, when the system updates information about users, units, camps, etc. involving nodes, initiates real-time update of the topology structure;
[0098] S222. According to the updated object, obtain object information from the original MySQL database.
[0099] Example 3: To update the Haidian unit association, go to the unit table to obtain the latest unit information.
[0100] S223, parsing to obtain new Tag and Edge information that needs to be added;
[0101] S224, delete the old Tag node;
[0102] S225, add a new Tag node;
[0103] S226. Add a new Tag node associated edge.
[0104] like Figure 2 As shown, the update of the permission information topology structure adopts two data update modes, which takes into account the real-time update needs and can guarantee the integrity and correctness of the data.
[0105] S3. Compression of the calculation results of the permission information.
[0106] First, write a calculation script according to actual needs to quickly obtain the required permission range from the topology structure.
[0107] Example 4: Calculate the visible user range of user A whose ID is 100:
[0108] 1. Add the user ID by prefixing "user_" to form "user_100";
[0109] 2. Quickly locate the user A node by using user_100 as the ID of the tag node;
[0110] 3. Through the user-user visibility edge, you can find the set of all users that user A can see.
[0111] Example 5: Get all child units of unit A with ID 100, which can be used as the scope of units that unit A can manage:
[0112] 1. Add the ID of unit A to the prefix "dept_" to form "dept_100" as the unique number of the unit node;
[0113] 2. Quickly locate the unit A node by using dept_100 as the tag node number;
[0114] 3. Through the unit-unit association edge and the condition that the deep value of the edge is greater than 0, all the child units of unit A can be obtained in one step.
[0115] Example 6: Get the employees in all sub-units of unit A with ID 100, which can be used as the scope of employees that can be managed by unit A:
[0116] 1. Add the ID of unit A to the prefix "dept_" to form "dept_100" as the unique number of the unit node;
[0117] 2. Quickly locate the unit A node by using dept_100 as the tag node number;
[0118] 3. Through the unit-unit association edge, and the condition that the deep value of the edge is greater than 0, all the child units of unit A can be obtained in one step;
[0119] 4. Nebula Graph supports starting with the sub-unit set obtained in step 3 above as the exploration starting point, and exploring through the unit-personnel relationship edge, so that all employees associated with all sub-units can be obtained (the graph database has a built-in function, just use it).
[0120] S32. Compression of authority results.
[0121] After obtaining the permission set data, determine whether to perform data compression based on actual needs. For particularly large amounts of data, data compression is performed. In order to save space, mapping relationships are used for compression. The meaning of compressed data needs to be manually defined in the system. Generally, not much compression is required for military camp management business needs, and the compression and decompression business processes can be pre-defined.
[0122] When the amount of data is not large, you can directly use the collection type. You can name the collection later and use it directly.
[0123] Example 7: Compress and store all the child units of unit A, and the number of subset units of unit A is relatively large. After obtaining the child unit node set, put it into the container according to the unit ID in the set, such as Figure 3 shown.
[0124] Among them, the cell with ID=1 is 0, which means that there is no unit with ID 1 in the set, that is, the unit with ID 1 is not a child unit of unit A. Similarly, in the above figure, the units with IDs 2, 3, 5, 8, 9, and 10 are child units of unit A. Figure 3 As shown, when the ID set is originally stored, each ID such as dept_100 needs to occupy 8 bytes, and 10 ID sets need 80 bytes, which is equivalent to 640 binary bits. After conversion, only a maximum of 10 binary bits are needed to meet the storage requirements, which greatly saves storage space.
[0125] S4. Permission information cache.
[0126] In order to ensure efficient access, Redis cache is used to store calculated permission data. Redis uses key-value format to store data.
[0127] Use the redis collection type to store uncompressed collection type results. Take user A's visible permissions as an example:
[0128] Storage: key:user:visible:user_id,value:collection data;
[0129] That is: user:visible:user_id:{uid1,uid2,uid3}.
[0130] Use redis string type to store compressed data, for example, unit A subunit:
[0131] Storage: key:dept:relation:dept_id, value:compressed number;
[0132] That is: dept:relation:dept_id:0110100111.
[0133] S5. Use of permission information.
[0134] When permission data is needed in a business process, the permission key is assembled in the form of the permission type prefix plus the ID to be used, and then queried from the Redis cache.
[0135] Example 8: To obtain the sub-unit set of unit A (assuming its ID is 100), you can use "dept:relation:ID of unit A", that is, dept:relation:100 as the key, and query the data corresponding to the key in Redis.
[0136] Therefore, the present invention adopts the above-mentioned method for managing the authority information of the military camp management system. The graph database organizes data in the form of a directed graph. In addition to labels and attributes, a data node also directly includes relationship data. There is no need to perform associated queries to query complex relationship data. One query can obtain all "relationship" data, which improves query efficiency and supports the creation of a large number of roles. No manual assistance is required when creating roles. It is suitable for scenarios with a wide variety of personnel positions and complex business rules, and has a wide range of applications.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. The authority information management method of the military camp management system is characterized by: The following steps are involved: S1. Construction of the topological graphical structure of permission information: Convert the permission information association structure into the storage form of Nebula Graph database to form a topological mesh graphical structure; S2. Update of the topological structure of permission information: There are two forms: one is to update the topological structure in full at 0:00 every day; the other is to update the topological structure in real time; S21. Update the topology structure regularly at 0:00 every day. The specific process is as follows: S211. When deleting a Tag node, the Nebula Graph database automatically deletes the associated edges. The permission data table in the original MySQL database is fully scanned at 0:00 every day, and the Tag node information is obtained by creating a topological mesh structure based on step S1. S212, delete the old Tag node; S213, add a new Tag node; S214, adding a new Tag node associated edge; Based on the above steps, each node is deleted and rebuilt to complete the update of the entire topology graph structure; S22, real-time update of the topology structure, the specific process is as follows: S221, when the system updates the information of the node, initiates real-time update of the topology structure; S222, according to the updated object, obtain object information from the original MySQL database; S223, parsing to obtain new Tag nodes and Edge information that need to be added; S224, delete the old Tag node; S225, add a new Tag node; S226, add new Tag node associated edge S3. Compression of the calculation results of permission information: After obtaining the permission set data, determine whether to perform data compression based on actual needs. The specific process is as follows: First, obtain permission information, write calculation scripts according to actual needs, quickly obtain the required permission range from the topological structure, and determine whether to perform data compression; When not compressed, it is expressed in the form of a set; When compressing, it is expressed in the form of a mapping relationship; S4, permission information cache: Based on the Redis database, the calculated permission data is cached in key-value format; S5. Use of permission information: When permission data is used in a business process, the permission key is assembled in the form of the permission type prefix plus the ID to be used, and then queried from the Redis cache.
2. The method for managing authority information of a military camp management system according to claim 1, characterized in that: In step S1, in building the authority information topology graphical structure, the following steps are specifically included: S11, creating a permission information topology graphic structure, setting logical objects included in the permission information topology graphic structure, and association relationships between logical objects; wherein the permission information topology graphic structure adopts a Nebula Graph graph database model; S12. Traverse the permission information topology graph structure and convert the permission information topology graph structure into a graph database model.
3. The method for managing authority information of a military camp management system according to claim 2, characterized in that: In step S12, the permission information topology graph structure is converted into a graph database model. The specific steps are as follows: S121, obtaining entities in the permission information topology graph structure, marking the entities as nodes in the graph database model, parsing entity attributes of the marked entities, and marking the entity attributes as node attributes of the nodes in the graph database model; S122, obtaining relationships in the permission information topology graph structure, marking the relationships as edges in the graph database model; According to the graph database model, the permission management information corresponding to the specific user is transferred and stored in the nodes of the graph database, and edges are established between the corresponding nodes in the graph database.
4. The method for managing authority information of a military camp management system according to claim 1, characterized in that: In step S4, the permission information cache: Use redis collection type to store uncompressed collection type results; Use the redis string type to store compressed data.
5. The method for managing authority information of a military camp management system according to claim 1, characterized in that: In the use of the permission information in step S5, the index is enabled, and when the graph database is searched, the nodes in the graph database are searched based on the index.
6. The method for managing authority information of a military camp management system according to claim 1, characterized in that: The topological graphical structure of permission information is visualized to generate a logical model er diagram for managers to check the abstract permission management model.
