A data access method, electronic device and storage medium

By generating tenant information combinations through multi-source authentication, identifying and terminating tenant isolation anomalies, the problem of inconsistent tenant identity recognition in multi-tenant systems is solved, thereby improving the security and reliability of data access.

CN123122903APending Publication Date: 2026-11-17YIYUNYING NETWORK TECHNOLOGY (JINAN) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611281052.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-21
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In existing multi-tenant software systems, inconsistencies in tenant identification or cross-service calls pose a risk of tenant isolation failure, leading to cross-tenant access and misrouting of data sources, which affects the reliability of data isolation.

Method used

Tenant information combinations are generated through multi-source identity verification. These combinations are then used to verify whether data access requests have tenant isolation anomalies. If an anomaly is found, the request is aborted; otherwise, tenant constraint processing and target data source routing are executed.

Benefits of technology

It improves the credibility of data access identity, access security, and tenant isolation reliability in multi-tenant scenarios, reduces the risk of data leakage and unauthorized access, and enhances the controllability and security protection capabilities of the data access chain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123122903A_ABST
    Figure CN123122903A_ABST
Patent Text Reader

Abstract

This application relates to a data access method, electronic device, and storage medium. It includes: acquiring a data access request; performing multi-source identity information verification on the requesting tenant; generating a tenant information combination corresponding to the requesting tenant in response to the tenant passing the multi-source identity information verification; verifying whether the data access request has a tenant isolation anomaly using the tenant information combination; performing tenant constraint processing on the data access request in response to determining that the data access request does not have a tenant isolation anomaly, and routing the data access operation to the corresponding target data source according to the data access link corresponding to the data access request; and terminating the data access request in response to determining that the data access request has a tenant isolation anomaly, thereby identifying and blocking the risk of tenant isolation failure and achieving secure data access.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data security technology, and in particular to a data access method, electronic device and storage medium. Background Technology

[0002] With the continuous development of cloud computing technology and supply chain business platforms, multi-tenant software systems have been widely applied in business scenarios such as procurement, inventory, order processing, and logistics. These systems typically employ a model where multiple tenants share application services and differentiate data access scopes based on tenant, aiming to improve resource utilization and reduce deployment costs. Current technical solutions achieve tenant isolation through request identification, link context passing, database access filtering, and data source routing. However, when the tenants indicated by different identity information carried in a request are inconsistent, or when cross-service calls, thread switching, database statement processing, or data source routing occur, existing solutions may fail to promptly identify anomalies such as tenant identity conflicts, tenant context mismatches, missing tenant filtering conditions, or inconsistent data source attribution. This can lead to risks of cross-tenant access or misrouting of data sources, affecting the reliability of tenant data isolation. Summary of the Invention

[0003] Therefore, it is necessary to provide a data access method, electronic device, and storage medium that can identify and block the risk of tenant isolation failure and achieve secure data access, addressing the aforementioned technical problems.

[0004] Firstly, this application provides a data access method, the method comprising: Get data access request; Verify the identity information of the tenant requesting data access; In response to the requesting tenant's verification of multi-source identity information, a combination of tenant information corresponding to the requesting tenant is generated; Use tenant information combinations to verify whether data access requests contain tenant isolation anomalies; In response to the determination that there is no tenant isolation anomaly in the data access request, the tenant constraint processing is performed on the data access request, and the data access operation is performed according to the data access link corresponding to the data access request to the corresponding target data source. In response to the determination that the data access request has a tenant isolation anomaly, the data access request is terminated.

[0005] In one embodiment, verifying whether a data access request has a tenant isolation anomaly using tenant information combinations includes: Invoke the request interceptor; In response to the request interceptor, the identity tenant identifier corresponding to the request tenant is retrieved from the thread-local storage of the current service and written into the request header of the request interceptor; The called service is instructed to read the request header to obtain the identity tenant identifier and extract multiple information factors from the tenant information combination; wherein, the information factors include at least two of the tenant identifier, tracking identifier and tenant context signature; the multiple information factors are compared with the current thread tenant context, call chain parent node tenant identifier and business permission matrix corresponding to the identity tenant identifier stored by the called service; wherein, the business permission matrix includes the identity tenant identifier and / or the tenant to which the target data source belongs. In response to a match between multiple information factors and at least one of the following: the current thread tenant context stored in the called service, the tenant identifier of the parent node in the call chain, and the business permission matrix, it is determined that the data access request has a tenant isolation anomaly. If multiple information factors match the current thread tenant context, call chain parent node tenant identifier, and business permission matrix stored in the called service, it is determined that the data access request does not have a tenant isolation anomaly.

[0006] In one embodiment, the tenant information combination includes a tenant context signature. Verifying whether a data access request exhibits a tenant isolation anomaly using the tenant information combination includes: Create a signature snapshot corresponding to the tenant context signature; In response to thread switching, the matching and timeliness of the tenant context signature are verified using a signature snapshot; wherein, thread switching includes at least one of thread pool calls and message queue calls; In response to the failure of tenant context signature matching and / or timeliness verification, clear thread local variables and determine that the data access request has a tenant isolation exception; If the matching and timeliness of the tenant context signature are verified, it is determined that the data access request does not have any tenant isolation anomalies.

[0007] In one embodiment, the signature snapshot includes a link tracing number and a context version number; verifying the matching and timeliness of the tenant context signature using the signature snapshot includes: Compare the link tracing number and context version number in the two signature snapshots to see if they match the signature information stored in the current thread; If the link tracing number and signature information do not match, the matching verification is deemed to have failed; if the context version number and signature information do not match, the timeliness verification is deemed to have failed.

[0008] In one embodiment, performing tenant constraint processing on a data access request includes: Obtain the original query statement of the data access request; Parse the original query statement to identify whether the original query statement includes the identity tenant identifier; In response to the inclusion of an identity tenant identifier in the original query, compare the identity tenant identifier in the original query with a predefined trusted tenant context; in response to a match between the identity tenant identifier and the trusted tenant context, allow the execution of the data access request; and / or, If the original query statement does not include an identity tenant identifier, verify whether the original query statement matches the preset tenant isolation annotation and space whitelist; if the original query statement matches the tenant isolation annotation and space whitelist, add the tenant identifier of the trusted tenant in the tenant context as the identity tenant identifier to the original query statement, and allow the execution of the data access request.

[0009] In one embodiment, allowing the execution of a data access request includes: Parse the subqueries contained in the original query statement and inject tenant filtering conditions into the subqueries to implement tenant constraint processing; the tenant filtering conditions include the identity tenant identifier. In response to a subquery including a data update statement, the system verifies whether the target source is a data domain accessible to the requesting tenant; in response that the target data source is a data domain accessible to the requesting tenant, the system allows the data access operation represented by the data update statement to be executed; wherein the data update statement includes at least one of update statements, delete statements, insert statements, and select query statements; and / or, In response to a subquery statement including a statement to be reviewed, the data access request is aborted and a review request is generated to review the data access request. In response to obtaining a pass instruction for the review request, the data access operation represented by the statement to be reviewed is executed, allowing the execution of the data access operation represented by the statement to be reviewed. The statement to be reviewed includes at least one of the following: a cross-tenant query statement, a full table update statement with an unconditional filter clause, and a batch abnormal row count statement.

[0010] In one embodiment, routing the data access request to the corresponding target data source according to the data access link to perform the data access operation includes: Retrieve the tenant identifier from the tenant information combination, and use the tenant identifier as the lookup key to query the registry of the target data source; Compare the tenant information combination with the information status indicators in the registry to see if they match; where information status includes tenant identifier, lookup key, the tenant to which the target data source belongs, and the tenant status of the requesting tenant; In response to a match between the tenant information combination and the status indicators of the two in the registry, the lookup key of the target data source is returned, and the data access operation is performed by routing to the target data source according to the data access link based on the lookup key.

[0011] In one embodiment, after comparing whether the tenant information combination matches the information status indicators in the registry, the process further includes: In response to a mismatch between the tenant information combination and the information status indicators in the registry, it is determined that the data access request has a tenant isolation anomaly, and the current link tracing number is associated with the current anomaly; among them, when the information status mismatch includes the requesting tenant being an unknown tenant, an unknown tenant anomaly is marked.

[0012] In one embodiment, multi-source identity verification for the requesting tenant of a data access request includes: Obtain the tenant identifier of the requesting tenant from multiple identity sources; wherein, the identity source includes at least two of the following: token identity source, request header identity source, and domain name prefix identity source; The system compares multiple tenant identifiers obtained from multiple identity sources; in response to the matching of multiple tenant identifiers, it determines that the requesting tenant has passed the multi-source identity information verification.

[0013] In one embodiment, the combination of tenant information corresponding to the requesting tenant includes: Construct the tenant context information corresponding to the data access request and the requesting tenant; wherein, the tenant context information includes at least one of the following: tenant identifier, user identifier, request source, tracing number, and context version number; Generate tenant context information, timestamp of data access request, and message authentication code signature corresponding to service key. Combine message authentication code signature with tenant context signature as tenant information. The message authentication code signature is used for signature verification by the called service. The tenant information is combined and stored in a thread-local variable that is already available for the current request.

[0014] In one embodiment, after storing the tenant information in a thread-local variable already present in the current request, the method further includes: In response to a completion or exception feedback instruction for a data access request, clear the tenant information combination in the thread-local variable.

[0015] In one embodiment, after obtaining the data access request, the method further includes: Determine the tenant level corresponding to the data access request; In response to the tenant level being the first preset level, the independent database corresponding to the data access request is determined as the target data source, and the subquery statement processed by the tenant constraint is executed through the independent database. In response to the tenant level being the second preset level, the shared database is determined as the target data source, and a subquery statement processed by the tenant constraints is executed through the shared database; wherein, during the execution of the subquery statement, database-level isolation and row-level filtering are performed based on the tenant identity information and / or tenant context information of the requesting tenant.

[0016] Secondly, this application provides an electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above data access method; The interaction module, connected to the processor and memory, is used to obtain data access requests from external input and output the access results to the outside.

[0017] Thirdly, this application provides a computer-readable storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the steps of the above-described data access method.

[0018] By implementing data access methods, devices, and computer equipment, multi-source identity verification of requesting tenants can be performed before data access requests enter the actual access chain. Based on the verification results, a tenant information combination corresponding to the requesting tenant is generated, providing a more complete and reliable identity basis for subsequent tenant isolation verification. Furthermore, the system can determine whether the data access request contains tenant isolation anomalies, effectively identifying risks such as unauthorized access, inconsistent tenant identities, or cross-tenant access. Tenant constraint processing and target data source routing are only executed after confirming the absence of anomalies, ensuring that the data access process is always controlled by tenant boundaries and access constraints. Timely termination of data access requests upon detecting tenant isolation anomalies prevents abnormal requests from continuing to flow to the target data source, reducing the risk of data leakage and unauthorized access. Therefore, this solution comprehensively improves the identity credibility, access security, and tenant isolation reliability of data access in multi-tenant scenarios, enhancing the controllability and security protection capabilities of the data access chain. Attached Figure Description

[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be determined based on these drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a data access method provided in an embodiment of this application; Figure 2 This is an overall architecture diagram of a data access method according to an embodiment of this application; Figure 3 This is a flowchart illustrating the request verification and anomaly detection process of a data access method according to an embodiment of this application. Figure 4 This is a flowchart illustrating tenant constraints and routing access for a data access method in an embodiment of this application. Figure 5This is an internal structural diagram of a computer device in one embodiment of this application. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments determined by those skilled in the art without creative effort are within the protection scope of this application.

[0022] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or treatment method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or treatment method. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0023] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0024] In one embodiment, such as Figure 1 As shown, a data access method is provided, including: S100: Obtain data access request; S200: Verify the identity information of the requesting tenant for data access; S300: In response to the requesting tenant passing multi-source identity verification, generate a combination of tenant information corresponding to the requesting tenant; S400: Use tenant information combinations to verify whether there is a tenant isolation anomaly in the data access request; S500: In response to the determination that there is no tenant isolation anomaly in the data access request, the tenant constraint processing is performed on the data access request, and the data access operation is performed according to the data access link corresponding to the data access request to the corresponding target data source. S600: In response to the determination that a tenant isolation anomaly exists in the data access request, the data access request is terminated.

[0025] Here, a data access request refers to a tenant's request to read, call, query, or use data; the requesting tenant refers to the tenant entity that initiates the request and needs to access the data; multi-source identity verification refers to verifying the tenant's identity by combining multiple identity sources to improve the reliability of identity judgment; tenant information combination refers to the comprehensive judgment basis formed based on the verified identity information, permission information, tenant identifier, and access scope; tenant isolation anomaly refers to the state in which the tenant boundary does not meet the isolation requirements during data access, including both situations where tenant isolation has failed and situations where tenant isolation is at risk of failure; tenant constraint processing refers to restricting access requests based on the tenant's identity and permission scope; data access chain refers to the access path that the request takes before reaching the data source; target data source refers to the data location that this request ultimately needs to access; suspending a data access request means stopping the request from continuing to execute and preventing it from entering subsequent access stages.

[0026] Specifically, such as Figure 2 As shown, upon receiving an access request, the system first verifies the trustworthiness of the requesting tenant through multiple identity sources. If authentication fails, the request will not proceed to subsequent access processing. Once authentication is successful, tenant information is combined to determine if the current access exhibits any tenant isolation anomalies. The judgment covers two scenarios: when no tenant isolation anomalies exist, tenant constraints limit the access scope of the request and route the request along the corresponding access path to the target data source, ensuring legitimate requests can complete access within a controlled scope; when tenant isolation has failed or is at risk of failure, the request flow is promptly stopped to prevent abnormal access from reaching the data source. This establishes continuous control between identity verification, isolation validation, and access execution, improving the accuracy of tenant identification, cross-tenant risk detection capabilities, and data access security.

[0027] In one embodiment, such as Figure 3 As shown, verifying whether a data access request has a tenant isolation anomaly using tenant information combinations includes: Invoke the request interceptor; In response to the request interceptor, the identity tenant identifier corresponding to the request tenant is retrieved from the thread-local storage of the current service and written into the request header of the request interceptor; The called service is instructed to read the request header to obtain the identity tenant identifier and extract multiple information factors from the tenant information combination; wherein, the information factors include at least two of the tenant identifier, tracking identifier and tenant context signature; the multiple information factors are compared with the current thread tenant context, call chain parent node tenant identifier and business permission matrix corresponding to the identity tenant identifier stored by the called service; wherein, the business permission matrix includes the identity tenant identifier and / or the tenant to which the target data source belongs. In response to a match between multiple information factors and at least one of the following: the current thread tenant context stored in the called service, the tenant identifier of the parent node in the call chain, and the business permission matrix, it is determined that the data access request has a tenant isolation anomaly. If multiple information factors match the current thread tenant context, call chain parent node tenant identifier, and business permission matrix stored in the called service, it is determined that the data access request does not have a tenant isolation anomaly.

[0028] Here, the request interceptor is a component that processes the request content before it enters the called service; the current service is the side that initiates this service call; thread-local storage is a temporary storage space bound to the currently executing thread, used to store the tenant identity information within this thread; the identity tenant identifier is an identifier used to indicate the tenant's identity; the request header is the header information transmitted along with the service call; the called service is the side that receives the current service call and continues to process the request; the information factor is a judgment element used to verify the tenant identity and call consistency, which can be any two of the tenant identifier, tracking identifier, and tenant context signature, or all three; the tracking identifier is an identifier used to associate a request's flow in the call chain; the tenant context signature is a signature information used to verify that the tenant context has not been tampered with; the current thread tenant context is the tenant environment information stored in the current thread of the called service; the call chain parent node tenant identifier is the tenant identity identifier corresponding to the previous level call node; and the business permission matrix is ​​a set of rules used to represent the correspondence between the identity tenant identifier, the tenant to which the target data source belongs, and the business permission relationship. It can contain only the identity tenant identifier, only the tenant to which the target data source belongs, or both.

[0029] Specifically, the system first retrieves the tenant identifier from the thread-local storage of the current service using a request interceptor and writes it into the request header, enabling the called service to obtain a unified basis for tenant identity upon receiving the call. The called service then extracts multiple information factors from the tenant information combination and compares them with the current thread's tenant context, the tenant identifier of the parent node in the call chain, and the business permission matrix. If any combination of the tenant identifier, tracking identifier, or tenant context signature is inconsistent with the comparison objects, it can be determined that the request has an isolation anomaly in identity transmission, call chain inheritance, or business permission relationships. Only when multiple information factors are consistent with the current thread's tenant context, the tenant identifier of the parent node in the call chain, and the business permission matrix is ​​it determined that there is no tenant isolation anomaly. This allows the tenant identity to be transmitted from the current service to the called service, and cross-validation is performed on the called service side using thread context, call chain source, and permission relationships. This prevents the misuse or tampering of a single identifier from causing abnormal requests to continue execution, thereby improving the accuracy of tenant isolation anomaly identification and the consistency of tenant identity in the call chain.

[0030] In one embodiment, the tenant information combination includes a tenant context signature. Verifying whether a data access request exhibits a tenant isolation anomaly using the tenant information combination includes: Create a signature snapshot corresponding to the tenant context signature; In response to thread switching, the matching and timeliness of the tenant context signature are verified using a signature snapshot; wherein, thread switching includes at least one of thread pool calls and message queue calls; In response to the failure of tenant context signature matching and / or timeliness verification, clear thread local variables and determine that the data access request has a tenant isolation exception; If the matching and timeliness of the tenant context signature are verified, it is determined that the data access request does not have any tenant isolation anomalies.

[0031] Among them, the signature snapshot refers to the tenant context signature state that is fixedly saved during a specific access phase, which is used to determine whether the tenant identity environment has changed; matching refers to whether the current tenant context signature is consistent with the signature snapshot; timeliness refers to whether the tenant context signature is still within the validity period or valid state; thread switching refers to the situation where the request processing process is transferred from one execution thread to another, which can occur in either thread pool call or message queue call, or both; thread local variable refers to a temporary variable bound to the current thread, used to store tenant context information related to the current request.

[0032] Specifically, a signature snapshot is first created by signing the tenant context, providing a benchmark for subsequent cross-thread processing. When thread pool calls, message queue calls, or a combination of both occur during thread switching, the signature snapshot is used to verify the consistency and validity of the current tenant context signature. If the matching fails, the timeliness fails, or both fail, the thread-local variable is cleared and a tenant isolation anomaly is identified, preventing erroneous or expired tenant contexts from being reused by new threads. If both matching and timeliness pass, no tenant isolation anomaly is identified, allowing requests to continue processing under a continuously reliable tenant context. This prevents tenant identity remnants, misuse, or invalidation during thread reuse or asynchronous calls, improving the stability of tenant isolation and the timeliness of anomaly detection in cross-thread data access scenarios.

[0033] In one embodiment, the signature snapshot includes a link tracing number and a context version number; verifying the matching and timeliness of the tenant context signature using the signature snapshot includes: Compare the link tracing number and context version number in the two signature snapshots to see if they match the signature information stored in the current thread; If the link tracing number and signature information do not match, the matching verification is deemed to have failed; if the context version number and signature information do not match, the timeliness verification is deemed to have failed.

[0034] Among them, the link tracing number is a number used to identify the process of a data access request in the call chain, which can associate the transmission relationship of the request in different threads or service nodes; the context version number is a version information used to characterize the generation or update status of the tenant context, which can reflect whether the current tenant context is still valid; the signature information is the tenant context signature-related information stored in the current thread and used to verify with the signature snapshot.

[0035] Specifically, by simultaneously storing the tracing number and context version number in the signature snapshot, subsequent verification can confirm both whether the request chain remains consistent with the original tenant context and whether the tenant context has been updated or expired. During verification, the tracing number and context version number in the signature snapshot are compared with the signature information stored in the current thread. If the tracing number is inconsistent, it indicates that the request flow relationship may be misaligned or abnormally replaced, resulting in a mismatch. If the context version number is inconsistent, it indicates that the current tenant context may have expired or been updated, resulting in a timeliness failure. If both are inconsistent, there is a risk of both chain misalignment and context expiration. Only when both the tracing number and context version number are consistent with the signature information can both matching and timeliness be confirmed as successful. This allows for verification from two aspects: call chain continuity and context validity, improving the accuracy of tenant context judgment in thread switching scenarios and reducing isolation risks caused by tenant identity misuse, old context reuse, or abnormal chain mixing.

[0036] In one embodiment, such as Figure 4 As shown, performing tenant constraint processing on data access requests includes: Obtain the original query statement of the data access request; Parse the original query statement to identify whether the original query statement includes the identity tenant identifier; In response to the inclusion of an identity tenant identifier in the original query, compare the identity tenant identifier in the original query with a predefined trusted tenant context; in response to a match between the identity tenant identifier and the trusted tenant context, allow the execution of the data access request; and / or, If the original query statement does not include an identity tenant identifier, verify whether the original query statement matches the preset tenant isolation annotation and space whitelist; if the original query statement matches the tenant isolation annotation and space whitelist, add the tenant identifier of the trusted tenant in the tenant context as the identity tenant identifier to the original query statement, and allow the execution of the data access request.

[0037] Among them, the original query statement refers to the query content initially generated in the data access request that has not yet been supplemented or modified by the tenant conditions; the trusted tenant in the tenant context refers to the tenant object that is identified as trusted in the current access context after the tenant identity has been confirmed; the tenant isolation annotation refers to the isolation mark pre-configured in the query or business processing logic, which is used to indicate that the query needs to be processed in accordance with the tenant isolation rules; the space whitelist refers to the query space, business scope or data access scope that is pre-allowed to be supplemented or isolated by tenant identification.

[0038] Specifically, the original query statement is first obtained and parsed to determine if it already contains a tenant identity identifier. If it does, the identifier is compared with the trusted tenant in the tenant context. Execution is only allowed if they match; otherwise, the tenant identity in the query statement does not match the current trusted context, and execution is denied. If the original query statement does not contain a tenant identity identifier, it further verifies whether the query simultaneously meets the requirements of tenant isolation annotations and space whitelists. If it does, the tenant identifier of the trusted tenant in the tenant context is added to the query statement, allowing queries lacking tenant conditions to execute within a controlled scope. If it does not simultaneously meet the requirements of tenant isolation annotations and space whitelists, the tenant identifier is not added, and execution is not allowed. This approach covers both cases where the query contains a tenant identifier and cases where it does not, preventing the direct use of incorrect tenant identifiers and avoiding queries without tenant conditions from bypassing isolation restrictions, thereby improving the reliability of tenant constraints before query execution and the security of data access.

[0039] In one embodiment, allowing the execution of a data access request includes: Parse the subqueries contained in the original query statement and inject tenant filtering conditions into the subqueries to implement tenant constraint processing; the tenant filtering conditions include the identity tenant identifier. In response to a subquery including a data update statement, the system verifies whether the target source is a data domain accessible to the requesting tenant; in response that the target data source is a data domain accessible to the requesting tenant, the system allows the data access operation represented by the data update statement to be executed; wherein the data update statement includes at least one of update statements, delete statements, insert statements, and select query statements; and / or, In response to a subquery statement including a statement to be reviewed, the data access request is aborted and a review request is generated to review the data access request. In response to obtaining a pass instruction for the review request, the data access operation represented by the statement to be reviewed is executed, allowing the execution of the data access operation represented by the statement to be reviewed. The statement to be reviewed includes at least one of the following: a cross-tenant query statement, a full table update statement with an unconditional filter clause, and a batch abnormal row count statement.

[0040] Here, a subquery statement refers to a query fragment nested or executed hierarchically within the original query statement; a tenant filter condition refers to a filtering condition used to restrict the query to access only the corresponding tenant's data; a data update statement refers to a statement type that may change or retrieve data content, which may include one or more of update statements, delete statements, add statements, and select query statements; an accessible data domain refers to the range of data that the requesting tenant is allowed to access; a statement pending review refers to a statement with high execution risk that requires manual or audit process confirmation before it can continue to be processed, including one or more of cross-tenant query statements, unconditional filter clause full table update statements, and batch abnormal row count statements; a review request refers to an audit confirmation request initiated for a statement pending review; and an approval instruction refers to confirmation information that the review result allows continued execution.

[0041] Specifically, the subqueries in the original query statement are first parsed, and tenant filtering conditions containing tenant identifiers are added to the subqueries. This ensures that nested queries are also restricted by tenant scope, preventing the constraint of only the outer query from omitting the inner query. If the subquery is a data update statement, it further determines whether the target data source falls within the data domain accessible to the requesting tenant. Execution is only allowed if it is accessible; otherwise, it is blocked, preventing updates, deletions, additions, or selection queries from accessing unauthorized data. If the subquery is a statement awaiting review, the request is aborted and a review request is generated. Execution is only allowed after a pass instruction is received; otherwise, the aborted state remains. This approach simultaneously covers three types of scenarios: ordinary subquery constraints, data update access validation, and high-risk statement review. Data access undergoes tenant filtering, data domain confirmation, and risk review before execution, improving the granularity and security of tenant constraint processing.

[0042] In one embodiment, routing the data access request to the corresponding target data source according to the data access link to perform the data access operation includes: Retrieve the tenant identifier from the tenant information combination, and use the tenant identifier as the lookup key to query the registry of the target data source; Compare the tenant information combination with the information status indicators in the registry to see if they match; where information status includes tenant identifier, lookup key, the tenant to which the target data source belongs, and the tenant status of the requesting tenant; In response to a match between the tenant information combination and the status indicators of the two in the registry, the lookup key of the target data source is returned, and the data access operation is performed by routing to the target data source according to the data access link based on the lookup key.

[0043] Here, the lookup key refers to the index information used to locate the target data source in the registry; the registry refers to the set of data records that pre-store the correspondence between tenants and target data sources; the information status indicators refer to the status elements used to determine whether the access relationship is trustworthy, including tenant identifier, lookup key, the tenant to which the target data source belongs, and the tenant status of the requesting tenant; the tenant to which the target data source belongs refers to the data owner or manager corresponding to the target data source; the tenant status refers to whether the requesting tenant is currently in an available, valid, or permitted access state; and the data access operation refers to the processing of querying, reading, writing, or calling the target data source according to the request.

[0044] Specifically, the system uses the tenant identifier in the tenant information set as the search criterion. It checks the registry to see if a corresponding target data source record exists for that tenant, and then compares the tenant information set with the information status indicators in the registry. If the tenant identifier, search key, target data source owner tenant, and requesting tenant status all match, the search key for the target data source is returned, and the system routes the request to the target data source along the matching data access path. If no corresponding record is found, or any information status indicator does not match, a valid search key is not returned, and routing to the target data source does not continue. This allows the system to confirm the correspondence between the tenant, data source, and access path before actually accessing the target data source, preventing requests from being routed to the wrong data source or the data range of an unauthorized tenant, thus improving the accuracy of data source location and the security of tenant access.

[0045] In one embodiment, after comparing whether the tenant information combination matches the information status indicators in the registry, the process further includes: In response to a mismatch between the tenant information combination and the information status indicators in the registry, it is determined that the data access request has a tenant isolation anomaly, and the current link tracing number is associated with the current anomaly; among them, when the information status mismatch includes the requesting tenant being an unknown tenant, an unknown tenant anomaly is marked.

[0046] Among them, the current anomaly refers to the tenant isolation problem identified in real time during this data access link, which is used to establish a correlation with the corresponding access request and the location where the anomaly occurred; the tenant unknown anomaly refers to the abnormal state in which the identity of the tenant in the request cannot be confirmed in the registry or trusted tenant relationship, resulting in the inability to determine whether the tenant has access qualifications.

[0047] Specifically, if the tenant information combination does not correspond to the status relationship in the registry, the system will not continue to return the lookup key or perform data source routing. Instead, the current request will be directly identified as a tenant isolation exception, and the current tracing number will be associated with the current exception, allowing the exception to be located and traced along the access chain. If the mismatch is due to the requesting tenant being unidentifiable, it will be further marked as a tenant unknown exception, making it easier to distinguish between situations with missing identity or untrustworthy tenant sources and situations with inconsistent status. This allows access requests that do not conform to the registration relationship to be blocked in time before routing, while maintaining the correspondence between exceptions and the call chain, improving the efficiency of exception location and the traceability of tenant isolation issues.

[0048] In one embodiment, multi-source identity verification for the requesting tenant of a data access request includes: Obtain the tenant identifier of the requesting tenant from multiple identity sources; wherein, the identity source includes at least two of the following: token identity source, request header identity source, and domain name prefix identity source; Compare multiple tenant identifiers obtained from multiple identity sources; in response to the matching of multiple tenant identifiers, determine that the requesting tenant has passed the multi-source identity information verification; In response to multiple tenant identifier mismatches and / or at least one identity source failing to obtain a valid tenant identifier, the requesting tenant is determined to have failed multi-source identity verification, and the data access request is terminated.

[0049] Among them, the identity identifier source refers to the information entry that can provide evidence of the tenant's identity; the token identity identifier source refers to the source from which the tenant's identity is parsed from the access token; the request header identity identifier source refers to the source from which the tenant's identity is obtained from the header fields carried in the request; and the domain name prefix identity identifier source refers to the source from which the tenant's identity is identified from the prefix part of the access domain name.

[0050] Specifically, at least two types of tenant identifiers can be selected from the token identity identifier source, request header identity identifier source, and domain name prefix identity identifier source to obtain tenant identifiers. These can be combinations of token and request header, token and domain name prefix, or request header and domain name prefix, or all three can be used simultaneously for verification. After obtaining multiple tenant identifiers, the results from each source are compared for consistency. Only when all tenant identifiers participating in the comparison are consistent is the requesting tenant confirmed to have passed verification. If there are inconsistencies among the tenant identifiers participating in the comparison, or if at least one identity identifier source cannot form a valid tenant identifier, the requesting tenant is determined to have failed multi-source identity information verification. When tenant identifiers obtained from different identity identifier sources are inconsistent or a valid tenant identifier cannot be obtained, the requesting tenant is determined to have failed multi-source identity information verification, and the current data access request is terminated to avoid continuing to generate tenant information combinations or perform subsequent data access operations when the requesting tenant's identity is untrustworthy. This multi-source cross-verification method can reduce the risk of misjudgment caused by a single identity source being forged, missing, or transmitted incorrectly, making the identity confirmation of the requesting tenant more reliable and providing a more credible identity foundation for subsequent tenant isolation judgments and data access control.

[0051] In one embodiment, the combination of tenant information corresponding to the requesting tenant includes: Construct the tenant context information corresponding to the data access request and the requesting tenant; wherein, the tenant context information includes at least one of the following: tenant identifier, user identifier, request source, tracing number, and context version number; Generate tenant context information, timestamp of data access request, and message authentication code signature corresponding to service key. Combine message authentication code signature with tenant context signature as tenant information. The message authentication code signature is used for signature verification by the called service. The tenant information is combined and stored in a thread-local variable that is already available for the current request.

[0052] Among them, tenant context information refers to the tenant's operating environment information formed around this access, which may include only one of the following: tenant identifier, user identifier, request source, tracing number, and context version number, or multiple or all of them; user identifier refers to the specific user identity that initiated the access; request source refers to the source location or source method of the access request entering the system; timestamp refers to the time record corresponding to the generation of the signature; service key refers to the key used by the service side to generate and verify the signature; message authentication code signature refers to the verification result calculated based on the tenant context information, timestamp, and service key, used to verify whether the information is trustworthy and whether it has been tampered with.

[0053] Specifically, based on this request, corresponding tenant context information is constructed, allowing one or more of the following information to be incorporated into the identity criteria: tenant identity, user identity, request source, call chain, and context version. Then, a message authentication code signature is generated by combining the timestamp and service key. This signature, along with the tenant context signature, forms the tenant information combination, enabling the called service to verify the integrity and trustworthiness of the identity during request transmission based on the signature result. The tenant information combination is then saved to a thread-local variable of the current request thread, ensuring that subsequent access processing can directly obtain a consistent tenant identity criterion. This prevents tenant information from being lost, tampered with, or incorrectly replaced during cross-step processing, thereby improving the reliability of tenant information generation and the security of subsequent signature verification.

[0054] In one embodiment, after storing the tenant information in a thread-local variable already present in the current request, the method further includes: In response to a completion or exception feedback instruction for a data access request, clear the tenant information combination in the thread-local variable.

[0055] Among them, the completion feedback instruction refers to the feedback information generated after the normal execution of the data access request, which is used to indicate that the current request processing flow has been completed; the exception feedback instruction refers to the feedback information generated when an error, interruption or exception occurs during the execution of the data access request, which is used to indicate that the current request failed to complete according to the normal process; the tenant information combination in the thread local variable refers to the set of information such as tenant identity, tenant context signature, and message authentication code signature stored in the current request thread.

[0056] Specifically, after storing the tenant information combination in the thread-local variable of the current request thread, this tenant information is not retained indefinitely. Instead, it is promptly cleared from the thread-local variable upon receiving a completion or exception feedback instruction for the data access request. Regardless of whether the request completes normally or terminates due to an exception, the tenant-related information stored in the current thread is released during the request termination phase, preventing tenant information from the previous request from remaining in the next request when threads are reused. This reduces the risk of tenant context misuse, cross-referencing, or leakage, and improves the reliability of tenant isolation and the security of data access processing in thread reuse scenarios.

[0057] In one embodiment, after obtaining the data access request, the method further includes: Determine the tenant level corresponding to the data access request; In response to the tenant level being the first preset level, the independent database corresponding to the data access request is determined as the target data source, and the subquery statement processed by the tenant constraint is executed through the independent database. In response to the tenant level being the second preset level, the shared database is determined as the target data source, and a subquery statement processed by the tenant constraints is executed through the shared database; wherein, during the execution of the subquery statement, database-level isolation and row-level filtering are performed based on the tenant identity information and / or tenant context information of the requesting tenant.

[0058] Among them, tenant level refers to the level type pre-classified according to the business attributes, security requirements, resource configuration methods or isolation requirements of the requesting tenant; the first preset level refers to the tenant level that requires access processing through an independent database; the second preset level refers to the tenant level that can use a shared database for access processing; an independent database refers to the data storage space configured separately for the corresponding tenant; a shared database refers to the data storage space shared by multiple tenants but with data scopes distinguished by isolation rules; database-level isolation refers to limiting data access for different tenants to the corresponding database scope at the database selection level; row-level filtering refers to filtering data rows in the same database based on tenant identity conditions to restrict requests to accessing only the data of the corresponding tenant.

[0059] Specifically, after receiving a data access request, the tenant level corresponding to the request is first determined, and the appropriate target data source is selected based on the tenant level. If the tenant level is the first preset level, the independent database corresponding to the request is determined as the target data source, and a subquery statement processed by tenant constraints is executed through this independent database, ensuring that data access for this type of tenant is completed within an independent storage space. If the tenant level is the second preset level, the shared database is determined as the target data source, and a subquery statement processed by tenant constraints is executed through the shared database. During execution, database-level isolation and row-level filtering are performed based on the tenant identity information and / or tenant context information of the requesting tenant, ensuring that access in the shared database is still restricted to the data range corresponding to the requesting tenant. This allows for different data source routing and isolation methods to be used for different tenant levels, satisfying both independent database access in high-isolation scenarios and tenant identity filtering in shared database scenarios, thereby improving the flexibility of data source configuration, the accuracy of tenant access control, and the security of multi-tenant data isolation.

[0060] In one embodiment, data access processing under normal access conditions.

[0061] After logging into the procurement system, a procurement officer from company A initiates a purchase order query request. The system first extracts the tenant's identity information based on the identity token corresponding to the login identity, determining that the current access subject belongs to tenant A. Simultaneously, the system also obtains the tenant's identifier from the identity source in the request header and / or the domain prefix identity source, comparing at least two types of identity sources from the identity token, request header, and domain prefix. Since all identity sources point to tenant A, the system determines that the requesting tenant has passed multi-source identity verification.

[0062] After the multi-source identity information verification is successful, the system constructs the tenant context information corresponding to this purchase order query request. The tenant context information includes at least one of the following: tenant identifier, user identifier, request source, tracing number, and context version number. Subsequently, the system generates a message authentication code signature based on the tenant context information, the timestamp of the data access request, and the service key, and stores the message authentication code signature and the tenant context signature together as a combination of tenant information in the thread-local variable of the current request thread.

[0063] The system determines that the tenant context information corresponding to the data access link is also tenant A, based on the tenant identifier passed in the request header and the tenant context information stored in the service processing thread. When the request is passed between services, the current service calls the request interceptor to obtain the identity tenant identifier from the thread-local variable of the current request thread and writes the identity tenant identifier into the request header, enabling the called service to read the request header and obtain the identity tenant identifier. The called service further extracts at least two types of information factors from the tenant information combination, including the tenant identifier, the tracking identifier, and the tenant context signature, and compares these information factors with the tenant context of the current thread of the called service, the tenant identifier of the parent node of the call chain, and the business permission matrix.

[0064] The system identifies the target access object for this query and finds that the tenant field in the purchase order record belongs to tenant A. Combining this with the data source registration information, the system determines that the data source to be accessed belongs to tenant A. The system also uses the tenant identifier in the tenant information combination as the lookup key to query the registry of the target data source and compares the tenant information combination with the information status indicators in the registry. These information status indicators include the tenant identifier, lookup key, the tenant to which the target data source belongs, and the tenant status of the requesting tenant. Since all information status indicators in the registry correspond to tenant A, the system returns the lookup key of the target data source.

[0065] After obtaining the tenant identity information, tenant context information, target tenant information, and data source owner tenant information, the system determines the identity tenant identifier, context tenant identifier, target tenant identifier, and data source owner tenant identifier, respectively. Since all four identifiers are for tenant A, and multiple information factors in the tenant information combination match the current thread tenant context, the call chain parent node tenant identifier, and the business permission matrix, the system determines that there is no tenant isolation anomaly in this data access request.

[0066] Subsequently, the system parses the purchase order query statement and finds that it lacks tenant constraints. The system further verifies whether the purchase order query statement matches the preset tenant isolation annotation and space whitelist. If both match, the system adds an identity tenant identifier to the query statement based on the tenant identifier corresponding to the trusted tenant in the tenant context. The system also parses the subqueries contained in the original query statement and injects tenant filtering conditions containing the identity tenant identifier into the subqueries, thus limiting both the outer query and the subqueries to the data range of tenant A.

[0067] After completing the tenant constraint processing, the system selects the data source corresponding to tenant A based on the tenant information of the data source and the lookup key returned by the registry, and executes the query. Ultimately, it only returns the list of purchase orders under tenant A's name, thus achieving tenant isolation access under normal circumstances. When the system receives the completion feedback instruction for this data access request, it clears the tenant information combination stored in the thread-local variables of the current request thread to avoid tenant context residue during thread reuse.

[0068] In one embodiment, risk assessment and blocking are implemented when tenant identifiers do not match.

[0069] When a user of supplier company B initiates a contract details query request, upon entering the contract service, the system first determines the tenant identity information corresponding to the access subject as tenant B based on the identity token. Simultaneously, the system obtains the tenant identifier from the identity source in the request header and / or the domain prefix identity source, and compares the tenant identifiers obtained from at least two identity source sources. If the identity token, the tenant identifier corresponding to the request header, and / or the domain prefix all point to tenant B, the system only determines that the requesting tenant's identity source is consistent; however, this result does not directly indicate that the user can access the target contract data.

[0070] The system determines the context tenant identifier in the current processing chain based on the tenant identifier transmitted in the current processing chain and the tenant context information in the thread. The system also generates a message authentication code signature based on the tenant context information, timestamp, and service key, forming a tenant information combination including the tenant context signature, which is stored in a thread-local variable of the current request thread. In thread switching scenarios such as thread pool calls or message queue calls, the system creates a signature snapshot corresponding to the tenant context signature and uses the link tracing number and context version number in the signature snapshot to verify the signature information stored in the current thread. If the link tracing number does not match, the matching is deemed unsuccessful; if the context version number does not match, the timeliness is deemed unsuccessful.

[0071] Simultaneously, the system analyzes the contract object corresponding to this access, identifies that the target contract record belongs to tenant A, and further determines that the tenant identifier of the target data source is also tenant A based on the data source attribution relationship. The system uses the tenant identifier in the tenant information combination as the lookup key to query the registry of the target data source, and compares the tenant information combination with the tenant identifier, lookup key, the tenant attribution of the target data source, and the tenant status of the requesting tenant in the registry. Since the requesting tenant is tenant B, and both the target contract record and the target data source belong to tenant A, the information status indicators in the registry cannot form a consistent match with the current tenant information combination.

[0072] Based on this, the system compares the identity tenant B with the context tenant identifier, the target tenant identifier, and the data source owner tenant identifier. Since neither the target tenant identifier nor the data source owner tenant identifier matches the identity tenant identifier, the system determines that this data access request has a tenant isolation anomaly. Simultaneously, the system associates the current tracing number with the current anomaly to record that the anomaly occurred in the contract details query chain; if the comparison results show that the requesting tenant cannot be identified in the registry or trusted tenant relationships, it is further marked as a tenant unknown anomaly. In this embodiment, the requesting tenant B can be identified, but its owner tenant is inconsistent with the target contract data and the target data source, therefore, it belongs to a tenant isolation anomaly caused by tenant identifier mismatch.

[0073] Once a risk assessment is established, the system immediately generates corresponding blocking control information. Based on this information, the system intercepts the contract query request, preventing it from proceeding to the subsequent data access execution stage, and returns an access denial result to the request initiator. **If the tenant information combination has already been stored in a thread-local variable during the request processing, the system clears the tenant information combination from the thread-local variable after receiving an exception feedback instruction.** This process identifies and blocks cross-tenant access risks before access actually reaches the target data, preventing tenant B from accessing tenant A's contract data.

[0074] In one embodiment, data source selection and constraint enforcement are performed under different tenant tiers.

[0075] The platform contains both high-isolation-level tenants and shared-deployment tenants. Enterprise C belongs to the first preset level tenant and uses an independent database deployment; Enterprise D belongs to the second preset level tenant and uses a shared database deployment. After Enterprise C initiates a business data query request, the system first performs multi-source identity verification based on at least two identity identifiers from the identity token, request header, and / or domain name prefix, and determines that the current accessing tenant is Enterprise C based on the link context. The system generates a tenant information combination corresponding to Enterprise C, and uses the tenant identifier, link tracing number, context version number, and tenant context signature for subsequent isolation verification.

[0076] The system then combines the target access object and data source attribution to complete the risk assessment. When all tenant identifiers are consistent, the system confirms that the request does not have any tenant isolation anomalies and further determines that the tenant level corresponding to Enterprise C is the first preset level. Based on this level, the system selects the database independently used by Enterprise C as the target data source. **Before executing the query, the system parses the original query statement and its subqueries; if the statement does not carry a tenant identity identifier, it first verifies whether the statement conforms to the preset tenant isolation annotation and space whitelist. After successful verification, it injects the tenant identity identifier corresponding to Enterprise C as a tenant filtering condition.** Subsequently, the system executes the subquery statement processed by tenant constraints through Enterprise C's independent database, thereby achieving independent data access for tenants with high isolation levels.

[0077] When enterprise D initiates a similar query request, the system first determines the tenant's identity information, tenant context information, target tenant information, and the tenant information to which the data source belongs. After confirming that there are no tenant isolation anomalies, the system identifies the tenant level corresponding to enterprise D as the second preset level. Based on this level, the system determines the shared database as the target data source. For the shared database, the system confirms in the registry that the shared database belongs to the data source range that is allowed to be accessed by tenants of the second preset level, and completes the data access link routing based on the lookup key corresponding to enterprise D.

[0078] Before executing a data access statement, the system parses the statement and adds tenant constraints to it based on the tenant identity information corresponding to Enterprise D. For subqueries contained in the original query statement, the system also injects tenant filtering conditions containing the tenant identifier of Enterprise D. If the subquery statement includes an update statement, delete statement, add statement, or select query statement, the system further verifies whether the target data source belongs to a data domain accessible to Enterprise D. Only when the target data source is a data domain accessible to Enterprise D is the corresponding data access operation allowed.

[0079] During shared database execution, database-level isolation and row-level filtering are implemented by combining tenant identity information or tenant context information, ensuring that the query results retain only the data records corresponding to enterprise D. **If the system identifies a subquery statement as a cross-tenant query statement, a full table update statement with an unconditional filter clause, or a batch abnormal row count statement awaiting review, the data access request is first suspended and a review request is generated; only after receiving a pass instruction in response to the review request is the data access operation represented by the statement awaiting review allowed to proceed.** Through this implementation method, different tenant levels can adapt to the access modes of independent or shared databases respectively, while still maintaining effective isolation of tenant data boundaries.

[0080] In one embodiment, statement execution is blocked in the event of an explicit tenant constraint conflict.

[0081] When a user of Tenant A initiates a data query request, the system identifies the tenant as Tenant A after completing tenant identification. During the identification process, the system can also compare at least two identity sources from the identity token, request header, and domain name prefix, and form a trusted tenant context corresponding to Tenant A if the comparison matches.

[0082] When performing tenant constraint processing on data access statements, the system first parses the statement and discovers that an explicit tenant constraint already exists within it. Upon further extraction of the tenant identifier corresponding to this explicit constraint, the system finds that the tenant identifier is tenant B, not tenant A corresponding to the current identity information. At this point, the system compares the identity tenant identifier tenant B in the original query statement with the preset trusted tenant context tenant A, confirming that the two do not match.

[0083] In this situation, the system will not add new tenant constraints to the statement. Instead, it will directly determine that the explicit tenant constraints in the current statement do not match the identity tenant identifier, and accordingly block the execution of the data access statement. The system can also associate this blocking result with the current link tracing number to form a traceable tenant isolation anomaly record. If the query statement is a cross-tenant query statement awaiting review, the system will not allow it directly, but will abort the data access request and generate a review request; only if the approval instruction is obtained and it is confirmed to conform to the business permission matrix will subsequent execution be allowed.

[0084] The request is therefore unable to access subsequent data sources and will not return the target query results. This implementation process allows for validation of the tenant scope carried by the access statement itself before execution, preventing the access subject from bypassing normal tenant boundary control by constructing statements with incorrect tenant conditions. After the request is blocked and an exception feedback instruction is generated, the system clears the tenant information combination stored in the thread-local variables of the current request thread, thereby preventing tenant context remnants from the abnormal request from affecting subsequent request processing.

[0085] An embodiment of this application also provides an electronic device, including: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above data access method; The interaction module, connected to the processor and memory, is used to obtain data access requests from external input and output the access results to the outside.

[0086] An embodiment of this application also provides a computer-readable storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the steps of the above-described data access method.

[0087] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0088] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores training data for the detection model. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps of the data access method embodiment.

[0089] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data access method embodiments.

[0090] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0091] The data access method provided in this application has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A data access method, characterized in that, The method includes: Get data access request; The requesting tenant of the data access request shall undergo multi-source identity verification; In response to the requesting tenant passing the multi-source identity information verification, a tenant information combination corresponding to the requesting tenant is generated; The tenant information is used to verify whether the data access request has a tenant isolation anomaly. In response to the determination that the data access request does not have a tenant isolation anomaly, the tenant constraint processing is performed on the data access request, and the data access operation is performed according to the data access link corresponding to the data access request to the corresponding target data source. In response to the determination that the data access request has a tenant isolation anomaly, the data access request is terminated.

2. The data access method according to claim 1, characterized in that, The step of using the tenant information combination to verify whether the data access request has a tenant isolation anomaly includes: Invoke the request interceptor; In response to the call to the request interceptor, the identity tenant identifier corresponding to the request tenant is obtained from the thread-local storage of the current service, and the identity tenant identifier is written into the request header of the request interceptor; The called service reads the request header to obtain the identity tenant identifier and extracts multiple information factors from the tenant information combination; wherein, the information factors include at least two of the tenant identifier, tracking identifier, and tenant context signature; the multiple information factors are compared with the current thread tenant context, call chain parent node tenant identifier, and business permission matrix corresponding to the identity tenant identifier stored by the called service; wherein, the business permission matrix includes the identity tenant identifier and / or the tenant to which the target data source belongs; In response to a data access request being found to have a tenant isolation anomaly, the information factors are matched with at least one of the current thread tenant context, the call chain parent node tenant identifier, and the business permission matrix stored in the called service. In response to the fact that multiple information factors match the current thread tenant context, call chain parent node tenant identifier, and business permission matrix stored in the called service, it is determined that the data access request does not have a tenant isolation anomaly.

3. The data access method according to claim 1, characterized in that, The tenant information combination includes a tenant context signature, and the step of using the tenant information combination to verify whether the data access request has a tenant isolation anomaly includes: Create a signature snapshot corresponding to the tenant context signature; In response to thread switching, the matching and timeliness of the tenant context signature are verified using the signature snapshot; wherein, the thread switching includes at least one of thread pool invocation and message queue invocation; In response to the failure of the matching and / or timeliness of the tenant context signature to pass the verification, the thread local variable is cleared and it is determined that the data access request has a tenant isolation anomaly; If the matching and timeliness of the tenant context signature are verified, it is determined that the data access request does not have a tenant isolation anomaly.

4. The data access method according to claim 3, characterized in that, The signature snapshot includes a link tracing number and a context version number; the verification of the matching and timeliness of the tenant context signature using the signature snapshot includes: Compare the link tracing number and context version number in the two signature snapshots to see if they match the signature information stored in the current thread; If the link tracing number does not match the signature information, the matching is determined to have failed verification; if the context version number does not match the signature information, the timeliness is determined to have failed verification.

5. The data access method according to claim 1, characterized in that, The process of performing tenant constraint processing on the data access request includes: Obtain the original query statement of the data access request; Parse the original query statement to identify whether the original query statement includes an identity tenant identifier; In response to the inclusion of the identity tenant identifier in the original query statement, the identity tenant identifier in the original query statement is compared with a preset trusted tenant context; in response to the match between the identity tenant identifier and the trusted tenant context, the data access request is allowed to be executed; and / or, If the original query statement does not include the identity tenant identifier, verify whether the original query statement matches the preset tenant isolation annotation and space whitelist; if the original query statement matches the tenant isolation annotation and space whitelist, add the tenant identifier of the tenant context trusted tenant as the identity tenant identifier to the original query statement, and allow the execution of the data access request.

6. The data access method according to claim 5, characterized in that, The permission to execute the data access request includes: The subquery statements contained in the original query statement are parsed, and tenant filtering conditions are injected into the subquery statements to implement the tenant constraint processing; wherein, the tenant filtering conditions include the identity tenant identifier; In response to the subquery statement including a data update statement, verify whether the target source is a data domain accessible to the requesting tenant; in response to the target data source being a data domain accessible to the requesting tenant, allow the data access operation represented by the data update statement to be executed; wherein, the data update statement includes at least one of an update statement, a delete statement, an add statement, and a select query statement; and / or, In response to the subquery statement including a statement to be reviewed, the data access request is aborted and a review request to review the data access request is generated. In response to obtaining a pass instruction in response to the review request, the data access operation represented by the statement to be reviewed is allowed to be executed. The statement to be reviewed includes at least one of a cross-tenant query statement, a full table update statement with an unconditional filter clause, and a batch abnormal row count statement.

7. The data access method according to claim 1, characterized in that, The step of routing the data access link corresponding to the data access request to the corresponding target data source to perform the data access operation includes: Obtain the tenant identifier from the tenant information combination, and use the tenant identifier as the lookup key to query the registry of the target data source; Compare whether the tenant information combination matches the information status indicators of the two in the registry; wherein, the information status includes the tenant identifier, search key, the tenant to which the target data source belongs, and the tenant status of the requesting tenant; In response to a match between the tenant information combination and the information status indicators in the registry, the lookup key of the target data source is returned, and the data access operation is performed by routing to the target data source according to the data access link based on the lookup key.

8. The data access method according to claim 7, characterized in that, After comparing the tenant information combination with the information status indicators in the registry, the process further includes: In response to a mismatch between the tenant information combination and the information status indicators in the registry, it is determined that the data access request has a tenant isolation anomaly, and the current link tracing number is associated with the current anomaly; wherein, when the information status mismatch includes the requesting tenant being an unknown tenant, an unknown tenant anomaly is marked.

9. The data access method according to claim 1, characterized in that, The multi-source identity verification of the requesting tenant for the data access request includes: The tenant identifier of the requesting tenant is obtained from multiple identity sources; wherein, the identity source includes at least two of the following: token identity source, request header identity source, and domain name prefix identity source; The multiple tenant identifiers obtained from the multiple identity identifier sources are compared; in response to the matching of the multiple tenant identifiers, it is determined that the requesting tenant has passed the multi-source identity information verification; In response to multiple mismatches of the tenant identifiers, and / or at least one of the identity sources failing to obtain a valid tenant identifier, it is determined that the requesting tenant has failed the multi-source identity information verification, and the data access request is terminated.

10. The data access method according to claim 1, characterized in that, The combination of tenant information corresponding to the requesting tenant includes: Construct the tenant context information corresponding to the data access request and the requesting tenant; wherein, the tenant context information includes at least one of the following: tenant identifier, user identifier, request source, tracing number, and context version number; Generate the tenant context information, the timestamp of the data access request, and the message authentication code signature corresponding to the service key; combine the message authentication code signature and the tenant context signature as the tenant information; wherein, the message authentication code signature is used for signature verification by the called service; The tenant information is combined and stored in the thread-local variable of the current request.

11. The data access method according to claim 10, characterized in that, The step of storing the tenant information in the thread-local variable already present in the current request also includes: In response to a completion feedback instruction or an exception feedback instruction for obtaining the data access request, the tenant information combination in the thread local variable is cleared.

12. The data access method according to claim 1, characterized in that, Following the data access request, the following also includes: Determine the tenant level corresponding to the data access request; In response to the tenant level being a first preset level, the independent database corresponding to the data access request is determined as the target data source, and the subquery statement processed by the tenant constraint is executed through the independent database. In response to the tenant level being the second preset level, a shared database is determined as the target data source, and a subquery statement after tenant constraint processing is executed through the shared database; wherein, during the execution of the subquery statement, database-level isolation and row-level filtering are performed based on the tenant identity information and / or the tenant context information of the requesting tenant.

13. An electronic device, characterized in that, The electronic device includes: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the data access method according to any one of claims 1 to 12; An interaction module, connected to the processor and the memory, is used to acquire data access requests from external input and output access results to the outside.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the data access method according to any one of claims 1 to 12.