Authority information verification method and device, electronic equipment and computer readable medium
By pre-caching the user information structure in the distributed file system and directly obtaining the user identification information and file identification information from the memory for permission verification, it solves the time-consuming and complex problems of traditional permission management methods and improves the performance and performance of the system. stability.
Patent Information
- Application Number
- CN202410892283.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-10-29
AI Technical Summary
Traditional permission management methods are time-consuming and labor-intensive in distributed file systems, especially when large-scale users concurrently access, it may lead to performance bottlenecks and increased complexity.
By pre-caching the user information structure in the memory, when the user initiates a file operation request, the user identification information and file identification information are directly obtained from the memory, and target permissions are verified, avoiding layer-by-layer transfer and database query.
It improves the permission verification efficiency of the distributed file system and ensures the performance and stability of the system, especially in the case of large-scale concurrent access.
Smart Images

Figure CN118862034A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a permission information verification method, device, electronic device and computer-readable medium. Background Art
[0002] With the development of computer network technology, distributed file systems have been widely used in various large-scale data processing scenarios due to their advantages such as high scalability, high availability and easy maintainability. However, the security issues of distributed file systems are becoming increasingly prominent, among which user rights management is a critical and complex task. Traditional rights management methods usually require layer-by-layer transmission and verification by querying session information, which is not only time-consuming and labor-intensive, but also increases the complexity of distributed file systems if permission information is queried through the database. In addition, in the case of large-scale concurrent access by users, it may also cause performance bottlenecks in distributed file systems. Summary of the invention
[0003] In view of this, embodiments of the present application provide a permission information verification method, device, electronic device, and computer-readable medium to overcome the above-mentioned problems or at least partially solve the above-mentioned problems.
[0004] A first aspect of an embodiment of the present application provides a permission information verification method, which is applied to a distributed file system, and the method includes:
[0005] Pre-cache the user information structure in memory;
[0006] When a first user initiates a file operation request for a target file in the distributed file system, obtaining file identification information of the target file, and obtaining user identification information corresponding to the first user from the user information structure;
[0007] Based on the file operation request, the user identification information and the file identification information, a target permission verification result of the first user for the target file is determined.
[0008] Optionally, the pre-caching of the user information structure in the memory includes:
[0009] When the first user establishes a connection with the distributed file system for the first time, generating user identification information of the first user according to a result of first user login authentication of the first user;
[0010] Based on the user identification information of the first user, a user information structure of the first user is generated, and the user information structure is cached in a memory.
[0011] Optionally, the user identification information includes a plurality of first SID information, and the file identification information includes a plurality of second SID information. Before determining the target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information, the method further includes:
[0012] Based on the file operation request of the first user, obtaining a request permission bit of the first user for the target file, where the request permission bit is used to indicate the access permission required by the first user for the target file;
[0013] The determining, based on the file operation request, the user identification information, and the file identification information, a target permission verification result of the first user for the target file includes:
[0014] Matching each of the multiple first SID information included in the user identification information with each of the multiple second SID information included in the file identification information, and determining whether at least one first SID information successfully matches at least one second SID information;
[0015] When at least one first SID information successfully matches at least one second SID information, determining a file permission bit corresponding to the successfully matched second SID information, the file permission bit being used to indicate the access rights that the first user can obtain for the target file;
[0016] Performing operations on the request permission bit and the file permission bit to obtain remaining target permission bits;
[0017] Based on the remaining target permission bits, a target permission verification result of the first user for the target file is determined.
[0018] Optionally, the first user SID includes at least a user SID, a primary group SID, an additional group SID, and an Everyone user SID, and the matching of each of the plurality of first SID information included in the user identification information with each of the plurality of second SID information included in the file identification information includes:
[0019] According to the order of the user SID, the primary group SID, the additional group SID and the Everyone user SID, the plurality of first SID information are matched with the plurality of second SID information respectively to determine whether the same situation occurs;
[0020] When the same first SID information and the same second SID information exist, it is determined that the same first SID information and the same second SID information match successfully.
[0021] Optionally, when at least one first SID information successfully matches at least one second SID information, determining the file permission bit corresponding to the successfully matched second SID information includes:
[0022] After first determining that the first SID information successfully matches at least one second SID information, a first matching pair is obtained, and a file permission bit corresponding to the second SID information successfully matched in the first matching pair is obtained, wherein the first matching pair includes the first SID information successfully matched for the first time and the second SID information successfully matched for the first time, and the first SID information successfully matched for the first time in the first matching pair is the i-th first SID information in the user identification information;
[0023] Calculate the request permission bit of the first SID information in the first matching pair and the file permission bit of at least one second SID information in the first matching pair to obtain a first remaining target permission bit;
[0024] When the first remaining target permission bit is 0, determining that the target permission check result is a check pass;
[0025] When the first remaining target permission bit is not 0, the i+1th first SID information after the first SID information in the first matching pair is matched with multiple second SID information, and when the match is successful, a second matching pair is obtained, where the second matching pair includes the i+1th first SID information and the second SID information that successfully matches the i+1th first SID information;
[0026] Calculate the request permission bit of the (i+1)th first SID information in the second matching pair and the file permission bit of the second SID information that successfully matches the (i+1)th first SID information to obtain a second remaining target permission bit;
[0027] When the second remaining target permission bit is 0, determining that the target permission check result is a check pass;
[0028] The method further comprises:
[0029] When the plurality of first SID information in the user identification information cannot be successfully matched with at least one second SID information, it is determined that the target authority verification result is a verification failure.
[0030] Optionally, the method further comprises:
[0031] Monitoring the user identification information of the first user to determine whether the user identification information of the first user changes;
[0032] When the user identification information of the first user changes, the user identification information of the first user in the user information structure is updated, and the updated user information structure is cached in the memory.
[0033] Optionally, after determining the target permission verification result of the first user for the target file based on the remaining target permission bits, the method further includes:
[0034] Based on the target permission verification result, determining whether the file operation request of the first user passes the verification;
[0035] When it is determined that the file operation request of the first user passes the verification, allowing the first user to access the target file based on the file operation request;
[0036] After it is determined that the file operation request of the first user fails verification, the first user is denied access to the target file based on the file operation request.
[0037] A second aspect of an embodiment of the present application provides a permission verification device, which is applied to a distributed file system, and the device includes:
[0038] The cache module is used to cache the user information structure in memory in advance;
[0039] an acquisition module, configured to acquire file identification information of a target file in the distributed file system when a first user initiates a file operation request for the target file in the distributed file system, and to acquire user identification information corresponding to the first user from the user information structure;
[0040] A determination module is used to determine a target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information.
[0041] A third aspect of an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the permission information verification method as described in the first aspect.
[0042] A fourth aspect of an embodiment of the present application provides a computer-readable medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the permission information verification method as described in the first aspect is implemented.
[0043] Beneficial effects of this application:
[0044] An embodiment of the present application provides a permission information verification method, device, electronic device and computer-readable medium, which are applied to a distributed file system. The method includes: pre-caching a user information structure in a memory; when a first user initiates a file operation request for a target file in the distributed file system, obtaining file identification information of the target file, and obtaining user identification information corresponding to the first user from the user information structure; based on the file operation request, the user identification information and the file identification information, determining a target permission verification result of the first user for the target file.
[0045] The user information structure of the first user can be pre-cached in the memory. When the first user needs to access the target file of the distributed file system, it is not necessary to obtain the user information structure by querying session information layer by layer or by querying permission information in the database. Instead, the user information structure can be directly obtained from the memory, and based on the file operation request, user identification information and file identification information issued by the first user, the target permission verification result of the first user for the target file is determined, thereby improving the efficiency of the permission verification of the distributed file system without increasing the complexity of the distributed file system. Moreover, when there is a large number of concurrent users accessing the distributed file system, the performance and stability of the distributed file system can also be guaranteed by pre-caching the user information structure in the memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application.
[0047] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 It is a flowchart of a permission information verification method provided by an embodiment of the present application;
[0049] Figure 2 It is a schematic diagram of a permission information verification method provided by an embodiment of the present application;
[0050] Figure 3 This is a flowchart of distributed file system permission verification in a permission information verification method provided in an embodiment of the present application;
[0051] Figure 4 It is a schematic diagram of a framework of a permission verification device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0052] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application may be combined with each other.
[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0054] Figure 1 is a flowchart of a permission information verification method provided by an embodiment of the present application, such as Figure 1 As shown, an embodiment of the present application provides a permission information verification method, which is applied to a distributed file system. The method:
[0055] In step S101, a user information structure is pre-cached in the memory;
[0056] In step S102, when a first user initiates a file operation request for a target file in the distributed file system, file identification information of the target file is obtained, and user identification information corresponding to the first user is obtained from the user information structure;
[0057] In step S103, based on the file operation request, the user identification information and the file identification information, a target permission verification result of the first user on the target file is determined.
[0058] First, in step S101, the user information structure corresponding to each user in the distributed file system is pre-cached to a storage area of the distributed file system that can be accessed efficiently, such as a memory or a fast index area of a local disk. For example, Redis can be used as a cache database, and the cache expiration time of the user information structure is set to 30 minutes. The user information structure is various user identification information of the user pre-stored in the form of a structure. By caching the user information structure in the memory, the user identification information of the user can be quickly accessed and used when the various user identification information of the user contained in the user information structure is needed.
[0059] The code for defining the user information structure in C language is as follows:
[0060] struct smbd_sec_info{
[0061] uint32_t num_sids;
[0062] struct smb_sid *sids;
[0063] }
[0064] struct smb_sid{
[0065] uint8_t revision;
[0066] uint8_t num_subauth;
[0067] uint8_t authority[6];
[0068] int32_t sub_auth[num_subauth];
[0069] }
[0070] The above code is used to represent user information related to SMB (Server Message Block) security, and defines a user information structure for processing security-related information in the SMB protocol, such as identity authentication, permission management, etc. Through the user information structure, SMB security-related files can be easily operated and transferred.
[0071] Among them, the structure struct smbd_sec_info contains two member variables:
[0072] num_sids: Indicates the number of SMB security identifiers (SIDs), which is a 32-bit unsigned integer.
[0073] sids: is a pointer to the smb_sid structure, which is used to store the details of the SMB security identifier.
[0074] The struct smb_sid structure represents an SMB security identifier, which contains the following member variables:
[0075] revision: indicates the version number of the SMB SID, which is an 8-bit unsigned integer.
[0076] num_subauth: indicates the number of sub-authorizations of the SMB SID, which is an 8-bit unsigned integer.
[0077] authority: is a 6-byte array that represents the authority of the SMB SID.
[0078] sub_auth: is an integer array used to store the sub-authorization information of the SMB SID. The length of the array is determined by num_subauth.
[0079] Further, in step S102, the first user is a user who has completed user login authentication in advance on the distributed file system. When the first user needs to access a target file in the distributed file system, a file operation request based on the target file is initiated to the distributed file system. The file operation request includes a file identifier of the target file to be accessed and access permissions (such as read permission, write permission, execute permission, delete permission, update permission, owner permission, etc.) that the first user needs to request. User identification information corresponding to the first user is obtained from the user information structure of the first user, wherein the user identification information includes relevant information for identifying the user, the group to which the user belongs, or the computer account of the user, and file identification information for the target file also needs to be obtained. The file identification information is an access control list (ACL) or file attributes. The file identification information is used to manage and configure the target file to ensure the security and access control of the target file.
[0080] It should be noted that since the user information structure is pre-stored in the memory, when a file operation request initiated by the first user is received, there is no need to search the user information structure from the underlying storage, and only the file identification information of the target file needs to be read from the underlying storage.
[0081] Finally, in step S103, after obtaining the user identification information and the file identification information, the access rights that the first user has to the target file are determined based on the user identification information and the file identification information, and based on the access rights that the first user needs to request, the target permission verification result that the first user can request for the target file can be finally determined. The target permission verification result is the access right that can be verified by the first user after initiating a file operation request.
[0082] Through the above embodiment, the user information structure of the first user is pre-cached in the memory. When the first user needs to access the target file of the distributed file system, it is not necessary to obtain the user information structure by querying the session information layer by layer or by querying the permission information in the database. Instead, the user information structure can be directly obtained from the memory, and the target permission verification result of the first user for the target file is determined based on the file operation request, user identification information and file identification information issued by the first user. Therefore, the efficiency of the permission verification of the distributed file system is improved without increasing the complexity of the distributed file system. Moreover, when there is a large number of concurrent users accessing the distributed file system, the performance and stability of the distributed file system can also be guaranteed by pre-caching the user information structure in the memory.
[0083] Optionally, the step S101 includes:
[0084] When the first user establishes a connection with the distributed file system for the first time, generating user identification information of the first user according to a result of first user login authentication of the first user;
[0085] Based on the user identification information of the first user, a user information structure of the first user is generated, and the user information structure is cached in a memory.
[0086] Specifically, in an embodiment of the present application, when the client of the first user establishes a connection with the distributed file system for the first time, the server of the distributed file system generates user identification information according to the result of the user login authentication of the first user, and pre-generates a user information structure based on the user identification information of the first user, and caches the generated user information structure in the memory.
[0087] Through the above embodiment, when the first user establishes a connection with the distributed file system for the first time, a user information structure is constructed and cached in the memory, so that when the first user initiates a file operation request, the corresponding user identification information can be directly extracted from the pre-stored user information structure and compared with the file identification information of the target file, which greatly improves the verification efficiency of the permission information.
[0088] Optionally, the user identification information includes a plurality of first SID information, and the file identification information includes a plurality of second SID information, and before step S103, the method further includes:
[0089] Based on the file operation request of the first user, obtaining a request permission bit of the first user for the target file, where the request permission bit is used to indicate the access permission required by the first user for the target file;
[0090] The determining, based on the file operation request, the user identification information, and the file identification information, a target permission verification result of the first user for the target file includes:
[0091] Matching each of the multiple first SID information included in the user identification information with each of the multiple second SID information included in the file identification information, and determining whether at least one first SID information successfully matches at least one second SID information;
[0092] When at least one first SID information successfully matches at least one second SID information, determining a file permission bit corresponding to the successfully matched second SID information, the file permission bit being used to indicate the access rights that the first user can obtain for the target file;
[0093] Performing operations on the request permission bit and the file permission bit to obtain remaining target permission bits;
[0094] Based on the remaining target permission bits, a target permission verification result of the first user for the target file is determined.
[0095] Specifically, SID (Security Identifier), in an embodiment of the present application, the user identification information of the first user includes multiple first SID information, the first SID information is the user identification, the file identification information of the target file includes multiple second SID information, the second SID information is the file identification, before determining the target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information, it is necessary to obtain the request permission bit of the first user for the target file according to the file operation request of the first user, the request permission bit is used to indicate the access permission that the first user needs to request for the target file, for example, the access permission includes read permission, write permission, and execute permission, when the access permission bit that the first user needs to request is read permission and write permission, the corresponding request permission bit is 110, that is, the permission bit corresponding to the access permission required by the user is "1", and the permission bit corresponding to the access permission not requested by the user is "0".
[0096] Furthermore, each of the multiple first SID information included in the user identification information is matched with each of the multiple second SID information included in the file identification information to determine whether there is a successful match between at least one first SID information and at least one second SID information. When there is a successful match between at least one first SID information and at least one second SID information, the file permission bit corresponding to the successfully matched second SID information is determined, and the file permission bit is used to indicate the access rights that the first user can obtain for the target file.
[0097] Furthermore, the remaining target permission bits are calculated based on the first user's request permission bits and the file permission bits of the successfully matched files to obtain the remaining target permission bits, which represent the permission bits corresponding to the access rights that the first user can verify and pass after initiating a file operation request.
[0098] Finally, based on the calculated remaining target permission bits, the target permission verification result of the first user for the target file can be determined.
[0099] Through the above embodiment, the authority of the first user when accessing the target file can be determined by matching the user identification information with the file identification information, so as to facilitate corresponding authority control and access management.
[0100] Figure 2 It is a schematic diagram of a permission information verification method provided in an embodiment of the present application.
[0101] Optionally, the first user SID includes at least a user SID, a primary group SID, an additional group SID, and an Everyone user SID, and the matching each of the multiple first SID information included in the user identification information with each of the multiple second SID information included in the file identification information includes:
[0102] According to the order of the user SID, the primary group SID, the additional group SID and the Everyone user SID, the plurality of first SID information are matched with the plurality of second SID information respectively to determine whether the same situation occurs;
[0103] When the same first SID information and the same second SID information exist, it is determined that the same first SID information and the same second SID information match successfully.
[0104] Specifically, in the embodiments of the present application, Figure 2As shown, the SIDs of multiple first users at least include user SID, primary group SID, additional group SID and Everyone user SID, wherein user SID represents the SID of the first user, primary group SID represents the SID of the primary group to which the first user belongs, that is, the primary group SIDs of all users included in the primary group are the same, additional group SID represents the SID of the additional group to which the first user belongs, that is, the additional group SIDs of all users included in the additional group are the same, and Everyone user SID represents the SID that all users have. Further, it is necessary to match each first SID information in the user identification information and compare it with each second SID information in the file identification information. The matching steps are as follows:
[0105] The plurality of first SID information and the plurality of second SID information are compared in sequence according to the order of the user SID, the primary group SID, the additional group SID, and the Everyone user SID. That is, starting from the user SID, the user SID is matched with the plurality of second SID information respectively, and after the user SID matching is completed, the primary group SID is matched with the plurality of second SID information respectively, and after the primary group SID matching is completed, the additional group SID is matched with the plurality of second SID information respectively, and after the additional group SID matching is completed, the Everyone user SID is matched with the plurality of second SID information respectively, and thus, the matching of the plurality of first SID information and the plurality of second SID information is completed.
[0106] During the matching process, it is necessary to determine whether the first SID information and the second SID information are identical. If the first SID information and the second SID information are identical, it is determined that the two SIDs are matched successfully.
[0107] Through the above embodiment, the target permission verification result of the user can be quickly determined by matching the user SID, the primary group SID, the additional group SID and the Everyone user SID with the multiple second SID information of the target file respectively.
[0108] Optionally, when at least one first SID information successfully matches at least one second SID information, determining the file permission bit corresponding to the successfully matched second SID information includes:
[0109] After first determining that the first SID information successfully matches at least one second SID information, a first matching pair is obtained, and a file permission bit corresponding to the second SID information successfully matched in the first matching pair is obtained, wherein the first matching pair includes the first SID information successfully matched for the first time and the second SID information successfully matched for the first time, and the first SID information successfully matched for the first time in the first matching pair is the i-th first SID information in the user identification information;
[0110] Calculate the request permission bit of the first SID information in the first matching pair and the file permission bit of at least one second SID information in the first matching pair to obtain a first remaining target permission bit;
[0111] When the first remaining target permission bit is 0, determining that the target permission check result is a check pass;
[0112] When the first remaining target permission bit is not 0, the i+1th first SID information after the first SID information in the first matching pair is matched with multiple second SID information, and when the match is successful, a second matching pair is obtained, where the second matching pair includes the i+1th first SID information and the second SID information that successfully matches the i+1th first SID information;
[0113] Calculate the request permission bit of the (i+1)th first SID information in the second matching pair and the file permission bit of the second SID information that successfully matches the (i+1)th first SID information to obtain a second remaining target permission bit;
[0114] When the second remaining target permission bit is 0, determining that the target permission check result is a check pass;
[0115] The method further comprises:
[0116] When the plurality of first SID information in the user identification information cannot be successfully matched with at least one second SID information, it is determined that the target authority verification result is a verification failure.
[0117] As an example, Figure 2 As shown, taking the first user as user U and the target file as file A as an example, the multiple first SID information of the user identification information stored by user U in the user information structure include: user SID (SID_U1 of U itself), primary group SID (SID_U2 of the primary group to which U belongs), additional group SID (1-SID_U3 of the additional group to which U belongs), additional group SID (2-SID_U4 of the additional group to which U belongs), and Everyone user SID (SID_U5 of everyone user).
[0118] File A contains read permission, write permission, and execute permission (rwx). The multiple second SID information of the file identification information of file A includes: SID_A1: rwx, the corresponding file permission bit is 111, SID_A2: r, the corresponding file permission bit is 100, SID_A3: rw, the corresponding file permission bit is 110.
[0119] When user U requests file A, the access rights required are rw (read permission and write permission), and the corresponding request permission bit is 110. At this time, it is necessary to determine in turn whether each first SID information of user U matches one of the second SID information in the multiple second SID information. First, it is necessary to match the first first SID information of user U with the multiple second SID information of file A, that is, to compare the user SID (U's own SID_U1) with SID_A1, SID_A2, and SID_A3 respectively, to determine whether SID_U1 matches one of the second SID information in SID_A1, SID_A2, and SID_A3 (that is, the SID is consistent). Assuming that SID_U1 matches SID_A1 successfully, then SID_U1 and SID_A1 are the first matching pair, and the first SID information (SID_U1) that contains the first successful match in the first matching pair is the i-th first SID information, and at this time, i=1.
[0120] Further, based on the operation of the request permission bit (110) of user U and the file permission bit (111) corresponding to SID_A1, the first remaining target permission bit (000) is obtained. Specifically, the operation method for the request permission bit and the file permission bit is: bitwise invert the file permission bit and perform a bitwise AND operation with the request permission bit to obtain the remaining target permission bit.
[0121] That is, the first remaining target permission bit is 0. In this case, it means that the target permission verification result of the file operation request of user U for file A is passed.
[0122] It should be noted that the remaining target permission bits include the first remaining target permission bits, and the first remaining target permission bits specifically refer to the remaining target permission bits between the first matching pair.
[0123] Assuming that SID_U1 does not successfully match multiple second SID information or SID_U1 successfully matches SID_A1, but the first remaining target permission bit is not 0, a further matching process will be performed between SID_U2 and SID_A1, SID_A2, and SID_A3 respectively. If SID_U2 successfully matches SID_A2, then the first matching pair is SID_U2 and SID_A2. At this time, the first SID information (SID_U2) that successfully matches for the first time in the first matching pair is the i-th first SID information, and at this time, i=2.
[0124] Further, the second remaining target permission bit between SID_U2 and SID_A2 in the second matching pair is calculated. If the second remaining target permission bit is 0, it means that the target permission verification result of the file operation request of user U for file A is passed, and the matching process of the first SID information of user U and multiple second SID information of file A is ended. Otherwise, the matching process of the next first SID information is continued, and so on, until the remaining target permission bit is calculated to be 0.
[0125] If all the first SID information fails to match successfully or the remaining target permission bits calculated are not 0, it is determined that the target permission verification result corresponding to the file operation of user U on file A is a verification failure. At this time, user U is denied access to file A.
[0126] Through the above embodiment, after a successful match, the target permission verification result of the user can be quickly determined by immediately calculating the remaining target permission bits, thereby improving the efficiency of the permission verification.
[0127] Optionally, the method further comprises:
[0128] Monitoring the user identification information of the first user to determine whether the user identification information of the first user changes;
[0129] When the user identification information of the first user changes, the user identification information of the first user in the user information structure is updated, and the updated user information structure is cached in the memory.
[0130] Specifically, in an embodiment of the present application, the user identification information of the first user can be periodically monitored to determine whether the user identification information of the first user has changed. When the user identification information of the first user has changed, for example, the first user has joined a new additional group, then the user identification information of the first user in the user information structure needs to be updated, and the updated user information structure is cached in the memory, so that the permission information can be verified according to the latest user information structure.
[0131] In this way, it is possible to support permission management of dynamic user information structures. When the user information structure changes, only the content of the user information structure in the memory needs to be modified without searching the underlying storage for modification. At the same time, it supports dynamic user permission management, effectively improving the verification efficiency of the permission information of the distributed file system and reducing the maintenance cost of the distributed file system.
[0132] Optionally, after determining the target permission verification result of the first user for the target file based on the remaining target permission bits, the method further includes:
[0133] Based on the target permission verification result, determining whether the file operation request of the first user passes the verification;
[0134] When it is determined that the file operation request of the first user passes the verification, allowing the first user to access the target file based on the file operation request;
[0135] After it is determined that the file operation request of the first user fails verification, the first user is denied access to the target file based on the file operation request.
[0136] Specifically, in an embodiment of the present application, after determining the target permission verification result of the first user for the target file based on the remaining target permission bits, it is determined whether the file operation request of the first user has passed the verification based on the target permission verification result of the first user. When it is determined that the file operation request of the first user has passed the verification, the first user is allowed to access the target file based on the file operation request. When it is determined that the file operation request of the first user has failed the verification, the first user is denied access to the target file based on the file operation request.
[0137] Figure 3 FIG. 1 is a flowchart of distributed file system permission verification in a permission information verification method provided in an embodiment of the present application. Figure 3 shown.
[0138] First, the client of the first user establishes a connection with the distributed file system, and accesses the SMB (Server Message Block, a protocol for sharing files, printers and other resources on a computer network) shared directory in the distributed file system as part of the local file system.
[0139] Furthermore, the server of the distributed file system saves the user SID, primary group SID, attachment group SID, and Everyone user SID of the first user as user identification information into a user information structure, and caches the user information structure into a memory.
[0140] Further, the first user initiates a file operation request for the target file and obtains file identification information.
[0141] Further, each piece of SID information in the file identification information is compared with each piece of SID information in the user information structure in turn to determine whether they are equal.
[0142] Further, when the SID information of the existing file identification information is equal to the SID information in the user information structure, the remaining request permission bits are calculated to obtain the remaining target permission bits.
[0143] Finally, a target permission verification result of the first user for the target file is determined based on the remaining target permission bits.
[0144] Figure 4 is a schematic diagram of a framework of a permission verification device provided by an embodiment of the present application, such as Figure 4 As shown, an embodiment of the present application provides a permission verification device, which is applied to a distributed file system, and the device includes:
[0145] The cache module 11 is used to cache the user information structure in the memory in advance;
[0146] An acquisition module 12, configured to acquire file identification information of a target file in the distributed file system when a first user initiates a file operation request for the target file in the distributed file system, and to acquire user identification information corresponding to the first user from the user information structure;
[0147] The determination module 13 is used to determine a target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information.
[0148] Optionally, the cache module 11 includes:
[0149] A user identification information generating module, configured to generate user identification information of the first user according to a result of first user login authentication of the first user when the first user establishes a connection with the distributed file system for the first time;
[0150] The user information structure generation module is used to generate a user information structure of the first user based on the user identification information of the first user, and cache the user information structure in a memory.
[0151] Optionally, the user identification information includes a plurality of first SID information, the file identification information includes a plurality of second SID information, and the device further includes:
[0152] a request permission bit acquisition module, used for acquiring the request permission bit of the first user for the target file based on the file operation request of the first user before determining the target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information, wherein the request permission bit is used to indicate the access permission required by the first user for the target file;
[0153] The determination module 13 includes:
[0154] a judgment module, configured to match each of the plurality of first SID information included in the user identification information with each of the plurality of second SID information included in the file identification information, and judge whether at least one first SID information successfully matches with at least one second SID information;
[0155] A file permission bit determination module, configured to determine, when at least one first SID information successfully matches at least one second SID information, a file permission bit corresponding to the successfully matched second SID information, wherein the file permission bit is used to indicate the access rights that the first user can obtain for the target file;
[0156] A remaining target permission bit determination module, used for performing calculations on the request permission bit and the file permission bit to obtain the remaining target permission bit;
[0157] A target permission verification result determination module is used to determine a target permission verification result of the first user for the target file based on the remaining target permission bits.
[0158] Optionally, the first user SID includes at least a user SID, a primary group SID, an additional group SID, and an Everyone user SID, and the determination module includes:
[0159] A judging unit, configured to match the plurality of first SID information with the plurality of second SID information in order of the user SID, the primary group SID, the additional group SID and the Everyone user SID, to judge whether the same situation occurs;
[0160] The determining unit is configured to determine that, when the same first SID information and the same second SID information exist, the same first SID information and the same second SID information are matched successfully.
[0161] Optionally, when at least one first SID information successfully matches at least one second SID information, determining the file permission bit corresponding to the successfully matched second SID information includes:
[0162] a first matching module, configured to obtain a first matching pair after first determining that the first SID information successfully matches the at least one second SID information, and obtain a file permission bit corresponding to the second SID information successfully matched in the first matching pair, wherein the first matching pair includes the first SID information successfully matched for the first time and the second SID information successfully matched for the first time, and the first SID information successfully matched for the first time in the first matching pair is the i-th first SID information in the user identification information;
[0163] A first remaining target permission bit acquisition module, configured to calculate a request permission bit of the first SID information in the first matching pair and a file permission bit of at least one second SID information in the first matching pair to obtain a first remaining target permission bit;
[0164] A first verification module, configured to determine that the target permission verification result is a verification pass when the first remaining target permission bit is 0;
[0165] a secondary matching module, configured to, when the first remaining target permission bit is not 0, match the i+1th first SID information following the first SID information in the first matching pair with a plurality of second SID information, and when the match succeeds, obtain a second matching pair, wherein the second matching pair includes the i+1th first SID information and the second SID information successfully matched with the i+1th first SID information;
[0166] A second remaining target permission bit acquisition module is used to calculate the request permission bit of the i+1th first SID information in the second matching pair and the file permission bit of the second SID information that successfully matches the i+1th first SID information to obtain the second remaining target permission bit;
[0167] A second verification module, configured to determine that the target permission verification result is a verification pass when the second remaining target permission bit is 0;
[0168] The device also includes:
[0169] The verification failure determination module is used to determine that the target permission verification result is a verification failure when multiple first SID information in the user identification information cannot be successfully matched with at least one second SID information.
[0170] Optionally, the device further comprises:
[0171] A user identification information determination module, configured to monitor the user identification information of the first user and determine whether the user identification information of the first user has changed;
[0172] The updating module is used to update the user identification information of the first user in the user information structure when the user identification information of the first user changes, and cache the updated user information structure in the memory.
[0173] Optionally, the device further comprises:
[0174] A verification judgment module, configured to determine whether the file operation request of the first user has passed the verification based on the target permission verification result after determining the target permission verification result of the first user for the target file based on the remaining target permission bits;
[0175] an access permission module, configured to, when determining that the file operation request of the first user has passed verification, allow the first user to access the target file based on the file operation request;
[0176] The access denial module is used to deny the first user access to the target file based on the file operation request after determining that the file operation request of the first user fails verification.
[0177] Based on the same inventive concept, another embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the permission information verification method as described in any of the above embodiments.
[0178] Based on the same inventive concept, another embodiment of the present application further provides a computer program product, including a computer program, which is executed by a processor to perform the permission information verification method described in any of the above embodiments.
[0179] Based on the same inventive concept, another embodiment of the present application further provides a computer-readable medium on which a computer program is stored, wherein when the program is executed by a processor, the permission information verification method as described in any of the above embodiments is implemented.
[0180] As for the device, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0181] 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.
[0182] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt 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 code.
[0183] The embodiments of the present application 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 application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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.
[0184] 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.
[0185] 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 A step that specifies a function in one or more boxes.
[0186] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional 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 application.
[0187] 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.
[0188] The above is a detailed introduction to a permission information verification method, device, electronic device and computer-readable medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for verifying authority information, characterized in that: Applied to a distributed file system, the method comprises: Pre-cache the user information structure in memory; When a first user initiates a file operation request for a target file in the distributed file system, obtaining file identification information of the target file, and obtaining user identification information corresponding to the first user from the user information structure; Based on the file operation request, the user identification information and the file identification information, a target permission verification result of the first user for the target file is determined.
2. The method for verifying authority information according to claim 1, characterized in that: The pre-caching of the user information structure in the memory includes: When the first user establishes a connection with the distributed file system for the first time, generating user identification information of the first user according to a result of first user login authentication of the first user; Based on the user identification information of the first user, a user information structure of the first user is generated, and the user information structure is cached in a memory.
3. The permission information verification method according to claim 1, characterized in that: The user identification information includes a plurality of first SID information, the file identification information includes a plurality of second SID information, and before determining the target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information, the method further includes: Based on the file operation request of the first user, obtaining a request permission bit of the first user for the target file, where the request permission bit is used to indicate the access permission required by the first user for the target file; The determining, based on the file operation request, the user identification information, and the file identification information, a target permission verification result of the first user for the target file includes: Matching each of the multiple first SID information included in the user identification information with each of the multiple second SID information included in the file identification information, and determining whether at least one first SID information successfully matches at least one second SID information; When at least one first SID information successfully matches at least one second SID information, determining a file permission bit corresponding to the successfully matched second SID information, the file permission bit being used to indicate the access rights that the first user can obtain for the target file; Performing operations on the request permission bit and the file permission bit to obtain remaining target permission bits; Based on the remaining target permission bits, a target permission verification result of the first user for the target file is determined.
4. The method for verifying authority information according to claim 3, characterized in that: The first user SID includes at least a user SID, a primary group SID, an additional group SID, and an Everyone user SID, and the matching of each of the plurality of first SID information included in the user identification information with each of the plurality of second SID information included in the file identification information includes: According to the order of the user SID, the primary group SID, the additional group SID and the Everyone user SID, the plurality of first SID information are matched with the plurality of second SID information respectively to determine whether the same situation occurs; When the same first SID information and the same second SID information exist, it is determined that the same first SID information and the same second SID information match successfully.
5. The method for verifying authority information according to claim 3, characterized in that: When at least one first SID information successfully matches with at least one second SID information, determining the file permission bit corresponding to the successfully matched second SID information includes: After first determining that the first SID information successfully matches at least one second SID information, a first matching pair is obtained, and a file permission bit corresponding to the second SID information successfully matched in the first matching pair is obtained, wherein the first matching pair includes the first SID information successfully matched for the first time and the second SID information successfully matched for the first time, and the first SID information successfully matched for the first time in the first matching pair is the i-th first SID information in the user identification information; Calculate the request permission bit of the first SID information in the first matching pair and the file permission bit of at least one second SID information in the first matching pair to obtain a first remaining target permission bit; When the first remaining target permission bit is 0, determining that the target permission check result is a check pass; When the first remaining target permission bit is not 0, the i+1th first SID information after the first SID information in the first matching pair is matched with multiple second SID information, and when the match is successful, a second matching pair is obtained, where the second matching pair includes the i+1th first SID information and the second SID information that successfully matches the i+1th first SID information; Calculate the request permission bit of the (i+1)th first SID information in the second matching pair and the file permission bit of the second SID information that successfully matches the (i+1)th first SID information to obtain a second remaining target permission bit; When the second remaining target permission bit is 0, determining that the target permission check result is a check pass; The method further comprises: When the plurality of first SID information in the user identification information cannot be successfully matched with at least one second SID information, it is determined that the target authority verification result is a verification failure.
6. The method for verifying authority information according to claim 2, characterized in that: The method further comprises: Monitoring the user identification information of the first user to determine whether the user identification information of the first user changes; When the user identification information of the first user changes, the user identification information of the first user in the user information structure is updated, and the updated user information structure is cached in the memory.
7. The method for verifying authority information according to claim 3, characterized in that: After determining the target permission verification result of the first user for the target file based on the remaining target permission bits, the method further includes: Based on the target permission verification result, determining whether the file operation request of the first user passes the verification; When it is determined that the file operation request of the first user passes the verification, allowing the first user to access the target file based on the file operation request; After it is determined that the file operation request of the first user fails verification, the first user is denied access to the target file based on the file operation request.
8. A permission information verification device, characterized in that: Applied to a distributed file system, the device comprises: The cache module is used to cache the user information structure in memory in advance; an acquisition module, configured to acquire file identification information of a target file in the distributed file system when a first user initiates a file operation request for the target file in the distributed file system, and to acquire user identification information corresponding to the first user from the user information structure; A determination module is used to determine a target permission verification result of the first user for the target file based on the file operation request, the user identification information and the file identification information.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the permission information verification method according to any one of claims 1 to 7.
10. A computer-readable medium, characterized in that A computer program is stored thereon, wherein when the computer program is executed by a processor, the permission information verification method according to any one of claims 1 to 7 is implemented.
