Access processing method and device, electronic equipment and storage medium
By encrypting and decrypting data item identification information, combined with the dual-factor authentication mechanism, the problem of horizontal overprivileges vulnerabilities is solved, and the defense capabilities for overprivileges are enhanced to ensure data security and privacy protection.
Patent Information
- Application Number
- CN202411182627.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-11-15
AI Technical Summary
The prior art is difficult to effectively prevent vulnerabilities over privilege, which leads to attackers being able to illegally access or operate other users' resources or data, threatening user privacy and the security of business data.
By encrypting and decrypting the data item identification information, combined with the dual-factor authentication mechanism, we ensure that the target data item is returned only when the user identity and data scope permissions are exactly matched, preventing overprivileged access.
Effectively enhance the defense capabilities of horizontally overright access, prevent attackers from accessing target data items without complying with user identity or data scope permissions, and improve data security and privacy protection.
Smart Images

Figure CN118965405A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an access processing method, device, electronic device and storage medium. Background Art
[0002] In today's information age, the rapid progress of information technology has greatly promoted the digital transformation of various fields of society. As the core platform for information exchange and services, the security of network application systems is directly related to user data protection and business continuity. However, with the increasing complexity of network technology and the continuous evolution of attack methods, unauthorized vulnerability attacks on network application systems have shown unprecedented high frequency and professionalism, bringing severe security challenges to network application systems.
[0003] Among these privilege escalation vulnerabilities, horizontal privilege escalation vulnerabilities are particularly noteworthy. Such vulnerabilities allow attackers to exploit loopholes in the system verification mechanism or permission control logic, break through normal permission boundaries, and illegally access or operate resources or data that are at the same permission level as their own but should belong to other legitimate users. Such illegal access and operation not only directly threatens the security of user privacy and may lead to the leakage of sensitive information, but may also cause illegal tampering of business data and interfere with the normal operation of the system.
[0004] Therefore, how to prevent horizontal authority violations becomes a problem. Summary of the invention
[0005] In view of the above problems, the present application provides an access processing method, device, electronic device and storage medium to achieve the purpose of enhancing the defense capability against horizontal unauthorized access. The specific scheme is as follows:
[0006] The first aspect of the present application provides an access processing method, comprising:
[0007] In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0008] For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information;
[0009] Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client;
[0010] In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0011] According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0012] If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information;
[0013] The target data item is returned to the client as second response information.
[0014] In a possible implementation, in response to a first access request from a client, obtaining a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set includes:
[0015] Scanning each attribute in the returned entity class corresponding to the interface called by the client through the aspect device, identifying a first target attribute with a first annotation; the first target attribute corresponds to the data item identification information; the first annotation is used to mark that the first target attribute needs to be encrypted;
[0016] Acquire, by the section device, from the first annotation, a first table identifier associated with the data item identifier information;
[0017] Acquire at least one data item set corresponding to the first user identifier from the data range corresponding to the first table identifier in the database; the data item set includes the data item identification information and other data items;
[0018] The encrypted information is used to replace the data item identification information to obtain a new data item set, including:
[0019] The encrypted information is assigned to the first target attribute in the returned entity class through the slice device, and the other data items are assigned to other attributes in the returned entity class except the first target attribute, so as to obtain a new data item set.
[0020] In a possible implementation, after replacing the data item identification information with the encrypted information to obtain a new data item set, the method further includes:
[0021] Determining whether there is a data item containing sensitive information in the new data item set;
[0022] If so, perform desensitization processing on the data items containing sensitive information to obtain a set of desensitized data items.
[0023] In a possible implementation, determining whether there is a data item containing sensitive information in the data item set includes:
[0024] The slice device scans each attribute of each returned entity class in the returned entity class to determine whether there is an attribute corresponding to sensitive information in each attribute.
[0025] In a possible implementation, before desensitizing the data item containing sensitive information, the method further includes:
[0026] Determining, by the sectioning device, whether the attribute corresponding to the sensitive information has a second annotation; the second annotation is used to mark that desensitization processing is not allowed for the value of the attribute;
[0027] If not, desensitizing the data item containing the sensitive information;
[0028] If so, keep the data item containing the sensitive information unchanged.
[0029] In a possible implementation manner, decrypting the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information includes:
[0030] Scanning each attribute in the request entity class corresponding to the interface corresponding to the second access request by the aspect device, identifying a second target attribute with a third annotation; the second target attribute corresponds to the encrypted information; the third annotation is used to mark that the second target attribute needs to be decrypted;
[0031] The value of the second target attribute is decrypted by the slice device to obtain the first user identifier, the first table identifier and the data item identifier information.
[0032] In a possible implementation, obtaining a second table identifier corresponding to a data range to be queried by the client includes:
[0033] A second table identifier is obtained from the third annotation.
[0034] In another aspect of the present application, an access processing device is provided, comprising:
[0035] A first acquisition module is used to obtain, in response to a first access request from a client, a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0036] an encryption module, used for encrypting the first user identifier, the first table identifier and the data item identifier information for each set of data items to obtain encrypted information;
[0037] A replacement module, used to replace the data item identification information with the encrypted information to obtain a new data item set;
[0038] A first returning module, used for returning the new data item set as first response information to the client;
[0039] a decryption module, configured to, in response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0040] A second acquisition module, configured to acquire, according to the second access request, a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0041] A third acquisition module, configured to acquire a target data item based on the data item identification information if the first user identifier is consistent with the second user identifier and the first table identifier is consistent with the second table identifier;
[0042] The second returning module is used to return the target data item to the client as second response information.
[0043] In a third aspect of the present application, an electronic device is provided, comprising a processor and a memory connected to the processor, wherein:
[0044] The memory is used to store computer programs;
[0045] The processor is used to execute the computer program so that the electronic device can implement the following steps:
[0046] In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0047] For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information;
[0048] Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client;
[0049] In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0050] According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0051] If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information;
[0052] The target data item is returned to the client as second response information.
[0053] In a fourth aspect of the present application, a computer storage medium is provided, wherein the storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the following steps:
[0054] In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0055] For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information;
[0056] Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client;
[0057] In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0058] According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0059] If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information;
[0060] The target data item is returned to the client as second response information.
[0061] In the present application, by responding to a first access request from a client, a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identification information in the data item set are obtained; for each of the data item sets, the first user identifier, the first table identifier, and the data item identification information are encrypted to obtain encrypted information; the encrypted information is used to replace the data item identification information to obtain a new data item set, so that the data item identification information obtained by the client is always in ciphertext form, which can prevent the data item identification information from being stolen; on this basis, in response to a second access request for the data item set, the encrypted information in the second access request is decrypted to obtain the first user identifier, the first table identifier, and the data item identification information, and the second user identifier and the second table identifier are obtained; by comparing the first user identifier with the second user identifier, and the first table identifier with the second table identifier, a double authentication process is performed: only when the two user identifiers are consistent and the two set identification information are also consistent, the system will retrieve and return the target data item based on the decrypted data item identification information. This dual authentication mechanism can enhance the defense against horizontal unauthorized access, because even if an attacker obtains the encrypted data item identification information through some means, he cannot access the target data item without meeting the user's identity or data range permissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0063] Figure 1 A flowchart of an access processing method provided for this application;
[0064] Figure 2 A flowchart of another access processing method provided for this application;
[0065] Figure 3 A flowchart of another access processing method provided by the present application;
[0066] Figure 4 A flowchart of another access processing method provided by the present application;
[0067] Figure 5 A schematic diagram of the structure of an access processing device provided in this application. DETAILED DESCRIPTION
[0068] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0069] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0070] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0071] During the project development process, querying and modifying data item identification information (such as questionnaire ID) is a common requirement, and these operations are often accompanied by issues of data permission control and sensitive information protection. Traditional interface protection methods mainly focus on verifying whether users have the authority to operate specific data items, but there may be deficiencies in implementation, especially when dealing with complex organizational structures and sensitive information.
[0072] Take the internal management system of an enterprise as an example. The system adopts a hierarchical organizational structure (such as board of directors, departments, functional groups, small teams, etc.). Each level has a unique organizational code, and employees belong to a specific organizational level. In the questionnaire function, in order to ensure the security and privacy of data, access rights need to be strictly controlled to ensure that only employees of a specific organization and its subordinate organizations can view the corresponding questionnaire.
[0073] However, in some cases, horizontal unauthorized access protection is not enough, for example:
[0074] Scenario 1 (no permission check for the questionnaire viewing interface): When the developer ignores permission check, the interface allows any user to view any questionnaire by modifying the questionnaire ID in the request, which leads to serious horizontal unauthorized access issues. Assume that the questionnaire with questionnaire ID 3 is issued by the marketing department, and user A is an employee of the system R&D department. According to business requirements, he should not have the right to view the questionnaire. A only needs to set the questionnaire ID to 3 when calling the questionnaire viewing interface to initiate a request to view the questionnaire without authorization.
[0075] Scenario 2 (authorization judgment has been made but is complex): Although the developer has considered the authority issue and implemented the verification logic, this method relies on complex organizational hierarchical relationship judgment, which increases the difficulty and workload of development, and may still cause security vulnerabilities due to omissions or errors. Taking the questionnaire viewing interface as an example, the judgment logic is: the organization code of the organization that issued the questionnaire is Z1, and the organization code of the user is Z2. The condition for the user to view the questionnaire is that Z1 is the same organization or the superior organization of Z2. Assume that the questionnaire with questionnaire ID 3 is issued by the Marketing and Sales Department, and the organizational hierarchy to which user A belongs is: Enterprise-System R&D Department-Production and Research Group 1-R&D Team 1. When user A tries to view the questionnaire, the interface performs a logical authority check and needs to determine whether the "Marketing and Sales Department" is the same organization or the superior organization of "R&D Team 1". Compare the organization code to which A belongs and the higher-level organization codes (R&D Team 1, Production and Research Group 1, System R&D Department, and Enterprise organization codes in order) with the organization code to which the questionnaire belongs one by one. If they are the same, it means that A has the authority to view, otherwise he has no right to operate.
[0076] During project development, some interfaces' return messages contain sensitive information such as user's mobile phone number, ID number, and email address. If the interface is not processed and returns complete data, attackers can obtain the user's real information by calling the interface, causing data security issues. The conventional processing method is to search the system one by one for interfaces that return sensitive information, manually desensitize each sensitive information in each interface, and return messages according to the desensitized data.
[0077] Therefore, the present application provides an access processing method, which aims to simplify and strengthen data permission control and sensitive information protection.
[0078] The present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0079] Reference Figure 1 , is a flow chart of an access processing method provided in Example 1 of the present application. The method can be applied to a server. The present application does not limit the product type of the server. For example, Figure 1 As shown, the method may include but is not limited to the following steps:
[0080] Step S101, in response to a first access request from a client, obtain a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identification information in the data item set.
[0081] In this embodiment, the first user identifier may be obtained according to the first access request. The first user identifier is used to identify the user who initiated the first access request. For example, the first access request may include user authentication information (such as a token, a session ID, etc.) for verifying the identity of the user who initiated the first access request. Using the user authentication information, a user identity authentication process may be performed to confirm that the first access request is initiated by a legitimate user and that the user has the right to access the requested data.
[0082] Once the user identity authentication is successful, a unique first user identification (such as a user ID) may be extracted or generated from the user authentication information.
[0083] A parameter indicating the data range to be queried by the client may also be obtained according to the first access request, and the parameter may be a designated first table identifier. The first table identifier may be used to designate a data table to be queried in subsequent database query operations.
[0084] In this embodiment, at least one data item set associated with the first user identifier and to which the user has the right to access may be retrieved from the data corresponding to the first table identifier in the database.
[0085] The data item set may include data item identification information and other data items. The data item identification information may be used to uniquely identify the data item set, and the detailed information of the data item set may be obtained from the database through the data item identification information. Other data items are relative to the detailed information of the data item set, and other data items may be summary information of the data item set. Summary information is usually more concise than detailed information, but not complete enough.
[0086] Data item identification information can be encrypted, and other data items may not be encrypted.
[0087] Step S102: For each of the data item sets, encrypt the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information.
[0088] In this embodiment, the first user identifier, the first table identifier, and the data item identifier information may be concatenated into an original information string using a separator. For example, if the separator is @@, the original information string corresponding to the scenario where the user with userId 16 views the table paper (i.e., an implementation of the first table identifier) with ID (i.e., an implementation of the data item identifier information) 3 is "16@@paper@@3".
[0089] In this embodiment, the original information string can be encrypted based on an encryption algorithm to obtain encrypted information. The encryption key used is stored by the server.
[0090] Step S103: Replace the data item identification information with the encrypted information to obtain a new data item set, and return the new data item set to the client as the first response information.
[0091] After the client receives the first response information, the data item identification information is in ciphertext form, which can ensure that the data item identification information is not tampered with or stolen.
[0092] Step S104: In response to a second access request for the data item set, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier and the data item identifier information.
[0093] The second access request may come from the client that initiates the first access request, or may come from another client with corresponding permissions.
[0094] The decryption process can use the same key or decryption algorithm (or the corresponding key pair) as used for encryption to ensure that the original information string can be correctly restored.
[0095] Step S105: According to the second access request, obtain a second user identifier and a second table identifier corresponding to the data range to be queried by the client.
[0096] Since the process of obtaining the second user identifier is highly similar to the process of obtaining the first user identifier in step S101 in logic, except for the processed access requests, the specific details of obtaining the second user identifier are not repeated in the description of step S105.
[0097] Since the process of obtaining the second table identifier is highly similar to the process of obtaining the first table identifier in step S101 in logic, except for the processed access requests, the specific details of obtaining the second table identifier are not repeated in the description of step S105.
[0098] Step S106: If the first user identifier and the second user identifier are consistent, and the first table identifier and the second table identifier are consistent, obtain the target data item based on the data item identification information.
[0099] If the first user identifier and the second user identifier are consistent, it can be said that the encrypted information has not been stolen by other users, and horizontal unauthorized access between users (i.e., one user attempts to access another user's data) can be prevented. Furthermore, if the first table identifier and the second table identifier are consistent, it can be said that the user has not misappropriated the data item identifier information to obtain the target data item, and data scope unauthorized access (i.e., the user attempts to access data outside of his or her authority) can be prevented.
[0100] For example, user A's user ID is 1001, and user B's user ID is 1002. A saw multiple notifications on the notification list function page, and he sent the noticeID (encrypted information) of one of the notifications to B in violation of regulations. B attempted to use the noticeID to call the interface to view the notification without authorization. In this scenario, the noticeID sent by A to B is the encrypted ciphertext of the original information string "1001@@tb_notice@@notificationID plaintext value". When B makes a request based on this ciphertext, the server first decrypts the request to obtain the original information string, and the userId obtained from the original information string is 1001. When B initiates the request, the server obtains the current user's userId 1002 based on the session information. Because 1001 and 1002 are different, B is judged to be information theft, thereby preventing horizontal unauthorized access between users.
[0101] User A's userId is 1001. He has no right to view questionnaires with certain ID values, but he tries to view them by replacing data. In another scenario, multiple notifications are seen on the notification list function page. The noticeID of one of the notifications is the encrypted ciphertext of the original information string "1001@@tb_notice@@notification ID plaintext value". User A tries to use the ciphertext in the notification scenario to request to view the questionnaire interface. When the server receives the request, it decrypts the ciphertext to obtain the original information string. The userId obtained from the original information string is 1001, and the table name is tb_notice. According to User A's session information, the userId of the current user is 1001. The same userId in the two places indicates that the information is not stolen by others; check the table name tb_vote on the resource ID attribute annotation @IDDncrypt in the questionnaire interface request entity class. The table name tb_notice is different from tb_vote, which determines that the request data is forged or replaced by the user, thereby preventing User A from horizontally unauthorized access to certain questionnaires that he has no right to view.
[0102] Step S107: Return the target data item to the client as second response information.
[0103] In this embodiment, by responding to a first access request from a client, a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identification information in the data item set are obtained; for each of the data item sets, the first user identifier, the first table identifier, and the data item identification information are encrypted to obtain encrypted information; the encrypted information is used to replace the data item identification information to obtain a new data item set, so that the data item identification information obtained by the client is always in ciphertext form, which can prevent the data item identification information from being stolen; on this basis, in response to a second access request for the data item set, the encrypted information in the second access request is decrypted to obtain the first user identifier, the first table identifier, and the data item identification information, and the second user identifier and the second table identifier are obtained; by comparing the first user identifier with the second user identifier, and the first table identifier with the second table identifier, a double authentication process is performed: only when the two user identifiers are consistent and the two set identification information are also consistent, the system will retrieve and return the target data item based on the decrypted data item identification information. This dual authentication mechanism can enhance the defense against horizontal unauthorized access, because even if an attacker obtains the encrypted data item identification information through some means, he cannot access the target data item without meeting the user's identity or data range permissions.
[0104] As another optional embodiment of the present application, refer to Figure 2 , is a flow chart of an access processing method provided in Example 2 of the present application. This example is mainly an implementation method of steps S101 to S103 in Example 1. Figure 2 As shown, step S101 may include but is not limited to the following steps:
[0105] Step S1011: In response to a first access request from a client, a first user identifier is obtained according to session information.
[0106] Step S1012: Scan the attributes in the returned entity class corresponding to the interface called by the client through the aspect device, and identify the first target attribute with the first annotation; the first target attribute corresponds to the data item identification information; the first annotation is used to mark that the first target attribute needs to be encrypted.
[0107] When the client initiates a first access request, the server may determine the interface corresponding to the first access request.
[0108] The returned entity class can be used to define the data structure of the interface response.
[0109] In this embodiment, the business logic code of the returned entity class itself may not be modified, and annotations may be added to the returned entity class. For example, a custom encryption annotation class @IDEncrypt(tableName="") (tableName indicates the table name corresponding to the resource ID) is used to annotate the resource ID (i.e., an implementation method of the data item identification information) attribute in the returned entity class corresponding to the interface.
[0110] The first annotation may include a first table identifier associated with the data item identifier information, and the first table identifier may be used to indicate a data range to which the attribute belongs in the database.
[0111] In Java, aspect is a powerful function that allows developers to add additional behaviors without modifying business code. In this embodiment, the aspect device can use the reflection mechanism to scan and return the annotations on the entity class.
[0112] Step S1013: obtaining, from the first annotation, a first table identifier associated with the data item identifier information through a sectioning device.
[0113] Step S1014: Acquire at least one data item set corresponding to the first user identifier from the data range corresponding to the first table identifier in the database; the data item set includes the data item identification information and other data items.
[0114] Step S102 may include but is not limited to the following steps:
[0115] Step S1021: Encrypt the first user identifier, the first table identifier and the data item identifier information for each data item set through the slice device to obtain encrypted information.
[0116] Accordingly, step S103 may include but is not limited to the following steps:
[0117] Step S1031: assign the encrypted information to the first target attribute in the returned entity class through the slice device, and assign the other data items to other attributes in the returned entity class except the first target attribute, to obtain a new data item set.
[0118] For example, the aspect device can dynamically scan and return various attributes of the entity class. If an attribute is annotated with @IDEncrypt, it indicates that the attribute corresponds to a resource ID that needs to be encrypted and returned. The table name corresponding to the resource ID is obtained through the annotation @IDEncrypt, and the userId, table name, and resource ID plain text are concatenated into the original information string using the separator @@. For example, the original information string corresponding to the scene where the user with userId 16 views the table paper with ID 3 is "16@@paper@@3". The original information string is encrypted using the SM4 national encryption algorithm to obtain the resource ID ciphertext (i.e., an implementation method of encrypting information).
[0119] The encryption key used can be stored by the server.
[0120] In this embodiment, developers can obtain encrypted information by simply adding annotations without modifying the business logic code of the returned entity class, thereby enhancing data security. This method can reduce the workload of developers and avoid loopholes caused by omissions in the traditional method of adding code logic to each interface one by one.
[0121] In addition, by introducing the aspect device, there is no need to modify the original business logic code of each interface, thus reducing the workload.
[0122] As another optional embodiment of the present application, refer to Figure 3 , is a flow chart of an access processing method provided in Example 3 of the present application, such as Figure 3 As shown, the method may include but is not limited to the following steps:
[0123] Step S201, in response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0124] Step S202: for each of the data item sets, encrypt the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information;
[0125] Step S203: Replace the data item identification information with the encrypted information to obtain a new data item set.
[0126] The detailed process of steps S201-S203 can refer to the relevant introduction of steps S101-S103 in embodiment 1 or 2, which will not be repeated here.
[0127] Step S204: Determine whether there is a data item containing sensitive information in the new data item set.
[0128] Sensitive information can be information set based on the organization's internal data classification and data protection policies, such as identity information, phone numbers, email addresses, etc.
[0129] If yes, execute step S205; if no, execute step S206.
[0130] Step S205: desensitize the data items containing sensitive information to obtain a set of desensitized data items, and return the set of desensitized data items as first response information to the client.
[0131] After the data item containing the sensitive information is desensitized, the desensitized data item may be an incomplete plaintext compared to the data item containing the sensitive information.
[0132] Desensitization may include but is not limited to at least one of the following: partial masking (e.g., masking the phone number "123-456-7890" to "123-**-7890"), hashing, encryption, and data truncation (e.g., deleting the domain name portion of an email address and retaining only the username portion).
[0133] Step S206: Return the new data item set as first response information to the client.
[0134] Step S207: In response to a second access request for the data item set, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0135] Step S208: acquiring, according to the second access request, a second user identifier and a second table identifier corresponding to the data range to be queried by the client;
[0136] Step S209: if the first user identifier and the second user identifier are consistent, and the first table identifier and the second table identifier are consistent, acquiring a target data item based on the data item identification information;
[0137] Step S210: Return the target data item to the client as second response information.
[0138] The detailed process of steps S207-S210 can refer to the relevant introduction of steps S104-S107 in Example 1, which will not be repeated here.
[0139] In this embodiment, by determining whether there are data items containing sensitive information in the new data item set, and if so, desensitizing the data items containing sensitive information to obtain a desensitized data item set, automatic desensitization can be achieved, thereby reducing the workload of developers and avoiding the leakage of sensitive information due to omissions of multiple manual desensitizations.
[0140] As another optional embodiment of the present application, an access processing method is provided in Embodiment 4 of the present application. This embodiment is mainly an implementation method of step S204 in Embodiment 3. Step S204 may include but is not limited to the following steps:
[0141] Step S2041: Scan the attributes of each returned entity class in the returned entity class through the slice device to determine whether there is an attribute corresponding to sensitive information among the attributes.
[0142] In this embodiment, a regular expression can be used to determine whether an attribute corresponds to sensitive information such as a mobile phone number, ID card number, or email address. If so, a unified desensitization process is performed (taking a mobile phone number as an example, the result of a complete mobile phone number after desensitization process is similar to 183****4321).
[0143] In this embodiment, the aspect device scans each attribute of each returned entity class in the returned entity class to determine whether there is an attribute corresponding to sensitive information in each attribute. This can ensure that all sensitive information can be automatically desensitized globally without special requirements, thereby reducing the workload of developers and avoiding the omission of multiple manual desensitizations that may cause sensitive information leakage.
[0144] As another optional embodiment of the present application, an access processing method provided in Embodiment 5 of the present application may include but is not limited to the following steps:
[0145] Step S301: In response to a first access request from a client, a first user identifier is obtained according to session information.
[0146] Step S302: Scan the attributes in the returned entity class corresponding to the interface called by the client through the aspect device, and identify the first target attribute with the first annotation; the first target attribute corresponds to the data item identification information; the first annotation is used to mark that the first target attribute needs to be encrypted.
[0147] Step S303: Obtain, through a sectioning device, from the first annotation, a first table identifier associated with the data item identifier information.
[0148] Step S304: acquiring at least one data item set corresponding to the first user identifier from the data range corresponding to the first table identifier in the database; the data item set includes the data item identification information and other data items.
[0149] The detailed process of steps S301-S304 can refer to the relevant introduction of steps S1011-S1014 in Example 2, which will not be repeated here.
[0150] Step S305: Encrypt the first user identifier, the first table identifier and the data item identifier information for each data item set through the slice device to obtain encrypted information.
[0151] The detailed process of step S305 can refer to the relevant introduction of step S1021 in embodiment 2, which will not be repeated here.
[0152] Step S306: Assign the encrypted information to the first target attribute in the returned entity class through the slice device, and assign the other data items to other attributes in the returned entity class except the first target attribute, to obtain a new data item set.
[0153] The detailed process of step S306 can refer to the relevant introduction of step S1031 in embodiment 2, which will not be repeated here.
[0154] Step S307: Scan the attributes of each returned entity class in the returned entity class through the slice device to determine whether there is an attribute corresponding to sensitive information among the attributes.
[0155] If yes, execute step S308.
[0156] The detailed process of step S307 can refer to the relevant introduction of step S2041 in embodiment 4, which will not be repeated here.
[0157] Step S308: Determine, by the section device, whether the attribute corresponding to the sensitive information has a second annotation; the second annotation is used to mark that desensitization processing of the attribute value is not allowed.
[0158] In this embodiment, for the attribute corresponding to sensitive information in the returned entity class, if the attribute business requires plain text return, a custom annotation class @SkipMask can be added to the attribute to skip the automatic desensitization process, otherwise no annotation is needed.
[0159] If not, execute step S309; if so, execute step S310.
[0160] Step S309: desensitize the data items containing sensitive information to obtain a set of desensitized data items, and return the set of desensitized data items as first response information to the client.
[0161] Step S310: Keep the data item containing sensitive information unchanged.
[0162] Step S311: In response to a second access request for the data item set, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier and the data item identifier information.
[0163] Step S312: According to the second access request, obtain a second user identifier and a second table identifier corresponding to the data range to be queried by the client.
[0164] Step S313: If the first user identifier and the second user identifier are consistent, and the first table identifier and the second table identifier are consistent, obtain the target data item based on the data item identification information.
[0165] Step S314: Return the target data item to the client as second response information.
[0166] The detailed process of steps S311-S314 can refer to the relevant introduction of steps S104-S107 in Example 1, which will not be repeated here.
[0167] In this embodiment, the aspect device determines whether the attribute corresponding to the sensitive information has a second annotation; the second annotation is used to mark that the value of the attribute is not allowed to be desensitized; if not, the data item containing the sensitive information is desensitized; if so, the data item containing the sensitive information is kept unchanged, so that sensitive information in the data can be processed more flexibly. This mechanism allows developers to finely control which data should be desensitized and which data should be kept as is according to actual needs, thereby enhancing the flexibility and configurability of data processing.
[0168] As another optional embodiment of the present application, refer to Figure 4 , is a flow chart of an access processing method provided in Example 6 of the present application. This example is mainly an implementation method of step S104 in Example 2. Figure 4 As shown, step S104 may include but is not limited to the following steps:
[0169] Step S1041, scanning each attribute in the request entity class corresponding to the interface corresponding to the second access request through the aspect device, identifying the second target attribute with the third annotation; the second target attribute corresponds to the encryption information; the third annotation is used to mark that the second target attribute needs to be decrypted.
[0170] When the client sends the second access request, it is actually requesting to call an interface on the server. This interface corresponds to the request entity class.
[0171] The request entity class can be used to define the data structure of the interface request.
[0172] In this embodiment, the business logic code of the request entity class itself may not be modified, and annotations may be added to the request entity class. For example, a custom decryption annotation class @IDDncrypt(tableName="") (tableName indicates the table name corresponding to the resource ID) is used to annotate the resource ID attribute in the request entity class corresponding to the interface.
[0173] The third annotation may include a second table identifier associated with the data item identifier information, and the second table identifier may be used to indicate a data range to which the attribute belongs in the database.
[0174] Step S1042: Decrypt the value of the second target attribute through the slice device to obtain the first user identifier, the first table identifier and the data item identifier information.
[0175] It can be understood that the value of the second target attribute comes from the object of the request entity class (ie, the second access request) rather than from the request entity class.
[0176] For example, the aspect device can dynamically scan the various attributes of the request entity class. If an attribute is annotated with @IDDncrypt, it indicates that the resource ID corresponding to the attribute needs to be decrypted. First, use the SM4 national encryption algorithm to decrypt the resource ID ciphertext to obtain the original information string, which is in the form of "userId@@table name@@ID value". The original information string is split according to @@ to obtain userId1, table name 1, and ID value in turn.
[0177] The userId2 of the currently logged-in user is obtained through the session information, and the corresponding table name 2 on the entity class annotation is obtained through the annotation @IDDncrypt. If userId1 and userId2 are different, or table name 1 and table name 2 are different, it means that the resource ID ciphertext is stolen or forged from elsewhere, thus preventing this illegal data request. If there is no such situation, it means that it is a normal request, and the ID value obtained after the original information string is split is the plaintext ID, which is used for subsequent logical execution.
[0178] In this embodiment, the developer may be allowed to perform decryption by simply adding annotations without modifying the business logic code of the request entity class itself.
[0179] In addition, by introducing the aspect device, there is no need to modify the original business logic code of each interface, thus reducing the workload.
[0180] As another optional embodiment of the present application, an access processing method is provided for Embodiment 7 of the present application. This embodiment is mainly an implementation method for obtaining the second table identifier corresponding to the data range to be queried by the client in Embodiment 6. Obtaining the second table identifier corresponding to the data range to be queried by the client may include but is not limited to the following steps:
[0181] A second table identifier is obtained from the third annotation.
[0182] In the case where the third annotation may include the second table identifier associated with the data item identifier information, the second table identifier may be obtained from the third annotation, thereby improving the speed of access processing.
[0183] Next, an access processing device provided by the present application is introduced. The access processing device introduced below and the access processing method introduced above can refer to each other.
[0184] Reference Figure 5 The access processing device includes: a first acquisition module 100, an encryption module 200, a replacement module 300, a first return module 400, a decryption module 500, a second acquisition module 600, a third acquisition module 700 and a second return module 800.
[0185] A first acquisition module 100 is used to obtain, in response to a first access request from a client, a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0186] An encryption module 200, configured to encrypt the first user identifier, the first table identifier and the data item identifier information for each set of data items to obtain encrypted information;
[0187] A replacement module 300, used to replace the data item identification information with the encrypted information to obtain a new data item set;
[0188] A first returning module 400, configured to return the new data item set as first response information to the client;
[0189] a decryption module 500, configured to, in response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0190] A second acquisition module 600 is used to acquire, according to the second access request, a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0191] A third acquisition module 700, configured to acquire a target data item based on the data item identification information if the first user identifier is consistent with the second user identifier and the first table identifier is consistent with the second table identifier;
[0192] The second returning module 800 is used to return the target data item as second response information to the client.
[0193] The first acquisition module 100 may be specifically used to scan various attributes in the returned entity class corresponding to the interface called by the client through the aspect device, and identify a first target attribute with a first annotation; the first target attribute corresponds to the data item identification information; the first annotation is used to mark that the first target attribute needs to be encrypted;
[0194] Acquire, by the section device, from the first annotation, a first table identifier associated with the data item identifier information;
[0195] At least one data item set corresponding to the first user identifier is acquired from the data range corresponding to the first table identifier in the database; the data item set includes the data item identification information and other data items.
[0196] The replacement module 300 can be specifically used for:
[0197] The encrypted information is assigned to the first target attribute in the returned entity class through the slice device, and the other data items are assigned to other attributes in the returned entity class except the first target attribute, so as to obtain a new data item set.
[0198] The access processing device may further include:
[0199] A first determination module, used to determine whether there is a data item containing sensitive information in the new data item set;
[0200] The desensitizing module is used to perform desensitizing processing on the data items containing sensitive information if there are any, so as to obtain a set of desensitized data items.
[0201] The first judgment module can be specifically used for:
[0202] The slice device scans each attribute of each returned entity class in the returned entity class to determine whether there is an attribute corresponding to sensitive information in each attribute.
[0203] The access processing device may further include:
[0204] A second judgment module is used to judge whether the attribute corresponding to the sensitive information has a second annotation through the section device; the second annotation is used to mark that the value of the attribute is not allowed to be desensitized;
[0205] If not, executing the desensitization module to perform desensitization processing on the data item containing sensitive information;
[0206] If so, keep the data item containing the sensitive information unchanged.
[0207] The decryption module 500 may be specifically used for:
[0208] Scanning each attribute in the request entity class corresponding to the interface corresponding to the second access request by the aspect device, identifying a second target attribute with a third annotation; the second target attribute corresponds to the encrypted information; the third annotation is used to mark that the second target attribute needs to be decrypted;
[0209] The value of the second target attribute is decrypted by the slice device to obtain the first user identifier, the first table identifier and the data item identifier information.
[0210] The process of the second acquisition module 600 acquiring the second table identifier corresponding to the data range to be queried by the client may specifically include:
[0211] A second table identifier is obtained from the third annotation.
[0212] An embodiment of the present application further provides an electronic device, which may include: a processor and a memory connected to the processor, wherein:
[0213] The memory is used to store computer programs;
[0214] The processor is used to execute the computer program to enable the electronic device to implement the following steps:
[0215] In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0216] For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information;
[0217] Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client;
[0218] In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0219] According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0220] If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information;
[0221] The target data item is returned to the client as second response information.
[0222] The present application also provides a computer-readable storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the following steps:
[0223] In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set;
[0224] For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information;
[0225] Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client;
[0226] In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information;
[0227] According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client;
[0228] If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information;
[0229] The target data item is returned to the client as second response information.
[0230] It should also be noted that the device embodiments described above are merely schematic, 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 over 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. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0231] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0232] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0233] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. An access processing method, characterized in that: include: In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set; For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information; Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client; In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information; According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client; If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information; The target data item is returned to the client as second response information.
2. The access processing method according to claim 1, characterized in that: In response to a first access request from a client, obtaining a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set, including: Scanning each attribute in the returned entity class corresponding to the interface called by the client through the aspect device, identifying a first target attribute with a first annotation; the first target attribute corresponds to the data item identification information; the first annotation is used to mark that the first target attribute needs to be encrypted; Acquire, by the section device, from the first annotation, a first table identifier associated with the data item identifier information; Acquire at least one data item set corresponding to the first user identifier from the data range corresponding to the first table identifier in the database; the data item set includes the data item identification information and other data items; The encrypted information is used to replace the data item identification information to obtain a new data item set, including: The encrypted information is assigned to the first target attribute in the returned entity class through the slice device, and the other data items are assigned to other attributes in the returned entity class except the first target attribute, so as to obtain a new data item set.
3. The access processing method according to claim 1 or 2, characterized in that: After replacing the data item identification information with the encrypted information to obtain a new data item set, the method further includes: Determining whether there is a data item containing sensitive information in the new data item set; If so, perform desensitization processing on the data items containing sensitive information to obtain a set of desensitized data items.
4. The access processing method according to claim 3, characterized in that: Determining whether there is a data item containing sensitive information in the data item set includes: The slice device scans each attribute of each returned entity class in the returned entity class to determine whether there is an attribute corresponding to sensitive information in each attribute.
5. The access processing method according to claim 4, characterized in that: Before desensitizing the data item containing sensitive information, the method further includes: Determining, by the sectioning device, whether the attribute corresponding to the sensitive information has a second annotation; the second annotation is used to mark that desensitization processing is not allowed for the value of the attribute; If not, desensitizing the data item containing the sensitive information; If so, keep the data item containing the sensitive information unchanged.
6. The access processing method according to claim 2, characterized in that: Decrypting the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information includes: Scanning each attribute in the request entity class corresponding to the interface corresponding to the second access request by the aspect device, identifying a second target attribute with a third annotation; the second target attribute corresponds to the encrypted information; the third annotation is used to mark that the second target attribute needs to be decrypted; The value of the second target attribute is decrypted by the slice device to obtain the first user identifier, the first table identifier and the data item identifier information.
7. The access processing method according to claim 6, characterized in that: Obtaining a second table identifier corresponding to a data range to be queried by the client includes: A second table identifier is obtained from the third annotation.
8. An access processing device, characterized in that: include: A first acquisition module is used to obtain, in response to a first access request from a client, a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set; an encryption module, used for encrypting the first user identifier, the first table identifier and the data item identifier information for each set of data items to obtain encrypted information; A replacement module, used to replace the data item identification information with the encrypted information to obtain a new data item set; A first returning module, used for returning the new data item set as first response information to the client; a decryption module, configured to, in response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information; A second acquisition module, configured to acquire, according to the second access request, a second user identifier and a second table identifier corresponding to a data range to be queried by the client; A third acquisition module, configured to acquire a target data item based on the data item identification information if the first user identifier is consistent with the second user identifier and the first table identifier is consistent with the second table identifier; The second returning module is used to return the target data item to the client as second response information.
9. An electronic device, characterized in that: The invention comprises a processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the following steps: In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set; For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information; Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client; In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information; According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client; If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information; The target data item is returned to the client as second response information.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by the electronic device, the electronic device can implement the following steps: In response to a first access request from a client, obtaining a first user identifier, a first table identifier corresponding to a data range to be queried by the client, at least one data item set corresponding to the first user identifier, and data item identifier information in the data item set; For each of the data item sets, encrypting the first user identifier, the first table identifier and the data item identifier information to obtain encrypted information; Replacing the data item identification information with the encrypted information to obtain a new data item set, and returning the new data item set as first response information to the client; In response to a second access request for the set of data items, decrypt the encrypted information in the second access request to obtain the first user identifier, the first table identifier, and the data item identifier information; According to the second access request, obtaining a second user identifier and a second table identifier corresponding to a data range to be queried by the client; If the first user identifier is consistent with the second user identifier, and the first table identifier is consistent with the second table identifier, acquiring the target data item based on the data item identification information; The target data item is returned to the client as second response information.
