User authority control method and device

Through the hash structure, storing user interface permissions and adding permission annotations to the back-end interface layer, the problem of insufficient fine-grained user permission control in the existing technology is solved, and more fine-grained permission allocation and interface security is achieved, improving user experience .

CN119046906AInactive Publication Date: 2024-11-29SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411118508.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2024-11-29
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing user permission control methods have shortcomings in fine-grained allocation, especially in the case of multiple operation buttons or tab pages, it is difficult for the RBAC model to achieve fine-grained permission allocation, resulting in role redundancy.

Method used

The user interface permissions are stored through a hash structure, and permission annotations are added at the backend interface layer. The permission encoding is obtained using the surrounding notification and reflection mechanism, and the permissions are obtained from the database in combination with the user ID, so as to achieve fine-grained matching and control of interface permissions.

Benefits of technology

It realizes finer-grained permission allocation, reduces role redundancy, improves interface security, and improves user operation experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046906A_ABST
    Figure CN119046906A_ABST
Patent Text Reader

Abstract

According to the user permission control method and device provided by the invention, the user operation permission can be matched with the back-end interface layer operation permission, so that finer-grained distribution of the user permission is realized. The user permission control method comprises the following steps: acquiring a preset user interface permission; based on a hash structure, storing the user interface permission through a first key value; adding a permission annotation to each back-end interface; wherein the value of the annotation represents the authority code of the interface; when a target interface is called, comparing the stored user interface permission with the permission annotation of the target interface; wherein the target interface is any rear-end interface; when the permission annotation of the target interface exists in the stored user interface permission, the target interface is allowed to be called.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of authority management, and in particular to a user authority control method and device. Background Art

[0002] With the rapid development of information technology, especially its widespread application in cloud computing, big data, the Internet of Things, and financial technology, user permission control has become a key link in ensuring system security, data privacy, and business continuity. In terms of usage scenarios, most existing permission controls use a combination of the RBAC model and the ACL model. The usual model consists of three parts: user module, role module, and permission module. User permission control is achieved by defining roles, defining permissions, assigning permissions to roles, and then assigning roles to users. The disadvantage of this method is that user permissions are implicit. When there are multiple operation buttons on the same page, or multiple tab pages on the same page, and different buttons or input boxes on different tab pages require different permissions, the RBAC method cannot achieve very fine-grained allocation. If they are assigned one by one, a large number of role redundancies will be caused. Summary of the invention

[0003] In order to solve the above technical problems, the present invention is proposed. The embodiments of the present invention provide a user authority control method and device, which can achieve more fine-grained allocation of user authority by matching user operation authority with back-end interface layer operation authority.

[0004] According to one aspect of the present invention, a user permission control method is provided, including: obtaining preset user interface permissions; based on a hash structure, storing the user interface permissions through a first key value; adding permission annotations to each backend interface; wherein the annotation value represents the permission code of the interface; when calling a target interface, comparing the stored user interface permissions and the permission annotations of the target interface; wherein the target interface is any backend interface; when the permission annotation of the target interface exists in the stored user interface permissions, allowing the target interface to be called.

[0005] In one embodiment, based on a hash structure, the user interface permissions are stored through a first key value, including: when a user logs in, the preset user interface permissions corresponding to the user are stored in a database, and the user interface permissions are stored using the first key value; wherein the user permission control method also includes: storing a user menu through a second key value.

[0006] In one embodiment, the user permission control method also includes: adding a permission aspect, the entry point of the permission aspect is defined to the permission annotation to be woven into the interface; using surround notification to obtain the method of the entry point by reflection to obtain the permission annotation on the method; based on the permission annotation on the method, obtaining the permission code of the interface; obtaining the ID of the current user through the context to obtain the user interface permissions from the database.

[0007] In one embodiment, when calling the target interface, the stored user interface permissions and the permission annotations of the target interface are compared, including: comparing the permission code and the user interface permissions obtained from the database to obtain a comparison result; wherein, when the permission annotation of the target interface exists in the stored user interface permissions, calling the target interface is allowed, including: when the comparison result indicates that the permission code corresponds to the user interface permissions stored in the database, releasing the method in the aspect.

[0008] In one embodiment, the user authority control method also includes: presetting the front-end authority code on the front-end; obtaining a user authority list through the user interface authority stored by the first key value; when the front-end authority code exists in the user authority list, inserting a new view and displaying an operation button in the view; wherein the operation button corresponds to the user interface authority; when the front-end authority code does not exist in the user authority list, the operation button is not displayed.

[0009] In one embodiment, the user permission control method further includes: using a custom instruction PermissionDirective for the operation button that requires permission control; and adding the custom instruction PermissionDirective to the container to control the visibility or hiding of the operation button.

[0010] In one embodiment, the user authority control method also includes: when the permission annotation of the target interface does not exist in the stored user interface permissions, calling the interface is not allowed and an exception prompt is issued; wherein the exception prompt is used to remind the user that there is no operation permission; based on the permission annotation of the target interface and the exception prompt, a permission information prompt is issued to the user; wherein the permission information prompt is used to prompt the user that the user lacks the permission required to perform the operation.

[0011] In one embodiment, based on a hash structure, the user interface permissions are stored through a first key value, including: creating a hash table to store the user's interface permission information; inserting a first key-value pair into the hash table; wherein the key in the first key-value pair includes a license key, and the first key value in the first key-value pair includes the user interface permissions; wherein the user permission control method includes: based on a query instruction, searching for the corresponding user interface permissions through the key in the first key-value pair.

[0012] In one embodiment, the user authority control method includes: when a first target user interface authority among user interface authorities undergoes an authority change, searching for the corresponding first target user interface authority through the key in the first key-value pair and executing the change; recording the change information of the first target user interface authority and analyzing the change information to obtain a user authority change record; overwriting the first target user interface authority with a new user interface authority and storing it.

[0013] According to another aspect of the present invention, a user authority control device is provided, comprising: an acquisition module for acquiring preset user interface permissions; a storage module for storing the user interface permissions through a first key value based on a hash structure; an annotation module for adding permission annotations to each backend interface; wherein the annotation value represents the permission code of the interface; a comparison module for comparing the stored user interface permissions and the permission annotations of the target interface when calling a target interface; wherein the target interface is any backend interface; and a calling module for allowing the target interface to be called when the permission annotation of the target interface exists in the stored user interface permissions.

[0014] The user authority control method and device provided by the present invention store user authority through a hash structure, can define multiple keys, are more flexible, and achieve the purpose of controlling user operation authority by matching the user operation authority of the memory data with the operation authority of the back-end interface layer, and can realize more fine-grained authority allocation, thereby ensuring the security of the interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The above and other purposes, features and advantages of the present invention will become more apparent by describing the embodiments of the present invention in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings, the same reference numerals generally represent the same components or steps.

[0016] Figure 1 It is a flowchart of a user authority control method provided by an exemplary embodiment of the present invention.

[0017] Figure 2 It is a flowchart of a user authority control method provided by another exemplary embodiment of the present invention.

[0018] Figure 3 It is a structural diagram of a user authority control device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0019] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.

[0020] Figure 1 is a flow chart of a user authority control method provided by an exemplary embodiment of the present invention, such as Figure 1 As shown, the user authority control method includes:

[0021] S100: Obtaining preset user interface permissions.

[0022] By customizing permissions and roles, and then assigning permissions to roles, preset user interface permissions are formed. For example, the RBAC (Role-Based Access Control) model can be used as the basis for permission allocation. The RBAC model aims to control access rights to system resources (such as data, application functions, etc.) by assigning specific roles to different users or user groups. The core concepts of the RBAC model include: Role, which is the basic unit in the RBAC model and represents a set of permissions. Each role is given the permission to perform specific operations or access specific resources; User, the user is the actual operator of the system, and they obtain corresponding permissions by being assigned to different roles. A user can be assigned one or more roles, but each role is usually associated with multiple users; Permission: Permission refers to the right to perform specific operations or access specific resources. In the RBAC model, permissions are not directly assigned to users, but indirectly assigned through roles; Session: A session is a process in which a user interacts with the system. In the RBAC model, a session is used to track the role and permission status of a user within a specific time period to ensure the dynamic and timeliness of permissions; Constraint: Constraints are used to limit the allocation of roles, users, permissions, and the relationships between them. These constraints can ensure the security and compliance of the system, such as preventing permission conflicts between roles or users from having too high permissions.

[0023] S200: Based on the hash structure, store the user interface permission through the first key value.

[0024] Hash structure, also known as hash table or hash table, is a very important data structure used to store key-value pairs. It quickly locates data by calculating the hash value of a key, thereby achieving fast data access. Hash structure can be accessed quickly, and compared with other data structures (such as balanced binary trees), hash tables are usually more space-efficient when storing key-value pairs because they do not need to maintain additional data structures (such as tree node links) to keep the order of data. When storing user permissions, applications based on the RBAC model do not use the traditional list data type. Instead, they combine the user's menu permissions and data permissions, expand the list data type to a hash type, and use the hash structure of redis to store user permissions. Multiple keys can be defined, for example, two key values ​​are used to store the user's list permissions and operation permissions respectively.

[0025] S300: Add permission annotations to each backend interface.

[0026] The value of the annotation indicates the permission code of the interface.

[0027] Add a permission annotation to the RESTful interface, and the value of the annotation is the permission code of the interface, that is, permission_code. The RESTful interface is a Web service interface that follows the REST (Representational State Transfer) principle. REST is a software architecture style that defines how to design the API (application programming interface) of network applications so that they can be accessed and used by different clients (such as Web browsers, mobile devices, desktop applications, etc.) in a unified and predictable way. The interface design based on the RESTful style aims to provide a simple, intuitive and scalable way to build Web services. They allow developers to create easy-to-understand and easy-to-use APIs that can be accessed and used by various clients in a unified way. Because the RESTful interface follows the standards and best practices of the HTTP protocol, they have wide compatibility and interoperability and can be seamlessly integrated with various client and server technologies. The scope of the permission annotation is the method level, that is, METHOD, which means that this permission annotation is used to add additional information or instructions to the method.

[0028] S400: When calling a target interface, comparing the stored user interface permissions and the permission annotations of the target interface.

[0029] The target interface is any backend interface.

[0030] Set a permission annotation for each backend interface. If the stored user interface permissions correspond to the permission annotation of this backend interface, this interface can be called. If not, this backend interface cannot be called because there is no permission to call it.

[0031] S500: When the permission annotation of the target interface exists in the stored user interface permissions, calling the target interface is allowed.

[0032] For example, obtain the current user's ID, then obtain the user interface permissions, compare the permission annotation of the backend interface with the stored user interface permissions, and if the permission annotation is included in the user's interface permission list, the target interface is allowed to be called.

[0033] In one embodiment, S200 (based on a hash structure, storing user interface permissions through a first key value) includes: when a user logs in, storing the preset user interface permissions corresponding to the user in a database, and using a first key value to store the user interface permissions; wherein, the user permission control method may also include: storing a user menu through a second key value.

[0034] In order to improve reading efficiency and avoid accessing the database every time the interface is accessed, redis is used as an in-memory database. When the user logs in, the user's operation permissions are placed in the redis in-memory database as a query cache. In addition, the hash structure of redis is used to store user permissions. Multiple keys can be defined. For example, the "permission" key (the first key value) stores user interface permissions, and the "menus" key (the second key value) can be used to store user menus, so that data can be stored clearly and prevent mutual interference.

[0035] Figure 2 is a flow chart of a user authority control method provided by another exemplary embodiment of the present invention, such as Figure 2 As shown, the user authority control method may also include:

[0036] S600: Add a permission aspect, and define the entry point of the permission aspect to the permission annotation to be woven into the interface.

[0037] AOP (Aspect-Oriented Programming) is a programming paradigm that aims to improve the maintainability, reusability and modularity of software. AOP encapsulates common behaviors (such as logging, transaction management, security control, etc.) scattered across multiple parts of an application into a reusable module by separating cross-cutting concerns. This module is called an "Aspect". Pointcuts are used to specify which connection points (that is, which methods) need to be enhanced, and pointcut expressions are used to define the rules for these connection points. An aspect consists of pointcuts and notifications, which define where (pointcuts) and how (notifications) to enhance cross-cutting concerns. For example, using @Pointcut ("@annotation()"), it can be woven into the interface.

[0038] S700: Use the surround notification to obtain the method of the entry point through reflection to obtain the permission annotation on the method.

[0039] In order to decouple the code, the present invention uses the concept of AOP in the Spring framework, customizes the permission aspect, adds an around notification when calling the backend interface, obtains the user permission from the Spring context, and then determines whether the user has the permission to use the interface. At the same time, the permission annotation is customized and the control is added at the Controller layer, which further realizes the decoupling of the code and improves the readability and scalability of the code. The around notification is not only used to control the execution process of the method, but also to further obtain or operate the information related to the method of the entry point through the reflection mechanism. Around advice is a type of advice in AOP (aspect-oriented programming), which intercepts before and after the execution of the target method, and can decide whether to continue to execute the target method, whether to return its own return value, or whether to throw an exception to end the execution. The around notification has complete control and can obtain all the information of the target method, including operations, parameters, return values, etc. before and after the method call. Around advice can perform custom operations before and after the target method is executed. This is the main difference between it and other advice types (such as before advice, after advice, etc.). Around advice can fully control the execution of the target method, including whether to execute the target method, whether to return its own return value, or whether to throw an exception. Reflection is a mechanism provided by programming languages ​​such as Java that allows programs to check or modify the behavior of a class at runtime. Through reflection, you can obtain class information (such as methods, fields, etc.) and call these methods dynamically.

[0040] S800: Based on the permission annotation on the method, obtain the permission code of the interface.

[0041] Through the Java reflection API, you can access the annotation information of the class, including the annotations on the method. You can write code to traverse all the methods of the class and check whether there is a permission annotation on each method. If so, read the permission code in the annotation. To obtain the permission code of the interface based on the permission annotation on the method, you specify one or more permission identifiers (permission codes) for the interface method through annotations, and then perform permission checks based on these permission identifiers at runtime.

[0042] S900: Obtain the ID of the current user through the context to obtain the user interface authority from the database.

[0043] In Spring Security, getting the current user's ID usually involves accessing the SpringSecurity context, such as the SecurityContextHolder and Authentication objects. Based on the user ID, the user interface permissions can be obtained from the redis memory database.

[0044] In one embodiment, S400 (when calling the target interface, comparing the stored user interface permissions and the permission annotations of the target interface) includes: comparing the permission code and the user interface permissions obtained from the database to obtain a comparison result; wherein, S500 (when the permission annotation of the target interface exists in the stored user interface permissions, allowing the target interface to be called) includes: when the comparison result indicates that the permission code corresponds to the user interface permissions stored in the database, releasing the method in the aspect.

[0045] Use the surrounding advice to obtain the method of the entry point through reflection, and then obtain the annotation on the method, and then obtain the permission code, and then obtain the current user ID through the SpringSecurity context, and then obtain the user interface permission from redis. Compare the permission code on the method with the permission code assigned to the user obtained from redis. If the method permission code is included in the user's permission list, then release the method in the aspect. If not, throw an exception to remind the user that he does not have permission to operate.

[0046] In one embodiment, the user authority control method may also include: presetting the front-end authority code on the front-end; obtaining a user authority list through the user interface authority stored in the first key value; when the front-end authority code exists in the user authority list, inserting a new view and displaying an operation button in the view; wherein the operation button corresponds to the user interface authority; when the front-end authority code does not exist in the user authority list, the operation button is not displayed.

[0047] In addition to the permission matching in the backend, in the frontend framework using Angular, custom instructions are used, that is, in the buttons where permission judgment is required, custom instructions are used to judge whether the user has the permission, so as to control whether certain buttons or options exist. For example, the permission code is preset in the frontend code, and then the user's code list can be obtained from the backend user login interface. If the code for the operation is included, it can be displayed normally, otherwise, the button or component is invisible to the user.

[0048] In one embodiment, the user permission control method may further include: using a custom instruction PermissionDirective for the operation button that requires permission control; and adding the custom instruction PermissionDirective to the container to control visibility or hiding of the operation button.

[0049] For example, define an operation permission with the code "opereate". Through the back-end interface, obtain the user interface permission from the redis memory database storage, and then determine whether the permission with the code "opereate" is in the user interface permission. If it is, instantiate the view through the createEmbeddedView method of ViewContainerRef, and then display the corresponding operation button. That is, in the front-end page, where the component needs to control the permission, add judgment, and only users with the permission can see the button or perform the operation, which can further improve the user's operation experience, improve the security of the system, and reduce the risk of misoperation.

[0050] In one embodiment, the user permission control method may further include: when the permission annotation of the target interface does not exist in the stored user interface permissions, calling the interface is not allowed and an exception prompt is issued; wherein the exception prompt is used to remind the user that there is no operation permission; based on the permission annotation of the target interface and the exception prompt, a permission information prompt is issued to the user; wherein the permission information prompt is used to prompt the user that the user lacks the permission required to perform the operation.

[0051] If the permission annotation of the target interface does not exist in the stored user interface permissions, an exception is thrown to remind the user that the operation permission is not available. In addition, a permission information prompt, such as an error message or a pop-up window, can be issued to clearly inform the user that the permission required to perform the operation is missing. The message can contain enough contextual information for the user to understand why this permission is required and how it affects the functionality of the application. If the functionality of the application can be partially implemented without relying entirely on the permission, an alternative solution or downgraded functionality can be provided to the user. Record the user's operation choices after the lack of permission to avoid frequent and identical prompts to the user every time.

[0052] In one embodiment, S200 (based on a hash structure, storing user interface permissions through a first key value) includes: creating a hash table to store the user's interface permission information; inserting a first key-value pair into the hash table; wherein the key in the first key-value pair includes a license key, and the first key value in the first key-value pair includes user interface permissions; wherein the user permission control method includes: based on a query instruction, searching for corresponding user interface permissions through the key in the first key-value pair.

[0053] In a hash structure, each key is unique and is used to uniquely identify a value. For example, in the original memory database, the data type of user permissions is modified, a hash structure is used, a key value permissions is added to store user interface permissions, and the menu key is used to store user menus, that is, the Redis data type is designed as:

[0054] Key: "permissions": permission_1, permission_2, ...

[0055] "menus": menu1, menu2, menu3, ...

[0056] Use the hash function to calculate the permissions key to get the corresponding hash value. Use the calculated hash value as the index to locate the corresponding bucket (or slot) in the hash table, and search for the key-value pair (that is, user interface permissions) that matches the given key in the bucket or linked list. If found, the corresponding user interface permissions are returned; if not found, a value indicating not found (such as no permission, null, None, and -1, etc.) is usually returned.

[0057] In one embodiment, the user permission control method may include: when a first target user interface permission in the user interface permissions undergoes a permission change, searching for the corresponding first target user interface permission through the key in the first key-value pair and executing the change; recording the change information of the first target user interface permission, and analyzing the change information to obtain a user permission change record; overwriting the first target user interface permission with a new user interface permission and storing it.

[0058] If you need to add user interface permissions, use a hash function to hash the key to get a hash value, locate the specific bucket (or slot) in the hash table based on the hash value, and insert the new key-value pair into the corresponding bucket. If you need to delete user interface permissions, find the user interface permissions that match the key to be deleted, and remove the found user interface permissions from the bucket. If you need to modify user interface permissions, also first calculate the hash value of the key and locate the corresponding bucket, traverse the elements in the bucket, find the user interface permissions that match the key to be modified, and replace the found user interface permissions with the new user interface permissions. If you try to insert an existing key, the old value corresponding to the key will usually be overwritten. In addition, analyze the change information to determine the user's changes and the reasons for the changes, so as to provide a reference for subsequent permission adjustments.

[0059] In summary, the present invention is based on the SpringBoot back-end framework and applications based on the Angular or Vue front-end framework, involving a redis memory database, a custom permission annotation based on Spring, and a permission aspect based on SpringAOP. In essence, the user operation permissions of the memory data are matched with the operation permissions of the back-end interface layer to achieve the purpose of controlling the user operation permissions. On the basis of the RBAC model allocation of permissions, a more fine-grained allocation of user permissions is achieved, and the RBAC model is supplemented. On the one hand, a more fine-grained permission allocation is achieved from the back end to ensure the security of the interface. On the other hand, a button and the display mode of some other components can be hidden or changed from the front end to enhance the user experience.

[0060] Figure 3 is a schematic diagram of the structure of a user authority control device provided by an exemplary embodiment of the present invention. Figure 3 As shown, the user authority control device 3 includes: an acquisition module 31, used to obtain preset user interface permissions; a storage module 32, used to store user interface permissions through a first key value based on a hash structure; an annotation module 33, used to add permission annotations to each backend interface; wherein the annotation value represents the permission code of the interface; a comparison module 34, used to compare the stored user interface permissions and the permission annotations of the target interface when calling the target interface; wherein the target interface is any backend interface; a calling module 35, used to allow calling the target interface when the permission annotation of the target interface exists in the stored user interface permissions.

[0061] The user authority control device provided by the present invention stores user authority through a hash structure, can define multiple keys, is more flexible, and matches the user operation authority of the memory data with the operation authority of the back-end interface layer to achieve the purpose of controlling the user operation authority, can realize more fine-grained authority allocation, and ensure the security of the interface.

[0062] In one embodiment, the storage module 32 can be configured to: when the user logs in, store the preset user interface permissions corresponding to the user in the database, and use the first key value to store the user interface permissions; wherein the user permission control method also includes: storing the user menu through the second key value.

[0063] In one embodiment, the user authority control device 3 can also be configured as: adding a permission aspect, the entry point of the permission aspect is defined to the permission annotation to be woven into the interface; using surround notification, obtaining the method of the entry point by reflection to obtain the permission annotation on the method; based on the permission annotation on the method, obtaining the permission code of the interface; obtaining the current user's ID through the context to obtain the user interface permissions from the database.

[0064] In one embodiment, the comparison module 34 can be configured to: compare the permission code and the user interface permissions obtained from the database to obtain a comparison result; wherein, the calling module 35 can be correspondingly configured to: when the comparison result indicates that the permission code corresponds to the user interface permissions stored in the database, release the method in the aspect.

[0065] In one embodiment, the user authority control device 3 can also be configured as: presetting the front-end authority code at the front end; obtaining the user authority list through the user interface authority stored by the first key value; when the front-end authority code exists in the user authority list, inserting a new view and displaying the operation button in the view; wherein the operation button corresponds to the user interface authority; when the front-end authority code does not exist in the user authority list, the operation button is not displayed.

[0066] In one embodiment, the user authority control device 3 may also be configured to: use a custom instruction PermissionDirective for the operation button that requires authority control; and add the custom instruction PermissionDirective to the container to control the visibility or hiding of the operation button.

[0067] In one embodiment, the user authority control device 3 can also be configured as follows: when the permission annotation of the target interface does not exist in the stored user interface permissions, calling the interface is not allowed, and an exception prompt is issued; wherein the exception prompt is used to remind the user that there is no operation permission; based on the permission annotation of the target interface and the exception prompt, a permission information prompt is issued to the user; wherein the permission information prompt is used to prompt the user that the user lacks the permission required to perform the operation.

[0068] In one embodiment, the storage module 32 can be configured to: create a hash table to store the user's interface permission information; insert a first key-value pair into the hash table; wherein the key in the first key-value pair includes a permission key, and the first key value in the first key-value pair includes user interface permissions; wherein the user permission control method includes: based on a query instruction, searching for corresponding user interface permissions through the key in the first key-value pair.

[0069] In one embodiment, the user authority control device 3 can also be configured as follows: when a first target user interface permission exists in the user interface permissions and a permission change occurs, the corresponding first target user interface permission is searched through the key in the first key-value pair, and the change is executed; the change information of the first target user interface permission is recorded, and the change information is analyzed to obtain a user authority change record; the first target user interface permission is overwritten with the new user interface permission, and the new permission is stored.

[0070] An embodiment of the present invention provides a user authority control device. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. From a hardware perspective, in addition to the CPU, memory, network interface, and non-volatile memory, the device in the embodiment where the device is located can generally include other hardware, such as a forwarding chip responsible for processing messages, etc. Taking software implementation as an example, as a device in a logical sense, it is formed by the CPU of the device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them.

[0071] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the user authority control method of any of the above embodiments.

[0072] In addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the user authority control method according to various embodiments of the present invention described in the above-mentioned "Exemplary Method" section of this specification.

[0073] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: a processor; a memory for storing instructions executable by the processor; and the processor, configured to execute the user authority control method of any of the above embodiments.

[0074] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the user authority control method according to various embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0075] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A user authority control method, characterized in that: include: Get the preset user interface permissions; Based on the hash structure, the user interface permission is stored by a first key value; Add permission annotations to each backend interface; the value of the annotation represents the permission code of the interface; When calling a target interface, comparing the stored user interface permissions and the permission annotations of the target interface; wherein the target interface is any backend interface; When the permission annotation of the target interface exists in the stored user interface permissions, calling the target interface is allowed.

2. The user authority control method according to claim 1, characterized in that: Based on the hash structure, the user interface permission is stored by the first key value, including: When the user logs in, the preset user interface permissions corresponding to the user are stored in the database, and the user interface permissions are stored using the first key value; The user authority control method further includes: The user menu is stored via the second key value.

3. The user authority control method according to claim 2, characterized in that: User permission control methods also include: Add a permission aspect, and define the entry point of the permission aspect to the permission annotation to weave it into the interface; Use the surround advice to obtain the pointcut method through reflection to obtain the permission annotation on the method; Based on the permission annotation on the method, obtain the permission code of the interface; Get the current user's ID through the context to obtain the user interface permissions from the database.

4. The user authority control method according to claim 3, characterized in that: When calling the target interface, the stored user interface permissions and the permission annotations of the target interface are compared, including: Compare the permission code with the user interface permission obtained from the database to obtain a comparison result; When the permission annotation of the target interface exists in the stored user interface permissions, calling the target interface is allowed, including: When the comparison result indicates that the permission code corresponds to the user interface permission stored in the database, the method is released in the aspect.

5. The user authority control method according to claim 1, characterized in that: User permission control methods also include: Preset the front-end permission code on the front-end; Obtain a user permission list through the user interface permission stored by the first key value; When the front-end permission code exists in the user permission list, insert a new view and display an operation button in the view; wherein the operation button corresponds to the user interface permission; When the front-end authority code does not exist in the user authority list, the operation button is not displayed.

6. The user authority control method according to claim 5, characterized in that: User permission control methods also include: The operation button for permission control uses the custom instruction PermissionDirective; And add the custom directive PermissionDirective to the container to control the visibility or hiding of the action button.

7. The user authority control method according to claim 1, characterized in that: The user authority control method further includes: When the permission annotation of the target interface does not exist in the stored user interface permissions, calling the interface is not allowed, and an abnormal prompt is issued; wherein the abnormal prompt is used to remind the user that he does not have the operation permission; Based on the permission annotation and exception prompt of the target interface, a permission information prompt is issued to the user; wherein the permission information prompt is used to prompt the user that the user lacks the permission required to perform the operation.

8. The user authority control method according to claim 1, characterized in that: Based on the hash structure, the user interface permission is stored by the first key value, including: Create a hash table to store the user's interface permission information; Inserting a first key-value pair into the hash table; wherein the key in the first key-value pair comprises a permission key, and the first key value in the first key-value pair comprises the user interface permission; Wherein, the user authority control method includes: Based on the query instruction, the corresponding user interface permission is searched through the key in the first key-value pair.

9. The user authority control method according to claim 8, characterized in that: The user authority control method comprises: When a first target user interface permission among the user interface permissions undergoes a permission change, searching for the corresponding first target user interface permission through the key in the first key-value pair and performing the change; Recording the change information of the first target user interface authority, and analyzing the change information to obtain the user authority change record; The first target user interface permissions are overwritten with the new user interface permissions and stored.

10. A user authority control device, characterized in that: include: An acquisition module is used to obtain preset user interface permissions; A storage module, configured to store the user interface permissions by a first key value based on a hash structure; Annotation module, used to add permission annotations to each backend interface; the value of the annotation represents the permission code of the interface; A comparison module, used for comparing the stored user interface permissions and the permission annotations of the target interface when calling the target interface; wherein the target interface is any backend interface; A calling module is used to allow calling the target interface when the permission annotation of the target interface exists in the stored user interface permissions.

Citation Information

Patent Citations

  • Method for controlling real-time view permission of single-page application

    CN110768974A

  • API access control method, apparatus and device, and medium

    CN112035858A

  • Interface calling permission identification method, system and device, equipment and storage medium

    CN114006755A

  • Interface access control method and device, electronic equipment and storage medium

    CN114519181A

  • Mass analysis data set staticizing method based on multi-dimensional rights

    CN116701460A

Cited By

  • Dynamic verification method and device for interface permission

    CN121309239A