A lightweight traceable user directory storage method
By using YAML files to manage user directory information, the complex problems of installation, deployment, backup, and operation and maintenance of database storage for small and medium-sized enterprises are solved. Lightweight user directory storage is achieved, enabling efficient operation on low-configuration hardware, reducing costs and simplifying the operation process.
Patent Information
- Application Number
- CN202311273408.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2043-09-28
AI Technical Summary
Small and medium-sized enterprises face challenges in installing, deploying, backing up, and maintaining databases for user directory storage, as well as increased costs.
YAML files are used instead of databases. User information is managed through user directory information files and user log files. Archive points are set for data recovery, achieving lightweight storage.
This approach reduces hardware costs while avoiding cumbersome database installation, deployment, backup, and maintenance tasks, thus improving the operational efficiency of the identity authentication system.
Smart Images

Figure CN117251422B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of network management, and particularly relates to a lightweight and traceable user directory storage method. BACKGROUND
[0002] For many small and medium-sized companies, most productivity tools use identity authentication standards such as LDAP and Oauth, and a database is needed behind the software that realizes these standards to serve as a user directory. In general enterprises and organizations, the storage data structure of user authentication is relatively fixed, the number of people is basically below ten thousand, and the logical structure related to user information is simple, and the storage of users can be completed without a database. Moreover, the operation and maintenance of the database itself increases the system complexity and cost. At the same time, database backup and information viewing are not intuitive. At the same time, setting up incremental backup for the database is very tedious, and the operations of each database are not the same. SUMMARY
[0003] The purpose of the embodiment of the present application is to provide a lightweight and traceable user directory storage method to replace the database and remove the tedious work of installation, deployment, backup and operation and maintenance when using the database.
[0004] According to a first aspect of the embodiment of the present application, a lightweight and traceable user directory storage method is provided, which stores a user directory based on a YAML file, and the YAML file includes a user directory information file and a user log file.
[0005] The user directory information file is used to store user information, and the user directory information file is divided into two modes: (1) all operations are performed in one file; and (2) a user sets an archive point, and saves the current user data as a backup file.
[0006] The user log file is used to record operations on the user directory information file, and the user log file is provided with an archive point, and the original data is restored by extracting the modified information in the log.
[0007] Further, the user log file includes log entry data and archive point data, the log entry data includes an operation type, original data and current data, the archive point data includes archive point information and archive point markers, the archive point information refers to a segment of plaintext set by a user, and is used to mark the custom information of this archive; and the archive point markers are obtained by calculating the MD5 value of the text obtained by mixing the operation time and the operation content.
[0008] Further, the operation type includes adding a user, deleting a user and modifying a directory.
[0009] Further, the process of archiving the user log is as follows:
[0010] a. The user adds, deletes or modifies the user information;
[0011] b. The user log file records the operation of the user;
[0012] c. The user sends an archiving instruction;
[0013] d. The read directory file lock is set;
[0014] e. An MD5 value is generated according to the existing user information, and the archiving information in the archiving instruction is recorded in the archiving point data of the log file;
[0015] f. After the user log file is modified successfully, the user directory data file is modified;
[0016] g. The read file lock is released.
[0017] Further, when the user log file receives the archiving instruction, if the user directory information file is mode (1), the value of the user directory file is modified synchronously; if the user directory information file is mode (2), the current user directory file is saved and a copy of the same user directory file is copied, and the modification is performed on the copied user directory file.
[0018] Further, when the user log file receives the rollback instruction, if the user directory information file is mode (1), the data recorded in the log file is operated in reverse according to the rollback point, and the user directory data at the corresponding archiving point is restored; if the user directory information file is mode (2), the user directory file after the rollback point is deleted.
[0019] According to a second aspect of an embodiment of the present application, an electronic device is provided, comprising:
[0020] one or more processors;
[0021] a memory for storing one or more programs;
[0022] When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to the first aspect.
[0023] According to a third aspect of an embodiment of the present application, a computer readable storage medium is provided, which stores computer instructions, and the instructions are executed by a processor to implement the method according to the first aspect.
[0024] The technical scheme provided by the embodiments of the present application can include the following beneficial effects:
[0025] From the above embodiments, the application can complete the use of the database, and the system can run on the lower hardware configuration, saving the hardware cost, and avoiding the complicated work of installation, deployment, backup, operation and maintenance when using the database.
[0026] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the application. BRIEF DESCRIPTION OF DRAWINGS
[0027] The accompanying drawings incorporated in and forming a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.
[0028] Figure 1 is a logical structure diagram of a user directory information file according to an exemplary embodiment.
[0029] Figure 2 is a logical structure diagram of a user log file according to an exemplary embodiment.
[0030] Figure 3 is a schematic diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0031] A lightweight and traceable user directory storage method uses a YAML file to replace a database, the YAML file including a user directory information file and a user log file;
[0032] The user directory information file is used to store user information, and the user information includes a username, a password and an organization; the user directory information file is divided into two modes: (1) all operations are performed in one file, and when a user selects an archive point for traceability, data recovery operations are performed according to the user log file to return to a previous version; (2) a user sets an archive point once, and saves current user data as a backup file;
[0033] The user log file is used to record operations on the user directory information file, and the user log file is provided with an archive point, and original data is recovered by extracting modified information in the log.
[0034] In the present application, the lightweight storage adopts YAML format. The user data is managed by using the YAML format file, and the archive point can be set to trace back the data. The running efficiency of the identity authentication system is significantly improved: the system can also run smoothly on a low-config computer (2 GB memory, dual-core 2 GHz frequency processor); at the same time, compared with the traditional database system, the deployment, data migration and backup are easier, and in most cases, the backup system, maintenance system and recovery system can be copied.
[0035] As shown in Figure 1 , the logical structure of the user directory information file is shown in the figure, the data structure is an array, which can be continuous or discrete data in the memory, and the password field is MD5 encrypted. In the two working modes, the first mode: all operations are performed in one file, and when the user selects the archive point for tracing back, the data is traced back according to the log file; the second mode: the user sets an archive point, and saves the current user data as a backup file. The difference between the two modes is only whether the number of files is multiple or one. When the user sets the archive point, if the user directory is stored in the first mode, the user directory data modified by the user is saved in the current user directory file; if the user directory is stored in the second mode, the original user directory data is retained every time the archive point is set, and the updated data of the user is copied to a new file. In the two modes, the final storage logical structure of the user directory is consistent, as shown in Figure 1 .
[0036] The logical structure of the user log file is shown in Figure 2 , including log entry data and archive point data, the log entry data including operation type, original data and present data, and the archive point data including archive point information and archive point mark. The archive point information refers to a piece of plaintext set by the user, which can mark the custom information of this archive. The archive point mark is a text obtained by mixing the operation time and operation content, and then calculating the MD5 value as the archive identification result.
[0037] Generally, the user sets an archive point after a series of modifications, additions and deletions, that is, after the save operation after the modification in the user interface, so a plurality of or one log entry data corresponds to a unique archive data.
[0038] The operation type is divided into: adding a user, deleting a user and modifying a directory. In the modification operation, only one field needs to be recorded, and if multiple fields are modified, multiple fields can be provided. In the deletion operation, all information needs to be provided.
[0039] Specifically, the process of using the log archive by the user is as follows:
[0040] a. User increases, deletes, modifies user information by directly operating code or indirectly (REST API, RPC, etc.).
[0041] b. Log file records user-modified increase, deletion, modification information.
[0042] c. User sends archiving instructions by directly operating code or indirectly.
[0043] d. Set read directory file lock, implement file lock method, as long as the file can be read and cannot be modified.
[0044] e. According to the existing user information, generate an MD5 value, and receive the archiving information in the archiving instruction, record it in the log file archiving point data.
[0045] f. After the log file is modified successfully, the user directory data file is modified.
[0046] g. Release the read file lock.
[0047] User directory information file will only be modified according to the log record operation after archiving, if the system restarts without archiving operation, read the user directory data first, then read the operation data after the last archiving point, and operate the user directory data read into the memory.
[0048] The association between the two files is as follows:
[0049] a. When the log file receives the archiving instruction, according to the user-selected file mode, process the corresponding file, in user information file mode 1, synchronize the value of the user directory file. In mode 2, save the current file and copy a new file. There are many naming strategies, as long as they can be distinguished. For example: if the user adds two information, modifies one information, and archives, the log file adds an archiving point and archiving information after the new information entry and the modified information entry; if the user information file is mode 1, add new information after the file, and modify the corresponding project in the directory file according to the corresponding modification information. If the user information file is mode 2, you can directly write the existing data into the new user directory information file.
[0050] b. When the log file receives the backtracking instruction, delete the log data after the given backtracking archiving point, and then process the corresponding file according to the user-selected user directory file mode: in mode 1, according to the backtracking point, sequentially reverse the data recorded in the log file to restore the user directory data to the corresponding archiving point. In mode 2, directly delete the user directory file after the backtracking point.
[0051] Correspondingly, the present application also provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement a lightweight and traceable user directory storage method as described above. As Figure 3 As shown in the figure, a hardware structure diagram of any data processing capable device where the apparatus of the embodiment of the present application is provided, in addition to the processor, the memory and the network interface as shown in the figure, the any data processing capable device where the apparatus of the embodiment is generally according to the actual function of the any data processing capable device, can also include other hardware, and no longer be described. Figure 3
[0052] Correspondingly, the present application also provides a computer readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement a lightweight and traceable user directory storage method as described above. The computer readable storage medium can be an internal storage unit of any data processing capable device, such as a hard disk or a memory. The computer readable storage medium can also be an external storage device, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. Further, the computer readable storage medium can include both the internal storage unit of any data processing capable device and the external storage device. The computer readable storage medium is used to store the computer program and other programs and data required by the any data processing capable device, and can also be used to temporarily store data that has been output or will be output.
[0053] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. The application is intended to cover any variations, uses or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice in the art to which the application pertains.
[0054] It should be understood that the present application is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application.
Claims
1. A lightweight retroactive user directory storage method, characterized by, A user directory is stored based on a YAML file, the YAML file including a user directory information file and a user log file; The user directory information file is used to store user information, and the user directory information file is divided into two modes: (1) all operations are performed in one file; and (2) a user sets an archive point, and current user data is saved as a backup file; The user log file is used to record operations performed on the user directory information file, and the user log file is provided with an archive point, and original data is recovered by extracting modified information in the log; The user log file includes log entry data and archive point data, the log entry data including an operation type, original data and current data, the archive point data including archive point information and an archive point marker, the archive point information being a segment of plaintext set by a user and used to mark custom information for this archive, and the archive point marker being obtained by calculating an MD5 value of a text formed by mixing an operation time and operation content; A user log archive process includes the following steps: a. A user adds, deletes or modifies user information; b. A user log file records user operations; c. A user sends an archive instruction; d. A read directory file lock is set; e. An MD5 value is generated based on existing user information, and archive information in the archive instruction is recorded in archive point data in the log file; f. After the user log file is modified successfully, a user directory data file is modified; g. The read file lock is released.
2. The method of claim 1, wherein, The operation type includes adding a user, deleting a user and modifying a directory.
3. The method of claim 2, wherein, When the user log file receives an archive instruction, if the user directory information file is in mode (1), the value of the user directory file is modified synchronously; if the user directory information file is in mode (2), a current user directory file is saved and a same user directory file is copied, and the copied user directory file is modified.
4. The method of claim 2, wherein, When the user log file receives a backtracking instruction, if the user directory information file is in mode (1), data recorded in the log file is inversely operated according to a backtracking point, and the user directory data at the corresponding archive point is restored; if the user directory information file is in mode (2), the user directory file after the backtracking point is deleted.
5. An electronic device, comprising: The method comprises: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1-4.
6. A computer readable storage medium having stored thereon computer instructions, wherein, The instruction is executed by the processor to implement the method of any one of claims 1-4.
Citation Information
Patent Citations
Method and system for organizing, storing and querying network traffic logs
CN114218181A
Easily extensible and traceable data operation recording system and method
CN116192499A