Data authority control method and system

By dynamically splicing SQL query conditions and using distributed cache storage permission settings, the problem of insufficient flexibility and scalability of data permission control solutions in the existing technology in multi-tenant and cloud service environments is solved, and fine-grained data access control is realized and efficient permission management.

CN118468320BActive Publication Date: 2024-11-01SHENZHEN DIGITAL INTELLIGENCE CLOUD TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410917660.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-11-01
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

Existing data permission control solutions lack flexibility and scalability in multi-tenant and cloud service environments, making it difficult to meet rapidly changing business needs and fine-grained data access control.

Method used

By querying the database after the user logs in, dynamically splicing SQL query conditions, using distributed cache storage permission settings, interceptor performs permission verification, ensuring that data access follows user permission rules, and updating the cache when permission rules change.

Benefits of technology

It realizes flexible data permission management, improves system response speed and user experience, reduces database load, and ensures fine-grained data access control and real-time permissions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118468320B_ABST
    Figure CN118468320B_ABST
Patent Text Reader

Abstract

The present application relates to a data permission control method and system, and relates to the technical field of data control. The method comprises: after a user account successfully logs in, querying a database based on the logged-in user account to obtain all role information associated with the user account; defining and storing data permission rules in the database; the data permission rules include: permission rules for roles, business domains, business entities, accessible data records and permission operation types; the user is a user of a multi-tenant system; querying a permission rule table based on all associated role information; extracting all relevant permission settings based on the permission rule table; the permission settings include: access control lists, operation permissions and data access scopes; caching the extracted permission setting data in the user session, and maintaining the permission setting data throughout the user session; and allowing or denying based on the permission setting data when a user account initiates a data access request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data authority control, and in particular, to a data authority control method and system. Background Art

[0002] In modern software systems, especially multi-tenant systems and cloud-based services, data isolation and access control are critical issues. Existing data permission control schemes are usually fixed and inflexible, and it is difficult to meet the rapidly evolving business needs and fine-grained data access control. In addition, traditional permission control schemes often lack scalability and adaptability, and cannot effectively cope with the ever-changing permission requirements between different users and business domains.

[0003] Data permission management in existing technologies usually relies on static permission allocation schemes, which lack flexibility and scalability in multi-tenant and cloud service environments. This limits the ability of organizations to flexibly control data access in a rapidly changing business environment. Summary of the invention

[0004] In order to at least partially solve the above technical problems, the present application provides a data permission control method and system.

[0005] In a first aspect, a data permission control method provided in the present application adopts the following technical solution.

[0006] A data authority control method, comprising:

[0007] After the user account successfully logs in, the database is queried based on the logged-in user account to obtain all role information associated with the user account; data permission rules are defined and stored in the database; the data permission rules include: role, business domain, permission rules for business entities, accessible data records and permission operation types; the user is a user of a multi-tenant system;

[0008] Query the permission rule table based on all the associated role information; extract all relevant permission settings based on the permission rule table; the permission settings include: access control list, operation permissions and data access scope;

[0009] caching the extracted permission setting data in the user session, and maintaining the permission setting data throughout the user session;

[0010] When the user account initiates a data access request, permission or rejection is performed based on the permission setting data.

[0011] Optionally, querying the permission rule table based on all the associated role information includes:

[0012] After the user account successfully logs in, parse and confirm the user's role;

[0013] Extracting permission rules related to the role of the user from the permission configuration storage of the database based on the role of the user;

[0014] In the data operation layer, dynamically assemble the where conditions of the SQL query according to the extracted permission rules;

[0015] Execute the modified SQL query to ensure that each database query or modification is performed in accordance with the user's data access permissions.

[0016] Optionally, the extracted permission settings data is cached in the user session, including:

[0017] Write the extracted permission setting data into the distributed cache;

[0018] For subsequent data access requests, first query whether there is permission data corresponding to the data access request in the distributed cache; if there is corresponding permission data in the distributed cache, directly perform permission verification through the cached data in the distributed cache; if there is no corresponding permission data in the distributed cache; reload the permission setting data from the database;

[0019] The distributed cache is updated regularly and cache performance is monitored.

[0020] Optionally, when the user account initiates a data access request, allowing or denying the request based on the permission setting data includes:

[0021] When a user account initiates a data access request, it is captured by an interceptor; the interceptor is integrated into the data processing layer of the server; the data access request includes reading, updating or deleting data;

[0022] The interceptor calls the permission check service; when the permission check service runs, it retrieves the permission rules preloaded in the distributed cache from the user session;

[0023] Determine whether the requested data point matches the cached permission rules; if the data access request matches the user permissions, access is allowed; if not, access is denied and a corresponding error message or warning message is returned.

[0024] Optionally, dynamically stitch the where conditions of the SQL query based on the extracted permission rules at the data operation layer, including:

[0025] Pre-configure a permission rule model, wherein the permission rule model stores permission information of different roles;

[0026] After the user logs in successfully, the user's role is parsed, and the corresponding permission rules are extracted from the permission configuration storage according to the role;

[0027] Constructing a permission parser, which dynamically constructs query conditions according to the user's permission rules;

[0028] Abstract permission rules into query condition templates;

[0029] Construct a dynamic SQL generator, which dynamically generates SQL statements according to the template provided by the authority parser and the actual query requirements;

[0030] When generating SQL queries, combine multiple conditions and optimize the generated query statements;

[0031] When permission rules change, update and synchronize the new permission settings.

[0032] Optionally, write the extracted permission setting data to the distributed cache, including:

[0033] Serialize the permission setting data and convert the permission setting data into a SON string; generate a composite hash key value based on the role, business entity and operation type for each permission setting data, wherein the hash key value is generated based on the role ID, business domain ID and business entity ID;

[0034] Use consistent hashing algorithm to shard permission setting data and evenly distribute data to each cache node; retain data copies on different nodes to prevent data unavailability caused by single point failure;

[0035] Embed version number and timestamp information in permission setting data. Every time permission rules are updated, the version number is updated synchronously. When caching data, the version number and last update time are stored together as a basis for judging the freshness of the data. When querying permissions, compare the version information carried in the request with the version information in the cache to determine whether the permissions need to be reloaded.

[0036] For permission rules that are frequently accessed but infrequently changed, set a longer cache expiration time; for permissions that change frequently, shorten the cache validity period and combine it with an active monitoring mechanism. Once the background permission configuration changes, immediately notify the cache system to update the corresponding data;

[0037] While the permission setting data is written to the database, the atomicity of the data writing operation and the distributed cache update operation is ensured through the distributed transaction mechanism.

[0038] In a second aspect, a data permission control method provided in the present application adopts the following technical solution.

[0039] A data authority control system, comprising:

[0040] The first processing module is used to: after a user account successfully logs in, query the database based on the logged-in user account to obtain all role information associated with the user account; the database defines and stores data permission rules; the data permission rules include: role, business domain, permission rules for business entities, accessible data records and permission operation types; the user is a user of a multi-tenant system;

[0041] The second processing module is used to: query the permission rule table based on all the associated role information; extract all relevant permission settings based on the permission rule table; the permission settings include: access control list, operation permission and data access scope;

[0042] A third processing module is used to: cache the extracted permission setting data in the user session, and keep the permission setting data throughout the user session;

[0043] The fourth processing module is used to: when the user account initiates a data access request, allow or deny it based on the permission setting data.

[0044] In a third aspect, the present application discloses an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that is loaded by the processor and executes any of the above methods.

[0045] In a fourth aspect, the present application discloses a computer-readable storage medium storing a computer program that can be loaded by a processor and execute any of the above methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is a flow chart of a data authority control method according to an embodiment of the present application;

[0047] Figure 2 This is a system block diagram of a data authority control method according to an embodiment of the present application;

[0048] In the figure, 201 is a first processing module; 202 is a second processing module; 203 is a third processing module; 204 is a fourth processing module. DETAILED DESCRIPTION

[0049] The following is combined with Figure 1-Figure 2 The present application is further described with specific embodiments:

[0050] First of all, it should be noted that in the description of this application, if the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside" and other directional words appear, the orientation or position relationship indicated is based on the orientation or position relationship shown in the drawings, which is only for the convenience of description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of this application; in addition, if the terms "first", "second", "third" and other numerical quantifiers appear, they are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in this application, unless otherwise clearly specified and limited, if the terms "installed", "connected", and "connected" appear, they should be understood in a broad sense, for example, it can be a fixed connection, or a detachable connection, a limited connection such as an interference fit, a transition fit, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium; therefore, for ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to the specific circumstances.

[0051] An embodiment of the present application discloses a data permission control method.

[0052] Some of the names are explained below.

[0053] User: refers to a user who can log in to the system to perform operations.

[0054] Role: A set of permissions defined by the system. Users obtain corresponding permissions by being assigned to one or more roles.

[0055] RBAC: Role-Based Access Control is a mature and widely used permission management method that manages and assigns permissions through roles to simplify permission management and improve security.

[0056] Data permissions: Specifies the scope of data that a role can access, such as views, records, fields, etc.

[0057] Tenant: A tenant refers to a user or user group in a multi-tenant system who occupies certain system resources and has an independent data space.

[0058] Business Domain: Business Domain refers to the collection of relevant business logic and data in the system. It usually defines a series of relevant business rules, entities, relationships and processes. For example, the order domain (power station development and construction process), post-rental (power station operation after construction and transportation), purchase, sales and inventory (logistics ordering, inventory management, etc.)

[0059] Business Entity / Table: Business Entity / Table is usually represented as a table in the database, which is a structured form of storing specific types of data in the business domain.

[0060] Business attribute / field: A business attribute / field refers to a specific item in a business entity and is used to describe a specific characteristic, quantity, property, or status of a business entity.

[0061] Reference Figure 1 As an implementation method of a data authority control method, a data authority control method includes the following steps:

[0062] Step S101: After the user account logs in successfully, query the database based on the logged in user account to obtain all role information associated with the user account; define and store data permission rules in the database; the data permission rules include: role, business domain, business entity permission rules, accessible data records and permission operation types; the user is a user of a multi-tenant system.

[0063] Specifically, the user logs in by entering a user name and password. After the system verifies the correctness of the credentials, it grants login permission.

[0064] Step S102, querying the permission rule table based on all the associated role information; extracting all relevant permission settings based on the permission rule table; the permission settings include: access control list, operation permission and data access scope.

[0065] Step S103: caching the extracted permission setting data in the user session, and maintaining the permission setting data throughout the user session.

[0066] Step S104: when the user account initiates a data access request, permission or rejection is performed based on the permission setting data.

[0067] Specifically, a multi-tenant system is an architectural design pattern that allows a single instance of a software application to provide services to multiple organizations (tenants), with each tenant's data and configuration independent and isolated to ensure data privacy and security. In permission management, a role is a set of predefined permissions that represent a user's functions and access rights in the system. Users obtain corresponding permissions by being assigned one or more roles. A business domain refers to an area in the system that focuses on a specific business logic and data set, such as sales, finance, human resources, etc. Each business domain contains specific business entities and operational processes. A business entity refers to a structured object in the system that stores a specific type of business data, such as customers, orders, products, etc. Data permission rules specify the user's access rights on specific business domains and business entities, including which data records and fields can be accessed and the types of operations allowed (such as read, write, delete). Access control lists (ACLs) define a list of rules for which users or roles can access specific resources. Operation permissions refer to the types of operations that users can perform in the system, such as viewing, editing, and deleting data.

[0068] After a user logs in, the system first identifies their identity and obtains all the role information associated with them. Based on the user role, the system queries the permission rule table in the database and extracts all the permission settings related to these roles. The extracted permission data is cached in the user's session, so that during the user session, permissions can be quickly verified without repeatedly querying the database, which significantly improves the system response speed and user experience. Using a caching mechanism (such as Redis) further optimizes performance. When a user tries to access data, the system decides whether to allow the access based on the permission settings cached in the session.

[0069] The technical solution of this application implements a dynamic data rights management and application mechanism, allowing flexible control of data access based on roles, accounts and business rules. Through integrated rights management and dynamic rights application modules, the system can provide fine-grained data access control without sacrificing performance.

[0070] As a specific implementation of a data permission control method, querying a permission rule table based on all the associated role information includes:

[0071] After the user account successfully logs in, parse and confirm the user's role;

[0072] Extracting permission rules related to the role of the user from the permission configuration storage of the database based on the role of the user;

[0073] In the data operation layer, dynamically assemble the where conditions of the SQL query according to the extracted permission rules;

[0074] Execute the modified SQL query to ensure that each database query or modification is performed in accordance with the user's data access permissions.

[0075] Specifically, by parsing user roles and extracting corresponding permission rules, refined management of user permissions is achieved. Dynamically splicing the where conditions of SQL queries at the data operation layer is a specific embodiment of dynamic permission application. This process ensures that even when executing queries or update operations, data can be filtered in real time according to the user's current permissions to prevent unauthorized access. For example, if a user is only allowed to view the data of his or her own department, the system will automatically add the department ID filtering condition to the SQL query to prevent the user from seeing data from other departments. Compared with the need to query the database permission configuration for each operation, dynamically generating SQL query conditions and applying them at the data operation layer reduces the number of database accesses and improves the system's processing speed and response efficiency. Especially in a high-concurrency environment, this approach significantly reduces the database load.

[0076] As a specific implementation of a data permission control method, caching the extracted permission setting data in a user session includes:

[0077] Write the extracted permission setting data into the distributed cache;

[0078] For subsequent data access requests, first query whether there is permission data corresponding to the data access request in the distributed cache; if there is corresponding permission data in the distributed cache, directly perform permission verification through the cached data in the distributed cache; if there is no corresponding permission data in the distributed cache; reload the permission setting data from the database;

[0079] The distributed cache is updated regularly and cache performance is monitored.

[0080] Specifically, by caching the permission setting data in a distributed cache (such as Redis), when the system processes the user's data access request, it can quickly obtain the permission information required for permission verification directly from the cache without querying the database every time. This significantly reduces the frequency of database access and the time cost of I / O operations, thereby improving the efficiency of data access and the response speed of the system. Although the permission data is cached, the timeliness of the permission information is ensured by the mechanism of regularly updating the cache. This means that even if the permission configuration changes (such as the administrator adjusts the permissions of a role), these changes will be reflected in the cache after a certain time interval, and then applied to the permission verification process immediately, ensuring the real-time and accuracy of permission control. The introduction of distributed cache enables the system to maintain good performance in the face of expanding user scale and increasing business complexity. By monitoring cache performance, system administrators can obtain real-time feedback on key indicators such as cache hit rate and response time, which is crucial for optimizing cache strategies and identifying potential problems. For example, if the cache hit rate is found to be low, it may be necessary to adjust the cache strategy or increase the cache capacity; if the cache access delay increases, it is necessary to check whether the cache node load is uneven or the network delay is a problem.

[0081] As a specific implementation of a data permission control method, when the user account initiates a data access request, permission or rejection is performed based on the permission setting data, including:

[0082] When a user account initiates a data access request, it is captured by an interceptor; the interceptor is integrated into the data processing layer of the server; the data access request includes reading, updating or deleting data;

[0083] The interceptor calls the permission check service; when the permission check service runs, it retrieves the permission rules preloaded in the distributed cache from the user session;

[0084] Determine whether the requested data point matches the cached permission rules; if the data access request matches the user permissions, access is allowed; if not, access is denied and a corresponding error message or warning message is returned.

[0085] Specifically, when a user attempts to perform a data access operation (whether it is reading, updating or deleting), the interceptor immediately intervenes at the data processing layer and effectively intercepts all data access requests. The interceptor calls the permission check service, which directly reads the preloaded permission rules (these rules are stored in the distributed cache) from the user session. This process takes advantage of the cache, greatly reduces direct access to the database, speeds up permission verification, and improves system performance. The permission check service accurately matches the specific content of the data access request (such as data type, field, operation type) with the permission rules in the cache, achieving fine-grained permission control. Based on the permission matching results, the system can dynamically decide whether to allow the data access request. If the request matches the user's permissions, the access is successful; if it does not match, the access is immediately denied, and an error or warning message is returned to clearly inform the user that their access rights are insufficient.

[0086] As one implementation method of a data permission control method, dynamically splicing the where condition of the SQL query according to the extracted permission rules at the data operation layer includes:

[0087] Pre-configure a permission rule model, wherein the permission rule model stores permission information of different roles;

[0088] After the user logs in successfully, the user's role is parsed, and the corresponding permission rules are extracted from the permission configuration storage according to the role;

[0089] Constructing a permission parser, which dynamically constructs query conditions according to the user's permission rules;

[0090] Abstract permission rules into query condition templates;

[0091] Construct a dynamic SQL generator, which dynamically generates SQL statements according to the template provided by the authority parser and the actual query requirements;

[0092] When generating SQL queries, combine multiple conditions and optimize the generated query statements;

[0093] When permission rules change, update and synchronize the new permission settings.

[0094] Specifically, through the pre-configured permission rule model, the system can dynamically adjust data access permissions according to user roles, which enables the permission control strategy to adapt to changes in user roles in real time without manually adjusting each SQL query statement. The WHERE conditions of the SQL query are dynamically spliced ​​at the data operation layer to ensure that each data query strictly follows the user's permission boundaries. Even if the user tries to access unauthorized data, the system can automatically block such requests because the permission restrictions have been embedded in the query conditions, effectively preventing potential data leakage risks. The constructed permission parser and dynamic SQL generator can efficiently generate customized query statements based on user permissions, reducing unnecessary data access and reducing database load. At the same time, by merging multiple conditions and optimizing the generated query statements, the query efficiency is further improved. When the permission rules change, you only need to update the corresponding settings in the permission configuration storage, and the parser and SQL generator will automatically generate query conditions dynamically according to the latest permission rules. By abstracting the permission rules into query condition templates, it becomes easier to add new roles or new permissions. You only need to add corresponding entries in the permission rule model without modifying the underlying SQL generation logic. The dynamically generated SQL statements contain the logic of permission control, which facilitates logging and helps administrators monitor permission usage.

[0095] As one implementation of a data permission control method, writing the extracted permission setting data into a distributed cache includes:

[0096] Serialize the permission setting data and convert the permission setting data into a SON string; generate a composite hash key value based on the role, business entity and operation type for each permission setting data, wherein the hash key value is generated based on the role ID, business domain ID and business entity ID;

[0097] Use consistent hashing algorithm to shard permission setting data and evenly distribute data to each cache node; retain data copies on different nodes to prevent data unavailability caused by single point failure;

[0098] Embed version number and timestamp information in permission setting data. Every time permission rules are updated, the version number is updated synchronously. When caching data, the version number and last update time are stored together as a basis for judging the freshness of the data. When querying permissions, compare the version information carried in the request with the version information in the cache to determine whether the permissions need to be reloaded.

[0099] For permission rules that are frequently accessed but infrequently changed, set a longer cache expiration time; for permissions that change frequently, shorten the cache validity period and combine it with an active monitoring mechanism. Once the background permission configuration changes, immediately notify the cache system to update the corresponding data;

[0100] While the permission setting data is written to the database, the atomicity of the data writing operation and the distributed cache update operation is ensured through the distributed transaction mechanism.

[0101] Specifically, by serializing the permission setting data into a JSON string and storing it in a distributed cache, direct access to the database is reduced for each permission verification. Generating a composite hash key value and using a consistent hash algorithm for sharding not only ensures uniform distribution of data, but also improves the fault tolerance of the system by retaining data copies on different nodes. Even if a node fails, permission information can still be obtained from other copies to ensure service continuity. By embedding version numbers and timestamps in cached data and synchronously updating these metadata each time the permission rules are updated, the system can effectively determine the freshness of permission data and ensure data consistency and accuracy. The cache expiration time is dynamically adjusted according to the frequency of permission rule changes. A longer period is set for rules that do not change frequently, while the validity period is shortened for rules that change frequently. Combined with the active monitoring mechanism, efficient resource utilization and real-time requirements are achieved, balancing performance and data timeliness. The distributed transaction mechanism is used to ensure that the synchronization update operation of permission data between the database and the cache system is atomic, that is, either both operations are successful or both fail, avoiding data inconsistency problems and ensuring the rigor of permission control and the integrity of system data.

[0102] This application also provides a data permission control method, including:

[0103] The first processing module 201 is used to: after a user account successfully logs in, query the database based on the logged-in user account to obtain all role information associated with the user account; define and store data permission rules in the database; the data permission rules include: permission rules for roles, business domains, business entities, accessible data records and permission operation types; the user is a user of a multi-tenant system;

[0104] The second processing module 202 is used to: query the permission rule table based on all the associated role information; extract all relevant permission settings based on the permission rule table; the permission settings include: access control list, operation permission and data access scope;

[0105] The third processing module 203 is used to: cache the extracted permission setting data in the user session, and keep the permission setting data throughout the user session;

[0106] The fourth processing module 204 is used to: when the user account initiates a data access request, allow or deny the request based on the permission setting data.

[0107] The embodiment of the present application also discloses an electronic device.

[0108] Specifically, the device includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and execute any of the above-mentioned data authority control methods.

[0109] The embodiment of the present application also discloses a computer-readable storage medium. Specifically, the computer-readable storage medium stores a computer program that can be loaded by a processor and execute any of the above-mentioned data authority control methods, and the computer-readable storage medium includes, for example: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0110] It should be noted that the above embodiments are only used to illustrate the present application and are not intended to limit the technical solutions described in the present application. Although the present application has been described in detail in this specification with reference to the above embodiments, a person of ordinary skill in the art should understand that a person of ordinary skill in the art can still modify or make equivalent substitutions to the present application, and all technical solutions and improvements thereof that do not depart from the spirit and scope of the present application should be included in the scope of the claims of the present application.

Claims

1. A data authority control method, characterized in that: include: After the user account logs in successfully, query the database based on the logged in user account to obtain all role information associated with the user account; Defining and storing data permission rules in the database; The data permission rules include: permission rules for roles, business domains, business entities, accessible data records, and permission operation types; the user is a user of a multi-tenant system; Query the permission rule table based on all the associated role information; extract all relevant permission settings based on the permission rule table; the permission settings include: access control list, operation permissions and data access scope; caching the extracted permission setting data in the user session, and maintaining the permission setting data throughout the user session; When the user account initiates a data access request, allowing or denying the request based on the permission setting data; Query the permission rule table based on all the associated role information, including: After the user account successfully logs in, parse and confirm the user's role; Extracting permission rules related to the role of the user from the permission configuration storage of the database based on the role of the user; In the data operation layer, dynamically assemble the where conditions of the SQL query according to the extracted permission rules; Execute the modified SQL query to ensure that each database query or modification is performed in accordance with the user's data access rights; Cache the extracted permission setting data in the user session, including: Write the extracted permission setting data into the distributed cache; For subsequent data access requests, first query whether there is permission data corresponding to the data access request in the distributed cache; if there is corresponding permission data in the distributed cache, directly perform permission verification through the cached data in the distributed cache; if there is no corresponding permission data in the distributed cache; reload the permission setting data from the database; Regularly updating the distributed cache and monitoring cache performance; When the user account initiates a data access request, permission or rejection is performed based on the permission setting data, including: When a user account initiates a data access request, it is captured by an interceptor; the interceptor is integrated into the data processing layer of the server; the data access request includes reading, updating or deleting data; The interceptor calls the permission check service; when the permission check service runs, it retrieves the permission rules preloaded in the distributed cache from the user session; Determine whether the requested data point matches the cached permission rules; if the data access request matches the user's permissions, access is allowed; if not, access is denied and a corresponding error message or warning message is returned; In the data operation layer, dynamically stitch the where conditions of the SQL query according to the extracted permission rules, including: Pre-configure a permission rule model, wherein the permission rule model stores permission information of different roles; After the user logs in successfully, the user's role is parsed, and the corresponding permission rules are extracted from the permission configuration storage according to the role; Constructing a permission parser, which dynamically constructs query conditions according to the user's permission rules; Abstract permission rules into query condition templates; Construct a dynamic SQL generator, which dynamically generates SQL statements according to the template provided by the authority parser and the actual query requirements; When generating SQL queries, combine multiple conditions and optimize the generated query statements; When permission rules change, update and synchronize new permission settings; Write the extracted permission setting data to the distributed cache, including: Serialize the permission setting data and convert the permission setting data into a SON string; generate a composite hash key value based on the role, business entity and operation type for each permission setting data, wherein the hash key value is generated based on the role ID, business domain ID and business entity ID; Use consistent hashing algorithm to shard permission setting data and evenly distribute data to each cache node; retain data copies on different nodes to prevent data unavailability caused by single point failure; Embed version number and timestamp information in permission setting data. Every time permission rules are updated, the version number is updated synchronously. When caching data, the version number and last update time are stored together as a basis for judging the freshness of the data. When querying permissions, compare the version information carried in the request with the version information in the cache to determine whether the permissions need to be reloaded. For permission rules that are frequently accessed but infrequently changed, set a longer cache expiration time; for permissions that change frequently, shorten the cache validity period and combine it with an active monitoring mechanism. Once the background permission configuration changes, immediately notify the cache system to update the corresponding data; While the permission setting data is written to the database, the atomicity of the data writing operation and the distributed cache update operation is ensured through the distributed transaction mechanism.

2. A data authority control system, characterized in that: include: The first processing module is used to: after the user account logs in successfully, query the database based on the logged-in user account to obtain all role information associated with the user account; Defining and storing data permission rules in the database; The data permission rules include: permission rules for roles, business domains, business entities, accessible data records, and permission operation types; the user is a user of a multi-tenant system; The second processing module is used to: query the permission rule table based on all the associated role information; extract all relevant permission settings based on the permission rule table; the permission settings include: access control list, operation permission and data access scope; A third processing module is used to: cache the extracted permission setting data in the user session, and keep the permission setting data throughout the user session; A fourth processing module, configured to: when the user account initiates a data access request, allow or deny the request based on the permission setting data; Query the permission rule table based on all the associated role information, including: After the user account successfully logs in, parse and confirm the user's role; Extracting permission rules related to the role of the user from the permission configuration storage of the database based on the role of the user; In the data operation layer, dynamically assemble the where conditions of the SQL query according to the extracted permission rules; Execute the modified SQL query to ensure that each database query or modification is performed in accordance with the user's data access rights; Cache the extracted permission setting data in the user session, including: Write the extracted permission setting data into the distributed cache; For subsequent data access requests, first query whether there is permission data corresponding to the data access request in the distributed cache; if there is corresponding permission data in the distributed cache, directly perform permission verification through the cached data in the distributed cache; if there is no corresponding permission data in the distributed cache; reload the permission setting data from the database; Regularly updating the distributed cache and monitoring cache performance; When the user account initiates a data access request, permission or rejection is performed based on the permission setting data, including: When a user account initiates a data access request, it is captured by an interceptor; the interceptor is integrated into the data processing layer of the server; the data access request includes reading, updating or deleting data; The interceptor calls the permission check service; when the permission check service runs, it retrieves the permission rules preloaded in the distributed cache from the user session; Determine whether the requested data point matches the cached permission rules; if the data access request matches the user's permissions, access is allowed; if not, access is denied and a corresponding error message or warning message is returned; In the data operation layer, dynamically stitch the where conditions of the SQL query according to the extracted permission rules, including: Pre-configure a permission rule model, wherein the permission rule model stores permission information of different roles; After the user logs in successfully, the user's role is parsed, and the corresponding permission rules are extracted from the permission configuration storage according to the role; Constructing a permission parser, which dynamically constructs query conditions according to the user's permission rules; Abstract permission rules into query condition templates; Construct a dynamic SQL generator, which dynamically generates SQL statements according to the template provided by the authority parser and the actual query requirements; When generating SQL queries, combine multiple conditions and optimize the generated query statements; When permission rules change, update and synchronize new permission settings; Write the extracted permission setting data to the distributed cache, including: Serialize the permission setting data and convert the permission setting data into a SON string; generate a composite hash key value based on the role, business entity and operation type for each permission setting data, wherein the hash key value is generated based on the role ID, business domain ID and business entity ID; Use consistent hashing algorithm to shard permission setting data and evenly distribute data to each cache node; retain data copies on different nodes to prevent data unavailability caused by single point failure; Embed version number and timestamp information in permission setting data. Every time permission rules are updated, the version number is updated synchronously. When caching data, the version number and last update time are stored together as a basis for judging the freshness of the data. When querying permissions, compare the version information carried in the request with the version information in the cache to determine whether the permissions need to be reloaded. For permission rules that are frequently accessed but infrequently changed, set a longer cache expiration time; for permissions that change frequently, shorten the cache validity period and combine it with an active monitoring mechanism. Once the background permission configuration changes, immediately notify the cache system to update the corresponding data; While the permission setting data is written to the database, the atomicity of the data writing operation and the distributed cache update operation is ensured through the distributed transaction mechanism.

3. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program according to the method of claim 1 which is loaded and executed by the processor.

4. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method as claimed in claim 1.

Citation Information

Cited By

  • System and method for detecting and preventing anomalous behavior of non-interactive machine to machine database accounts

    US12775725B2

  • System and method for detecting and preventing anomalous behavior of non-interactive machine to machine database accounts

    US20250335614A1