Function-level permission control method, device, equipment, medium and product
By introducing a function-level permission control method into dbus and dynamically configuring permission attributes, the problem of inability to implement function-level permission management in the existing technology is solved, system efficiency and security are improved, and resource waste and security risks are avoided.
Patent Information
- Application Number
- CN202410573902.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-05-10
AI Technical Summary
Existing technology cannot implement function-level permission control, resulting in low system operation efficiency and security risks. SELinux's process-level permission management cannot be refined to the function level, resulting in a waste of resources and performance.
Adopting a permission control method based on function level, by receiving API call requests, querying the permission attributes of target functions and services, performing service-level and function-level permission verification, and dynamically configuring permission attributes to achieve refined control and avoid user-mode configuration files be modified.
Function-level permission control is implemented, which improves system operation efficiency, reduces resource and performance waste, enhances security, and avoids the risk of special permissions bypassing security control.
Smart Images

Figure CN118133266B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security management and control technology, and in particular to a function-level-based permission management method, device, equipment, medium and product. Background Art
[0002] In the operating system, dbus (inter-process communication mechanism optimized for desktop environment) provides powerful and flexible cross-process communication functions. Among them, for some security-related services, the API provided by the service needs to be called by authorized clients, so it is necessary to control the permissions of API call requests.
[0003] dbus itself provides a set of security control solutions, which controls the client's calls to related APIs by setting corresponding service permissions in the configuration file. The configuration file provided by dbus can control whether the user can start the service, whether to send messages to the service or an interface under the service, and can be further refined to send messages to certain functions of the interface. However, the user-mode configuration file can be modified, thereby bypassing the security control of service calls, bringing certain security risks.
[0004] At present, in order to prevent the configuration in the configuration file from being modified, dbus has further adapted SELinux (Security-Enhanced Linux). By modifying the internal code of dbus, it supports SELinux to control whether a service can be started based on a certain service name, and it can also control the message sent by process A to process B, putting the permission check in the kernel state, and also avoiding the possibility of user state configuration files being modified. However, the message sending in SELinux is based on the process, and it cannot be based on the function name. That is, SELinux is a permission management method based on the process. For some processes that only need to run a few functions, once they are intercepted, the entire process cannot be executed, resulting in the inability to execute the function, which will greatly reduce the operating efficiency of the system. Summary of the invention
[0005] The present invention provides a method, device, equipment, medium and product based on function-level permission control, which are used to solve the defect that function-level permission control cannot be achieved in the prior art and realize function-level permission control.
[0006] The present invention provides a function-level permission management method, which is applied to a server, and the method includes:
[0007] Receive an API call request sent by a client, and determine a target function to be accessed based on the API call request;
[0008] Querying the server for a first function control attribute of the target function;
[0009] If the first function control attribute is not found, performing service-level permission control on the API call request;
[0010] If the first function control attribute is found, query the client for a second function control attribute for the target function;
[0011] If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result;
[0012] If the first permission check result is that the permission is granted, the API call request is routed to the target service accessed by the API call request.
[0013] According to a function-level permission control method provided by the present invention, the service-level permission control of the API call request includes:
[0014] Querying the first permission control attribute of the server for the target service;
[0015] If the first permission control attribute is not found, routing the API call request to the target service;
[0016] If the first permission control attribute is found, query the second permission control attribute of the client for the target service;
[0017] If the second permission control attribute is found, based on the first permission control attribute and the second permission control attribute, the API call request is subjected to permission verification to obtain a second permission verification result;
[0018] If the second permission check result is that the permission is granted, the API call request is routed to the target service.
[0019] According to a function-level permission management method provided by the present invention, the querying of the second permission management attribute of the client for the target service includes:
[0020] Based on the first socket sent by the client, query the second permission control attribute of the client for the target service;
[0021] There is a reference between the first Socket and the second Socket of the client itself, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the server can query the second permission control attribute based on the first Socket.
[0022] According to a function-level permission control method provided by the present invention, the first permission control attribute is generated based on the following method:
[0023] Obtaining extended attributes configured on the file corresponding to the target service;
[0024] Based on the extended attribute, determining a first keyword for searching a hash table;
[0025] If the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission control attribute;
[0026] If the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute.
[0027] According to a function-level permission control method provided by the present invention, the querying of the first function control attribute of the server for the target function includes:
[0028] Determining a file name based on the objective function;
[0029] Query the target file corresponding to the file name;
[0030] If the target file is found, query whether the target file is configured with the first function control attribute;
[0031] If the target file is not found, the first function control attribute is not found;
[0032] The first function control attribute is configured based on the following method:
[0033] Determine a target function for configuring the first function control attribute, and determine a file name based on the target function;
[0034] Create a target file corresponding to the file name;
[0035] The first function control attribute is configured for the target file so that the first function control attribute is an extended attribute of the target file.
[0036] The present invention also provides a function-level permission management method, which is applied to a client, and the method includes:
[0037] Sending an API call request to a server, so that the server can perform permission verification on the API call request;
[0038] The server verifies the API call request based on the following method:
[0039] Determine the target function to be accessed based on the API call request;
[0040] Querying the server for a first function control attribute of the target function;
[0041] If the first function control attribute is not found, performing service-level permission control on the API call request;
[0042] If the first function control attribute is found, query the client for a second function control attribute for the target function;
[0043] If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result;
[0044] If the first permission check result is that permission is granted, routing the API call request to the target service accessed by the API call request;
[0045] If the server finds the second function control attribute, the sending of the API call request to the server further includes:
[0046] Sending the second function control attribute of the client to the server.
[0047] The present invention also provides a function-level permission control device, which is deployed on a server side, and includes:
[0048] A request receiving module, used to receive an API call request sent by a client, and determine a target function to be accessed based on the API call request;
[0049] A first query module, used to query the server for a first function control attribute of the target function;
[0050] A permission control module, configured to perform service-level permission control on the API call request if the first function control attribute is not found;
[0051] A second query module is configured to query the client for a second function control attribute for the target function if the first function control attribute is found;
[0052] a permission verification module, configured to, if the second function control attribute is queried, perform a function-level permission verification on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission verification result;
[0053] A request routing module is used to route the API call request to the target service accessed by the API call request if the result of the first permission check is that the request is authorized.
[0054] The present invention also provides a function-level permission control device, which is deployed on a client, and includes:
[0055] A request sending module, used to send an API call request to a server, so that the server can perform permission verification on the API call request;
[0056] The server verifies the API call request based on the following method:
[0057] Determine the target function to be accessed based on the API call request;
[0058] Querying the server for a first function control attribute of the target function;
[0059] If the first function control attribute is not found, performing service-level permission control on the API call request;
[0060] If the first function control attribute is found, query the client for a second function control attribute for the target function;
[0061] If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result;
[0062] If the first permission check result is that permission is granted, routing the API call request to the target service accessed by the API call request;
[0063] If the server queries the second function control attribute, the device further includes:
[0064] The attribute sending module is used to send the second function control attribute of the client to the server.
[0065] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements any of the function-level-based permission management methods described above.
[0066] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the function-level permission management methods described above.
[0067] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned function-level-based permission management methods.
[0068] The function-level permission control method, device, equipment, medium and product provided by the present invention receive an API call request sent by a client, determine the target function to be accessed based on the API call request, query the first function control attribute of the server for the target function, and if the first function control attribute is not queried, perform service-level permission control on the API call request, so that when the first function control attribute is not configured, it is confirmed that the server does not perform permission control on the target function, and the service-level permission control can be directly performed, that is, if there is no configuration, it is assumed that there is no function-level permission control. Only when the first function control attribute is queried, the second function control attribute of the client for the target function is queried, that is, only when the first function control attribute is configured, it is confirmed that the server performs permission control on the target function, and then it is necessary to perform function-level permission verification on the client's API call request, so that all functions do not need to be labeled, and only the first function control attribute needs to be configured for the function that needs permission control, thereby reducing waste of resources and performance and improving system performance; if the second function control attribute is queried, the API call request is subjected to function-level permission verification based on the first function control attribute and the second function control attribute to obtain a first permission verification result, thereby reducing waste of resources and performance and improving system performance. In summary, the embodiments of the present invention can implement function-level permission management and control, thereby improving the operating efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0070] Figure 1One of the flow charts of the function-level permission control method provided by the present invention;
[0071] Figure 2 The second flowchart of the function-level permission control method provided by the present invention;
[0072] Figure 3 A schematic diagram of the structure of the function-level permission control device provided by the present invention;
[0073] Figure 4 This is a schematic structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0075] In the operating system, dbus (inter-process communication mechanism optimized for desktop environment) provides powerful and flexible cross-process communication functions. Among them, for some security-related services, the API provided by the service needs to be called by authorized clients, so it is necessary to control the permissions of API call requests.
[0076] dbus itself provides a set of security control solutions, which controls the client's calls to related APIs by setting corresponding service permissions in the configuration file. The configuration file provided by dbus can control whether the user can start the service, whether the user can send messages to the service or an interface under the service, and can be further refined to send messages to certain functions of the interface. However, the user-mode configuration file can be modified, thereby bypassing the security control of service calls and bringing certain security risks. For example, due to the special permissions of some special accounts (such as the root account) of the operating system, the configuration in the configuration file can also be modified directly, that is, the root account can be used to directly modify the configuration in the configuration file.
[0077] For ease of understanding, take the service configuration as an example, the corresponding dbus configuration file is as follows:
[0078] “ <busconfig>
[0079] <policy context="default">
[0080] / / Configuration 1
[0081] <deny own=" " / >
[0082] < / policy>
[0083] <policy user="root">
[0084] / / Configuration 2
[0085] <deny own=" " / >
[0086] <allow own="Rose.LocalPropertyRepository" / >
[0087] / / Configuration 3
[0088] <deny send_destination="Rose.LocalPropertyRepository" / >
[0089] <alow send_destination="Rose.LocalPropertyRepository"
[0090] send_interface="Rose.LocalPropertyRepository.Internal" / >
[0091] / / Configuration 4
[0092] <selinux>
[0093] <associate own="Rose.LocalPropertyRepository" context="system_u:object_r:service_own_name_t:s0" / >
[0094] < / selinux>
[0095] < / policy>
[0096] < / busconfig> ”.
[0097] Among them, configuration 1 means that ordinary users cannot start the service. It uses deny to deny the start of any service name. Configuration 2 means that the root user can start the service, but can only start the service with the service name "Rose.LocalPropertyRepository". It first denies all services through deny, and then uses allow to start the service with the service name "Rose.LocalPropertyRepository". Configuration 3 means that messages can only be sent to the "Rose.LocalPropertyRepository.Internal" interface under the "Rose.LocalPropertyRepository" service, and messages cannot be sent to other interfaces under the service. Configuration 4 means that SELinux is used to control the permission to start the service and the permission to send messages. Whether it can be started based on the "Rose.LocalPropertyRepository" service name is determined by the "service_own_name_t" label.
[0098] At present, in order to prevent the configuration in the configuration file from being modified, dbus has further adapted SELinux (Security-Enhanced Linux). SELinux is an implementation of MAC (Mandatory Access Control). It uses security policies to enforce the access allowed by the system. Under the restrictions of this access control system, the process can only access the resources required in its task, and the resources outside the allowed range will be prohibited by the system. By modifying the internal code of dbus, it supports SELinux to control whether the service can be started based on a certain service name, and it can also control the message sending from process A to process B, putting the permission check in the kernel state, and also avoiding the possibility of the user state configuration file being modified. However, the message sending in SELinux is based on the process, and it cannot be based on the function name. That is, SELinux is a permission management method based on the process. For some processes that only need to run a few functions, once they are intercepted, the entire process cannot be executed, resulting in the inability to execute the function, which will greatly reduce the operating efficiency of the operating system.
[0099] In addition, the whitelist mechanism easily leads to waste of resources. Since SELinux is directly introduced, assuming that SELinux is used to control the sending of messages, for example, authorization is required to send a message to process B. If process A needs to send a message to process B, then process A can be labeled with the authorized blksec_clt_send_t label set. However, due to the introduction of SELinux, the entire system needs to be labeled. At this time, if the system has no other control requirements, it will lead to waste of resources. Although it is possible to label with default permissions, these additional labels will also lead to waste of resources and performance.
[0100] In view of the above problems, the present invention proposes the following embodiments. Figure 1 One of the flow charts of the function-level permission control method provided by the present invention is as follows: Figure 1 As shown, the function-level permission control method applied to the server includes:
[0101] Step 110: Receive an API call request sent by a client, and determine a target function to be accessed based on the API call request.
[0102] Here, the API call request is used to call the API of the accessed target function. In one embodiment, the client sends the API call request to the target service service of the server; first, the API call request is sent to the service daemon, and then routed to the target service service.
[0103] Step 120: query the server for a first function control attribute of the target function.
[0104] If there is permission control for the target function, the first function control attribute is configured for the target function, so that the first function control attribute can be queried; if there is no permission control for the target function, the first function control attribute is not configured for the target function, so that the first function control attribute cannot be queried.
[0105] In one embodiment, the first function control attribute is configured on the file, that is, the first function control attribute is an extended attribute on the file, so as to realize dynamic configuration of the first function control attribute, that is, realize dynamic labeling. Compared with static labels, dynamic labeling can be performed on the target function.
[0106] Step 130: If the first function control attribute is not found, perform service-level permission control on the API call request.
[0107] Specifically, if the first function control attribute is not found, it means that the server does not perform permission control on the target function, so service-level permission control can be directly performed on the API call request.
[0108] Step 140: If the first function control attribute is found, query the client for a second function control attribute for the target function.
[0109] Specifically, if the first function control attribute is queried, it means that the server needs to perform permission control on the target function. Therefore, the client is queried for the second function control attribute of the target function to perform function-level permission check on the client's API call request to determine whether to route the API call request to the target service.
[0110] If the client does not have permission to access the target function, the client will not be configured with the second function control attribute for the target function, so that if the second function control attribute cannot be queried, the API call request will be refused to be routed to the target service; if the client has permission to access the target function, the client will be configured with the second function control attribute for the target function, so that if the second function control attribute is queried, based on the first function control attribute and the second function control attribute, a function-level permission check will be performed on the API call request to determine whether the client has permission to access the target function.
[0111] In one embodiment, the second function control attribute is configured on the file of the client, that is, the second function control attribute is an extended attribute on the file, so as to realize dynamic configuration of the second function control attribute, that is, to realize dynamic labeling. Compared with static labeling, dynamic labeling can be performed on the target function.
[0112] Step 150: If the second function control attribute is found, a function-level permission check is performed on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission check result.
[0113] It should be understood that if the second function control attribute is queried, it means that the second function control attribute is obtained from the client.
[0114] Specifically, a function-level permission check is performed on the API call request based on the kernel state, that is, the permission check itself must fall into the kernel state, and the kernel state returns the first permission check result. It should be understood that the permission control of cross-process communication is implemented based on the MAC mechanism, so that the permission check for the client application calling the service is completed in the kernel state, which solves the possibility of user-state configuration files being modified, avoids potential problems such as bypassing the security control mechanism through special permission accounts, and improves the security of permission control. In other words, based on MAC, there is no function-level permission control by default. Only when the function control attributes are configured can there be permission control, and the judgment of permissions is completed in the kernel state.
[0115] Step 160: If the first permission check result is that the user has permission, the API call request is routed to the target service accessed by the API call request.
[0116] If the first permission check result is permission, the API call request can be routed to the target service for the target service to respond to the API call request; if the first permission check result is no permission, the API call request is refused to be routed to the target service, that is, the API call request is refused to be responded to.
[0117] It should be understood that there are two scenarios for function-level permission control. The first is that the server itself only needs service-level permission control, but some functions need function-level permission control; the second is that only a few functions on the server itself need permission control, and other interfaces do not need control. Therefore, function-level permission control of API call requests can achieve more refined permission control, so that for some processes that only need permission control for a few functions, it is first determined whether there is permission control for individual functions in the process. Only if it is configured, it needs to be controlled, and there is no need to perform permission control on the entire process, which solves the problem of low operating efficiency caused by process-level control in the operating system.
[0118] It should be understood that function-level security control does not exclude service-level security control. Function-level security control is used first. When function-level security control does not exist, service-level security control is tried. When service-level security control also does not exist, permissions are relaxed.
[0119] The function-level permission control method provided by the embodiment of the present invention receives an API call request sent by a client, determines the target function to be accessed based on the API call request, queries the first function control attribute of the server for the target function, and performs service-level permission control on the API call request if the first function control attribute is not queried. Thus, when the first function control attribute is not configured, it is confirmed that the server does not perform permission control on the target function, and the service-level permission control can be directly performed, that is, if there is no configuration, there is no function-level permission control by default. Only when the first function control attribute is queried, the second function control attribute of the client for the target function is queried, that is, only when the first function control attribute is configured, it is confirmed that the server performs permission control on the target function, and then it is necessary to perform function-level permission verification on the API call request of the client, so that all functions do not need to be labeled, and only the first function control attribute needs to be configured for the function that needs permission control, thereby reducing waste of resources and performance and improving system performance; if the second function control attribute is queried, the function-level permission verification is performed on the API call request based on the first function control attribute and the second function control attribute to obtain the first permission verification result, thereby reducing waste of resources and performance and improving system performance. In summary, the embodiments of the present invention can implement function-level permission management and control, thereby improving the operating efficiency of the system.
[0120] Based on any of the above embodiments, for example, taking sending a message to an interface under the service as an example, based on the SELinux "pre-labeling + bool variable control" mechanism, the overall message sending of process A to process B can be controlled, that is, either all messages can be sent, or all messages cannot be sent. However, SELinux performs permission control based on the whitelist mechanism, and only client objects included in the whitelist have permission to access, that is, only those that meet the configuration requirements have permission to access. Based on this, although SELinux can implement the control of client calls to services without modifying the dbus configuration file, all terminals need to be labeled for permission control of the whitelist mechanism, and some terminals do not have permission control requirements, which leads to the introduction of additional labels, which in turn causes waste of resources and performance, resulting in reduced system performance. For example, authorization is required to send a message to process B, and only process A can send a message to process B. In this case, process A can be labeled with the authorized "blksec_clt_send_t" label. Due to the introduction of SELinux, the entire system must be labeled, but the entire system actually has no other control requirements. Although the default permissions can be released, these additional labels are also a waste of resources and performance. Based on this, Figure 2 The second flowchart of the function-level permission control method provided by the present invention is as follows: Figure 2As shown, in the above step 130, the service-level permission control of the API call request includes:
[0121] Step 131: query the server for a first permission control attribute of the target service.
[0122] If there is permission control for the target service, the first permission control attribute is configured for the target service, so that the first permission control attribute can be queried; if there is no permission control for the target service, the first permission control attribute is not configured for the target service, so that the first permission control attribute cannot be queried.
[0123] In one embodiment, the first permission control attribute is configured on the file corresponding to the target service, that is, it is configured on the process file corresponding to the target service, that is, the first permission control attribute is an extended attribute on the file, thereby realizing dynamic configuration of the first permission control attribute, that is, realizing dynamic labeling. Compared with static labels, dynamic labeling can be performed on the target service.
[0124] In one embodiment, based on the first Socket sent by the client, the server is queried for the first permission control attribute of the target service. There is a reference between the first Socket and the second Socket of the client itself, and the first Socket stores the first permission control attribute, so the first permission control attribute can be queried based on the first Socket sent by the client.
[0125] Step 132: If the first permission management attribute is not found, the API call request is routed to the target service.
[0126] Specifically, if the first permission control attribute is not found, it means that the server does not perform permission control on the target service, so the API call request can be directly routed to the target service for the target service to respond to the API call request.
[0127] Step 133: If the first permission control attribute is found, query the second permission control attribute of the client for the target service.
[0128] Specifically, if the first permission control attribute is queried, it means that the server needs to perform permission control on the target service, so a service-level permission check is performed on the client's API call request to determine whether to route the API call request to the target service.
[0129] If the client does not have permission to access the target service, the client will not be configured with the second permission control attribute for the target service, so that if the second permission control attribute cannot be queried, the API call request will be refused to be routed to the target service; if the client has permission to access the target service, the client will be configured with the second permission control attribute for the target service, so that if the second permission control attribute is queried, the API call request will be checked for permission based on the first permission control attribute and the second permission control attribute to determine whether the client has permission to access the target service.
[0130] In one embodiment, the second permission control attribute is configured on the corresponding process file in the client, that is, the second permission control attribute is an extended attribute on the file, thereby realizing dynamic configuration of the second permission control attribute, that is, realizing dynamic labeling, which can dynamically label the target service compared to static labels.
[0131] Step 134: If the second permission control attribute is found, a permission check is performed on the API call request based on the first permission control attribute and the second permission control attribute to obtain a second permission check result.
[0132] It should be understood that if the second permission control attribute is queried, it means that the second permission control attribute is obtained from the client.
[0133] Specifically, the permission check of API call request is performed based on kernel state, that is, the permission check itself must fall into kernel state, and the permission check result is returned by kernel state. It should be understood that the permission control of cross-process communication is implemented based on the MAC mechanism, so that the permission check of client application calling service is completed in kernel state, which solves the possibility of user state configuration files being modified, avoids potential problems such as bypassing the security control mechanism through special permission accounts, and improves the security of permission control.
[0134] Step 135: If the second permission check result is authorized, route the API call request to the target service.
[0135] If the permission check result is authorized, the API call request can be routed to the target service for the target service to respond to the API call request; if the permission check result is unauthorized, the API call request is refused to be routed to the target service, that is, the API call request is refused to be responded to.
[0136] It should be understood that through the above method, the idea of a blacklist mechanism is introduced on the basis of the original whitelist mechanism, that is, there is no permission control by default, and permission control is available only after configuration, which can effectively solve the resource waste problem of SELinux implementing "dynamic" permission control based on bool variables.
[0137] The function-level permission control method provided by the embodiment of the present invention queries the first permission control attribute of the server for the target service. If the first permission control attribute is not queried, the API call request is routed to the target service, so that when the first permission control attribute is not configured, it is confirmed that the server does not perform permission control on the target service, and the API call request can be directly routed to the target service, that is, if there is no configuration, there is no permission control by default. Only when the first permission control attribute is queried, the permission check is performed on the API call request of the client, that is, only when the first permission control attribute is configured, it is confirmed that the server performs permission control on the target service, and then the permission check is required for the API call request of the client, so that all terminals and services do not need to be labeled, and only the first permission control attribute needs to be configured for the service that requires permission control, thereby reducing waste of resources and performance and improving system performance; if the second permission control attribute is queried, the service-level permission check is performed on the API call request based on the first permission control attribute and the second permission control attribute to obtain the second permission check result, thereby reducing waste of resources and performance and improving system performance.
[0138] Based on any of the above embodiments, in the method, in the above step 133, querying the second permission control attribute of the client for the target service includes:
[0139] Based on the first socket sent by the client, query the second permission control attribute of the client for the target service;
[0140] There is a reference between the first Socket and the second Socket of the client itself, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the server can query the second permission control attribute based on the first Socket.
[0141] Specifically, the process usually communicates based on Socket. In order to perform permission control on the socket, the first permission control attribute or the second permission control attribute stored in the socket can directly inherit the first permission control attribute or the second permission control attribute of the process. That is, the first permission control attribute or the second permission control attribute is directly saved to the security member variable of the socket.
[0142] In a specific embodiment, when the process file is opened to create an inode, the first permission control attribute or the second permission control attribute is saved to the security member variable of the inode; when the process is started, the first permission control attribute or the second permission control attribute of the inode is saved to the process context; a Socket is created inside the process, and the first permission control attribute or the second permission control attribute of the process context is saved to the Socket. The above can be processed by a security hook function. Among them, since the process has a process context, many controls are based on the process. In order to facilitate indexing, the first permission control attribute or the second permission control attribute of the inode is saved to the process context.
[0143] Considering that the above only completes the inheritance of the first permission control attribute or the second permission control attribute of the process to Socekt, but the communication between Sockets is mutual communication, and the control itself also requires two objects, the subject and the object, so the two sides of the Socket are just the relationship between the subject and the object. Based on this, in order to improve the communication performance of the Socket, a reference is set between the first Socket and the second Socket of the client itself, thereby improving the query efficiency of the first permission control attribute or the second permission control attribute, and then improving the efficiency and performance of permission control.
[0144] It should be noted that in order to enable the permission control attributes of both parties of permission control (i.e., the client and the server) to be immediately found from their own Socket data structure, and in addition to knowing their own permission control attributes, they also need to know the permission control attributes of the other party. Therefore, a reference is set between the first Socket and the second Socket of the client itself to improve the query efficiency of the permission control attributes, thereby improving the efficiency and performance of permission control.
[0145] The server performs Socket communication with the client through the first Socket sent by the client.
[0146] In a specific embodiment, the client actively connects to the server through a Socket, that is, the user state triggers the call to connect, and the server user state triggers the call to accept to receive the connection; when the client connects, the previous Socket (cltsock) is searched out according to fd (FileDescriptor, file descriptor), and the second permission control attribute is obtained from cltsock for security, and the client needs to create a brand new first Socket (newsk), which is to complete point-to-point communication with the server. A client can create multiple point-to-points with the server, so multiple newsks will be created; newsk will eventually be sent to the server, and the final communication after the connection is successful occurs between cltsock->sk and newsk, so there is a reference between the first Socket and the second Socket of the client itself, for example, through peer reference, sk->peer=newsk, newsk->peer=sk; sk (second Socket) and newsk (first Socket) can access each other, which also enables them to communicate directly with each other, and the permission verification information before communication is also saved in sk and newsk. Based on this, after completing the mutual reference, both the client and the server can complete the permission verification. To make it easier to understand the references, they are as follows:
[0147] sk->blksec_id = blksec_id of the client process (second permission control attribute);
[0148] newsk->blksec_id=blksec_id of the server process (the first permission control attribute);
[0149] sk->peer_blksec_id=newsk->blksec_id;
[0150] newsk->peer_blksec_id=sk->blksec_id.
[0151] In addition, it should be noted that the second Socket can be found in the client process through the client's fd, and the server process can eventually find the first Socket through the newly created fd, so the user state can complete mutual communication based on fd, and can also complete mutual permission control.
[0152] It should be understood that the first Socket and the second Socket point to each other, so that each can quickly obtain the permission control attributes of the other, thereby improving the query efficiency of the permission control attributes, and thus improving the efficiency and performance of permission control.
[0153] It should be understood that since the first permission control attribute and the second permission control attribute are permission control attributes of two processes, verifying the permissions between Socket communications is actually verifying whether Socket communication can be performed between the two processes.
[0154] The function-level permission management method provided in the embodiment of the present invention queries the second permission management attribute of the client for the target service based on the first Socket sent by the client, and there is a reference between the first Socket and the second Socket of the client itself, so that the second permission management attribute of the other party can be quickly queried, thereby improving the query efficiency of the second permission management attribute, thereby improving the efficiency and performance of permission management.
[0155] Based on any of the above embodiments, in this method, the first permission control attribute is generated based on the following method:
[0156] Obtaining extended attributes configured on the file corresponding to the target service;
[0157] Based on the extended attribute, determining a first keyword for searching a hash table;
[0158] If the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission control attribute;
[0159] If the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute.
[0160] Considering that in the prior art, SELinux is statically labeled, that is, it must set application labels in advance, and cannot do dynamic labeling, that is, it cannot flexibly solve the problem of dynamically setting permission control. For example, it is impossible to know in advance how many clients send messages to process B. Since SELinux must statically label in advance, it can only define the number of labels in advance, such as 128; and dynamic control needs to be implemented based on bool variables. Due to limited label resources, these labels can only be statically planned according to the existing applications in the system, such as application 1 is labeled 1, application 2 is labeled 2, and application 128 is labeled 128. During the operation, the value of the bool variable is modified to control their permission to send messages to process B. However, there are far more than 128 applications, and there is a problem of insufficient number of labels. These 128 applications do not necessarily call the service to send messages to process B. Such a whitelist static planning label mechanism will cause huge waste of resources. Based on this, the extended attributes configured on the file corresponding to the target service are obtained to implement dynamic labeling, that is, dynamically configure the extended attributes on the file according to actual needs, that is, realize the function of dynamically labeling the application, and flexibly solve the problem of insufficient number of labels and difficulty in effective planning. Correspondingly, the kernel also needs to dynamically add extended attributes, that is, the kernel needs to support the mechanism of dynamically adding extended attributes and parsing these attributes according to needs, and the newly added permissions can only be given to specific security service processes.
[0161] Specifically, the extended attributes configured on the process file corresponding to the target service are obtained. In a specific embodiment, when the process file is loaded, that is, when the target service (process) is started, the file system supports reading and writing extended attributes; when the process is opened, the system function is called to call the corresponding security hook function, that is, the execution process will call the kernel's do_filp_open function, and finally call the security opening hook function, which only needs to register its own security hook based on the kernel's LSM (Linux Security Module) mechanism; the security hook function reads the extended attribute; if this extended attribute exists, it means that permission control is required, and the value of the extended attribute is read.
[0162] Exemplarily, if the extended attribute is "system_u:object_r:blksec_srv_1_t:s0", the extended attribute is used as the first keyword for searching the hash table.
[0163] Furthermore, the first permission control attribute is saved in the security member variable of the inode. Since the parsing of the extended attribute occurs when the process file is first loaded, this is also the moment when the inode node of the file is created. Therefore, the parsed extended attribute value is saved in the data structure corresponding to the inode node. Since it is saved in the data structure corresponding to the inode node, it only needs to be parsed once, ensuring performance. In other words, no matter how many times the file is opened, only one unique inode will be created, and the extended attribute only needs to be parsed once. Therefore, the permission control attribute is parsed from the extended attribute and saved in the security member variable in the inode.
[0164] Furthermore, since the target service is a process, the first permission control attribute is further saved to the security member variable of the process context when the kernel initializes the process, so that the first permission control attribute can be retrieved when the process performs socket communication as a subject.
[0165] Furthermore, the security hook function is only a hook function in the entire opening process when the process is opened. After the security hook function is called, it needs to return to the function that called it. In any case, it returns OK, because the extended attributes are not necessary. The basic principle of this security module is to control only when they are set.
[0166] It should be noted that the generation method of the second permission control attribute is basically the same as the generation method of the first permission control attribute, which will not be repeated here.
[0167] The function-level permission management method provided in the embodiment of the present invention obtains the extended attributes configured on the file corresponding to the target service to realize dynamic labeling, that is, dynamically configures the extended attributes on the file according to actual needs, that is, realizes the function of dynamically labeling the application, and flexibly solves the problem of insufficient number of labels and difficulty in effective planning; based on the extended attributes, determines the first keyword for searching the hash table, if the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission management attribute, if the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute, thereby converting the extended attribute into the first permission management attribute of an integer value through the hash table, improving the query efficiency of the first permission management attribute, and then improving the efficiency and performance of permission management.
[0168] Based on any of the above embodiments, in the method, determining the first keyword for searching the hash table based on the extended attribute includes:
[0169] Splitting the extended attribute according to type to obtain multiple attributes;
[0170] Using the multiple attributes as second keywords for searching the hash table respectively;
[0171] Searching the hash table based on each of the second keywords to determine a target position of each of the second keywords in the hash table;
[0172] The first keyword is determined based on the integer value of each of the target positions.
[0173] Exemplarily, the extended attribute is "system_u:object_r:blksec_srv_1_t:s0", and the extended attribute is split according to the types user, role, type, and class to obtain multiple attributes system_u, object_r, blksec_srv_1_t, and s0; the multiple attributes system_u, object_r, blksec_srv_1_t, and s0 are respectively used as the second keyword key, and their positions are found in the hash table, and the target position of each second keyword in the hash table is their corresponding integer value; the integer value of each target position is encapsulated into a security context, which includes the integer value of each target position, and the security context is used as the first keyword.
[0174] The function-level permission management method provided by the embodiment of the present invention only needs to maintain multiple attributes divided by type in the hash table in the above manner, so that more first keywords can be obtained by combining multiple attributes. Compared with directly maintaining all first keywords in the hash table, the embodiment of the present invention can reduce the number of hash table configurations, thereby reducing the cost of permission management.
[0175] Based on any of the above embodiments, in the method, the above step 120 includes:
[0176] Determining a file name based on the objective function;
[0177] Query the target file corresponding to the file name;
[0178] If the target file is found, query whether the target file is configured with the first function control attribute;
[0179] If the target file is not found, the first function control attribute is not found.
[0180] Accordingly, the first function control attribute is configured based on the following method:
[0181] Determine a target function for configuring the first function control attribute, and determine a file name based on the target function;
[0182] Create a target file corresponding to the file name;
[0183] The first function control attribute is configured for the target file so that the first function control attribute is an extended attribute of the target file.
[0184] Specifically, the file name is determined based on the function name of the target function, so that the target file corresponding to the file name can be queried based on the target function.
[0185] In a specific embodiment, the file name is composed of process name + service name + interface name + function name, for example, the file name is Net_Net_NetCard_getMAC.blksec. Based on this pre-set rule, the file name can be determined based on the target function. The file name is added with the service name and the interface name to prevent conflicts when the function names are the same.
[0186] It should be understood that function-level permission control requires generating a target file based on the function name of the target function, and the corresponding file will be found based on the function name when sending an API call request. The first function control attribute at the function level supports dynamic setting, and can also be configured in advance, that is, setting the extended attribute to the file corresponding to the function name.
[0187] For example, in the server, set the function control attribute of calling the getMAC function; create the following file Net_Net_NetCard_getMAC.blksec under a writable directory (such as / etc / blksec); set the function control attribute for the Net_Net_NetCard_getMAC.blksec file, such as the function control attribute is blksec_service_1_t. In the client, set the function control attribute of calling the getMAC function; create the following file Net_Net_NetCard_getMAC.blksec under a writable directory (such as / etc / blksec); set the function control attribute for the Net_Net_NetCard_getMAC.blksec file, such as the function control attribute is blksec_client_1_t. From the settings of the server and the client, we can see that their processes are basically the same, and the difference in the file name is only the difference in the process name. The file name corresponding to the server function is tagged with the server type, such as blksec_service_1_t, and the client is tagged with the corresponding tag blksec_client_1_t. Since there can be many functions under control, such tags can be applied in batches. They are usually in pairs. Different client processes have the same tag for the same function, such as blksec_client_1_t.
[0188] Considering that in the prior art, SELinux is statically labeled, that is, it must set the application label in advance, and cannot achieve dynamic labeling, that is, it cannot flexibly solve the problem of dynamically setting permission control. Based on this, the target function of the first function control attribute to be configured is determined, the file name is determined based on the target function, and the target file corresponding to the file name is created to configure the first function control attribute for the target file, so as to realize dynamic labeling, that is, dynamically create files according to actual needs and configure extended attributes on the files, that is, realize the function of dynamically labeling functions, and flexibly solve the problem of insufficient number of labels and difficulty in effective planning.
[0189] It should be noted that the configuration method of the second function control attribute is basically the same as the configuration method of the first function control attribute, which will not be repeated here.
[0190] The function-level permission control method provided by the embodiment of the present invention creates a corresponding file for the function that needs to be controlled in the above manner, then labels the file, takes out the label of the client process when judging whether a message can be sent to the function, and then takes out the label of the file corresponding to the function name, and judges the permissions between the two labels, thereby achieving dynamic permission control at the function level and realizing dynamic labeling, that is, dynamically creating files according to actual needs and configuring extended attributes on the files, that is, realizing the function of dynamically labeling, and flexibly solving the problem of insufficient number of labels and difficulty in effective planning.
[0191] Based on any of the above embodiments, the present invention further provides a function-level permission control method applied to a client, and the function-level permission control method applied to a client includes:
[0192] Send an API call request to the server so that the server can perform permission verification on the API call request.
[0193] Among them, the server performs permission verification on the API call request based on the following method: determining the target function to be accessed based on the API call request; querying the server for the first function control attribute of the target function; if the first function control attribute is not queried, performing service-level permission control on the API call request; if the first function control attribute is queried, querying the client for the second function control attribute of the target function; if the second function control attribute is queried, based on the first function control attribute and the second function control attribute, performing function-level permission verification on the API call request to obtain a first permission verification result; if the first permission verification result is permission, routing the API call request to the target service accessed by the API call request.
[0194] Correspondingly, if the server queries the second function control attribute, the sending of the API call request to the server further includes:
[0195] Sending the second function control attribute of the client to the server.
[0196] Here, the steps of the server performing permission verification on the API call request can refer to the above embodiments, which will not be repeated here. It should be understood that the client can also act as a server and execute the steps of the server.
[0197] The function-level permission control method provided by the embodiment of the present invention sends an API call request to the server, so that the server determines the target function to be accessed based on the API call request, queries the server for the first function control attribute for the target function, and performs service-level permission control on the API call request if the first function control attribute is not queried, thereby confirming that the server does not perform permission control on the target function without configuring the first function control attribute, and can directly perform service-level permission control, that is, if there is no configuration, it is assumed that there is no function-level permission control, and only when the first function control attribute is queried, the second function control attribute of the client for the target function is queried, that is, only when the first function control attribute is configured, it is confirmed that the server performs permission control on the target function, and then it is necessary to perform function-level permission verification on the client's API call request, so that all functions do not need to be labeled, and only the first function control attribute needs to be configured for the function that requires permission control, thereby reducing waste of resources and performance and improving system performance; if the second function control attribute is queried, the API call request is subjected to function-level permission verification based on the first function control attribute and the second function control attribute to obtain the first permission verification result, thereby reducing waste of resources and performance and improving system performance. In summary, the embodiments of the present invention can implement function-level permission management and control, thereby improving the operating efficiency of the system.
[0198] The following is a description of the function-level-based permission control device provided by the present invention. The function-level-based permission control device described below and the function-level-based permission control method described above can be referenced to each other.
[0199] Figure 3 A schematic diagram of the structure of the function-level permission control device provided by the present invention is shown in FIG. Figure 3 As shown, the function-level permission control device deployed on the server side includes:
[0200] The request receiving module 310 is used to receive an API call request sent by a client, and determine a target function to be accessed based on the API call request;
[0201] A first query module 320, configured to query the server for a first function control attribute of the target function;
[0202] The permission control module 330 is used to perform service-level permission control on the API call request if the first function control attribute is not found;
[0203] A second query module 340 is configured to query the client for a second function control attribute for the target function if the first function control attribute is found;
[0204] The permission verification module 350 is configured to, if the second function control attribute is found, perform a function-level permission verification on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission verification result;
[0205] The request routing module 360 is used to route the API call request to the target service accessed by the API call request if the first permission check result is authorized.
[0206] The function-level permission control device provided by the embodiment of the present invention receives an API call request sent by a client, determines the target function accessed based on the API call request, queries the first function control attribute of the server for the target function, and performs service-level permission control on the API call request if the first function control attribute is not queried, thereby confirming that the server does not perform permission control on the target function without configuring the first function control attribute, and can directly perform service-level permission control, that is, if there is no configuration, it is assumed that there is no function-level permission control, and only when the first function control attribute is queried, the second function control attribute of the client for the target function is queried, that is, only when the first function control attribute is configured, it is confirmed that the server performs permission control on the target function, and then it is necessary to perform function-level permission verification on the client's API call request, so that all functions do not need to be labeled, and only the first function control attribute needs to be configured for the function that needs permission control, thereby reducing waste of resources and performance and improving system performance; if the second function control attribute is queried, the function-level permission verification is performed on the API call request based on the first function control attribute and the second function control attribute to obtain the first permission verification result, thereby reducing waste of resources and performance and improving system performance. In summary, the embodiments of the present invention can implement function-level permission management and control, thereby improving the operating efficiency of the system.
[0207] The function-level permission control device deployed on the client includes:
[0208] A request sending module, used to send an API call request to a server, so that the server can perform permission verification on the API call request;
[0209] The server verifies the API call request based on the following method:
[0210] Determine the target function to be accessed based on the API call request;
[0211] Querying the server for a first function control attribute of the target function;
[0212] If the first function control attribute is not found, performing service-level permission control on the API call request;
[0213] If the first function control attribute is found, query the client for a second function control attribute for the target function;
[0214] If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result;
[0215] If the first permission check result is that permission is granted, routing the API call request to the target service accessed by the API call request;
[0216] If the server queries the second function control attribute, the device further includes:
[0217] The attribute sending module is used to send the second function control attribute of the client to the server.
[0218] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 complete mutual communication through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the function-level permission control method applied to the server, the method comprising: receiving an API call request sent by a client, determining the target function to be accessed based on the API call request; querying the first function control attribute of the server for the target function; if the first function control attribute is not queried, performing service-level permission control on the API call request; if the first function control attribute is queried, querying the second function control attribute of the client for the target function; if the second function control attribute is queried, performing function-level permission check on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission check result; if the first permission check result is permission, routing the API call request to the target service accessed by the API call request. Alternatively, a function-level permission control method applied to a client is executed, the method comprising: sending an API call request to a server, so that the server performs permission verification on the API call request; wherein the server performs permission verification on the API call request in the following manner: determining the target function to be accessed based on the API call request; querying the server for a first function control attribute for the target function; if the first function control attribute is not queried, performing service-level permission control on the API call request; if the first function control attribute is queried, querying the client for a second function control attribute for the target function; if the second function control attribute is queried, performing a function-level permission verification on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission verification result; if the first permission verification result is permission, routing the API call request to the target service accessed by the API call request; if the server queries the second function control attribute, the sending of the API call request to the server also comprises: sending the second function control attribute of the client to the server.
[0219] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0220] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the function-level permission management method provided by the above methods and applied to the server, the method including: receiving an API call request sent by a client, and determining the target function to be accessed based on the API call request; querying the server for a first function control attribute of the target function; if the first function control attribute is not queried, performing service-level permission management on the API call request; if the first function control attribute is queried, querying the client for a second function control attribute of the target function; if the second function control attribute is queried, based on the first function control attribute and the second function control attribute, performing a function-level permission check on the API call request to obtain a first permission check result; if the first permission check result is permission, routing the API call request to the target service accessed by the API call request. Alternatively, a computer can execute the function-level permission control method provided by the above methods and applied to a client, the method comprising: sending an API call request to a server, so that the server performs permission verification on the API call request; wherein the server performs permission verification on the API call request in the following manner: determining the target function to be accessed based on the API call request; querying the server for a first function control attribute of the target function; if the first function control attribute is not queried, performing service-level permission control on the API call request; if the first function control attribute is queried, querying the client for a second function control attribute of the target function; if the second function control attribute is queried, performing function-level permission verification on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission verification result; if the first permission verification result is permission, routing the API call request to the target service accessed by the API call request; if the server queries the second function control attribute, sending the API call request to the server, and then further comprising: sending the second function control attribute of the client to the server.
[0221] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the function-level-based permission management method provided by the above-mentioned methods and applied to a server, the method comprising: receiving an API call request sent by a client, and determining the target function to be accessed based on the API call request; querying the server for a first function control attribute of the target function; if the first function control attribute is not queried, performing service-level permission management on the API call request; if the first function control attribute is queried, querying the client for a second function control attribute of the target function; if the second function control attribute is queried, performing a function-level permission check on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission check result; if the first permission check result is permission, routing the API call request to the target service accessed by the API call request. Alternatively, when the computer program is executed by the processor, it is implemented to execute the function-level permission control method based on the above methods and applied to the client, the method comprising: sending an API call request to the server, so that the server performs permission verification on the API call request; wherein the server performs permission verification on the API call request in the following manner: determining the target function to be accessed based on the API call request; querying the server for a first function control attribute of the target function; if the first function control attribute is not queried, performing service-level permission control on the API call request; if the first function control attribute is queried, querying the client for a second function control attribute of the target function; if the second function control attribute is queried, based on the first function control attribute and the second function control attribute, performing function-level permission verification on the API call request to obtain a first permission verification result; if the first permission verification result is permission, routing the API call request to the target service accessed by the API call request; if the server queries the second function control attribute, sending the API call request to the server, and then also comprising: sending the second function control attribute of the client to the server.
[0222] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0223] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0224] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for controlling permissions based on function level, characterized in that: Applied to the server, the method includes: Receive an API call request sent by a client, and determine a target function to be accessed based on the API call request; Querying the server for a first function control attribute of the target function; If the first function control attribute is not found, performing service-level permission control on the API call request; If the first function control attribute is found, query the client for a second function control attribute for the target function; If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result; If the first permission check result is that permission is granted, routing the API call request to the target service accessed by the API call request; The querying the server for the first function control attribute of the target function includes: Determining a file name based on the objective function; Query the target file corresponding to the file name; If the target file is found, query whether the target file is configured with the first function control attribute; If the target file is not found, the first function control attribute is not found; The first function control attribute is configured based on the following method: Determine a target function for configuring the first function control attribute, and determine a file name based on the target function; Create a target file corresponding to the file name; The first function control attribute is configured for the target file so that the first function control attribute is an extended attribute of the target file.
2. The function-level permission control method according to claim 1 is characterized in that: The service-level permission control of the API call request includes: Querying the first permission control attribute of the server for the target service; If the first permission control attribute is not found, routing the API call request to the target service; If the first permission control attribute is found, query the second permission control attribute of the client for the target service; If the second permission control attribute is found, based on the first permission control attribute and the second permission control attribute, the API call request is subjected to permission verification to obtain a second permission verification result; If the second permission check result is that the permission is granted, the API call request is routed to the target service.
3. The function-level permission control method according to claim 2 is characterized in that: The querying the second permission control attribute of the client for the target service includes: Based on the first socket sent by the client, query the second permission control attribute of the client for the target service; There is a reference between the first Socket and the second Socket of the client itself, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the server can query the second permission control attribute based on the first Socket.
4. The function-level permission control method according to claim 2 is characterized in that: The first permission control attribute is generated based on the following method: Obtaining extended attributes configured on the file corresponding to the target service; Based on the extended attribute, determining a first keyword for searching a hash table; If the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission control attribute; If the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute.
5. A method for controlling permissions based on function level, characterized in that: Applied to a client, the method comprises: Sending an API call request to a server, so that the server can perform permission verification on the API call request; The server verifies the API call request based on the following method: Determine the target function to be accessed based on the API call request; Querying the server for a first function control attribute of the target function; If the first function control attribute is not found, performing service-level permission control on the API call request; If the first function control attribute is found, query the client for a second function control attribute for the target function; If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result; If the first permission check result is that permission is granted, routing the API call request to the target service accessed by the API call request; If the server finds the second function control attribute, the sending of the API call request to the server further includes: Sending the second function control attribute of the client to the server; The querying the server for the first function control attribute of the target function includes: Determining a file name based on the objective function; Query the target file corresponding to the file name; If the target file is found, query whether the target file is configured with the first function control attribute; If the target file is not found, the first function control attribute is not found; The first function control attribute is configured based on the following method: Determine a target function for configuring the first function control attribute, and determine a file name based on the target function; Create a target file corresponding to the file name; The first function control attribute is configured for the target file so that the first function control attribute is an extended attribute of the target file.
6. A function-level permission control device, characterized in that: Deployed on the server, the device includes: A request receiving module, used to receive an API call request sent by a client, and determine a target function to be accessed based on the API call request; A first query module, used to query the server for a first function control attribute of the target function; A permission control module, configured to perform service-level permission control on the API call request if the first function control attribute is not found; A second query module is configured to query the client for a second function control attribute for the target function if the first function control attribute is found; a permission verification module, configured to, if the second function control attribute is queried, perform a function-level permission verification on the API call request based on the first function control attribute and the second function control attribute to obtain a first permission verification result; A request routing module, configured to route the API call request to a target service accessed by the API call request if the first permission check result is that the request is authorized; The first query module is also used for: Determining a file name based on the objective function; Query the target file corresponding to the file name; If the target file is found, query whether the target file is configured with the first function control attribute; If the target file is not found, the first function control attribute is not found; The first function control attribute is configured based on the following method: Determine a target function for configuring the first function control attribute, and determine a file name based on the target function; Create a target file corresponding to the file name; The first function control attribute is configured for the target file so that the first function control attribute is an extended attribute of the target file.
7. A function-level permission control device, characterized in that: Deployed on the client, the device includes: A request sending module, used to send an API call request to a server, so that the server can perform permission verification on the API call request; The server verifies the API call request based on the following method: Determine the target function to be accessed based on the API call request; Querying the server for a first function control attribute of the target function; If the first function control attribute is not found, performing service-level permission control on the API call request; If the first function control attribute is found, query the client for a second function control attribute for the target function; If the second function control attribute is found, based on the first function control attribute and the second function control attribute, a function-level permission check is performed on the API call request to obtain a first permission check result; If the first permission check result is that permission is granted, routing the API call request to the target service accessed by the API call request; If the server queries the second function control attribute, the device further includes: An attribute sending module, used for sending the second function control attribute of the client to the server; The querying the server for the first function control attribute of the target function includes: Determining a file name based on the objective function; Query the target file corresponding to the file name; If the target file is found, query whether the target file is configured with the first function control attribute; If the target file is not found, the first function control attribute is not found; The first function control attribute is configured based on the following method: Determine a target function for configuring the first function control attribute, and determine a file name based on the target function; Create a target file corresponding to the file name; The first function control attribute is configured for the target file so that the first function control attribute is an extended attribute of the target file.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the function-level-based permission management method as described in any one of claims 1 to 5 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the function-level-based permission management method as described in any one of claims 1 to 5 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the function-level-based permission management method as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method, apparatus and device for responding to webpage access request, and storage medium
CN110674427A
File permission control list management method and related components
CN112351062A
File access control system and method and computing equipment
CN113449327A
Equipment node opening control method and device, electronic equipment and storage medium
CN113935014A
Security access control method and system, vehicle control equipment, vehicle and medium
CN116566704A
