Movatterモバイル変換


[0]ホーム

URL:


CN114239040A - Menu permission control method and system based on prime number multiplication - Google Patents

Menu permission control method and system based on prime number multiplication
Download PDF

Info

Publication number
CN114239040A
CN114239040ACN202210032068.2ACN202210032068ACN114239040ACN 114239040 ACN114239040 ACN 114239040ACN 202210032068 ACN202210032068 ACN 202210032068ACN 114239040 ACN114239040 ACN 114239040A
Authority
CN
China
Prior art keywords
authority
menu
user
total code
establishing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210032068.2A
Other languages
Chinese (zh)
Inventor
何健进
吕火生
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Foshan Zhongtaolian Supply Chain Service Co Ltd
Tibet Zhongtaolian Supply Chain Service Co Ltd
Original Assignee
Foshan Zhongtaolian Supply Chain Service Co Ltd
Tibet Zhongtaolian Supply Chain Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Foshan Zhongtaolian Supply Chain Service Co Ltd, Tibet Zhongtaolian Supply Chain Service Co LtdfiledCriticalFoshan Zhongtaolian Supply Chain Service Co Ltd
Priority to CN202210032068.2ApriorityCriticalpatent/CN114239040A/en
Publication of CN114239040ApublicationCriticalpatent/CN114239040A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The invention discloses a menu authority control method and a system based on prime number multiplication, wherein the method comprises the following steps: giving different authority codes different prime numbers; capturing an authority name required by the menu id; establishing a menu authority total code under the menu id, wherein the menu authority total code is the product of authority codes selected in the menu id; capturing an authority name required by a user id; establishing a user authority total code under the user id, wherein the user authority total code is the product of authority codes required by the user id; and continuously subtracting the user authority total code from the menu authority total code until the difference value is smaller than the user authority total code to obtain a residual value. The system comprises an authority list establishing module, a menu authority establishing module, a user authority establishing module and a menu authority checking module. The menu authority control method and system based on prime number multiplication solve the problems that the existing application system authority, roles and user relation are complex and the operation efficiency is influenced.

Description

Menu permission control method and system based on prime number multiplication
Technical Field
The invention relates to the technical field of information security, in particular to a menu authority control method and a system based on prime number multiplication.
Background
The authority control is often an indispensable part in an application system and widely permeates various small and medium-sized enterprises, and the menu control authority scheme needs to be adjusted in coordination with the granularity of increasingly complex business logic.
The existing menu authority verification method, as shown in fig. 1, is generally based on a RBAC authority model, that is, configured in the form of authority-role-user, and assigns and authorizes the authority in a many-to-many manner. The general table structure storage scheme is to store the relationship between the role and the authority in the form of a sub-table, and the authority verification is based on judging whether the authority id exists in the user role where the current user is located. When the types of the authorities increase, the authority ids required to be stored increase, and the relationships among the authorities, roles and users become very complicated, thereby affecting the efficiency of the operation of the application system.
Disclosure of Invention
In view of the above defects, an object of the present invention is to provide a method for controlling menu permission based on prime number multiplication, which solves the problem that the existing application system permission, role and user relationship is complex and affects the operation efficiency.
In view of the above defects, another objective of the present invention is to provide a menu authority control system based on prime number multiplication, which solves the problem that the existing application system authority, role and user relationship is complex, and the operation efficiency is affected.
In order to achieve the purpose, the invention adopts the following technical scheme: a menu authority control method based on prime number multiplication comprises the following steps:
establishing an authority table: establishing an authority name and an authority code, associating the authority name with the authority code, and giving different prime numbers to different authority codes;
a menu authority establishing step: constructing a menu id, capturing an authority name required by the menu id, and associating the menu relative path, the menu id and the authority name;
establishing a menu authority total code under the menu id, wherein the menu authority total code is the product of authority codes selected in the menu id;
user authority establishing step: constructing a user id, capturing an authority name required by the user id, and associating the user id with the authority name;
establishing a user authority total code under the user id, wherein the user authority total code is the product of authority codes required by the user id;
and (3) checking menu authority: and continuously subtracting the user authority total code from the menu authority total code until the difference value is smaller than the user authority total code to obtain a residual value, marking that the user id does not have the operation authority of the menu id when the residual value is not 0, and marking that the user id has the operation authority of the menu id when the residual value is not 0.
It should be noted that the user right establishing step further includes:
after the user id is constructed, checking the user id and checking a menu id needing authorization;
and calculating a menu authority total code corresponding to the menu id needing authorization, and storing the value of the menu authority total code in a user authority total code corresponding to the user id.
Optionally, the step of establishing the authority table further includes: randomly grabbing prime numbers in a prime number table from 1 to 100, and giving the grabbed prime numbers to the authority codes according to time established by the authority names; after the prime number is randomly captured each time, whether the captured prime number is repeated with the prime number which is captured before is judged, and when the captured prime number is not repeated, the next prime number is captured.
Specifically, in the menu authority establishing step, the menu authority total code is set to a format of a character string with a character length of 20; in the user authority establishing step, the user authority total code is set to a format of a character string with a character length of 20.
Preferably, the method further comprises an intercepting step, wherein the intercepting step comprises the following steps:
and setting an interceptor in front of the controller, and intercepting the current operation of the user id when the residual value obtained in the menu authority verification step is not 0.
It is worth to be noted that the menu authority control system based on prime number multiplication comprises an authority table establishing module, a menu authority establishing module, a user authority establishing module and a menu authority verifying module;
the authority table establishing module is used for establishing an authority name and an authority code, associating the authority name with the authority code and endowing different prime numbers to different authority codes;
the menu authority establishing module is used for establishing a menu id, capturing an authority name required by the menu id and associating the menu relative path, the menu id and the authority name; the menu management system is also used for establishing a menu authority total code under the menu id, wherein the menu authority total code is the product of authority codes selected in the menu id;
the user authority establishing module is used for establishing a user id, capturing an authority name required by the user id and associating the user id with the authority name; the system is also used for establishing a user authority total code under the user id, wherein the user authority total code is the product of authority codes required by the user id;
the menu authority checking module is used for continuously subtracting the user authority total code from the menu authority total code until the difference value is smaller than the user authority total code to obtain a residual value, marking that the user id has no operation authority of the menu id when the residual value is not 0, and marking that the user id has the operation authority of the menu id when the residual value is not 0.
Optionally, the user right establishing module is further configured to select a user id and a menu id that needs to be authorized; and the method is also used for calculating a menu authority total code corresponding to the menu id needing authorization and storing the value of the menu authority total code in the user authority total code corresponding to the user id.
Specifically, the authority table establishing module is further configured to randomly capture prime numbers in a prime number table from 1 to 100, and assign the captured prime numbers to the authority codes according to time sequence established by the authority names; after the prime number is randomly captured each time, whether the captured prime number is repeated with the prime number which is captured before is judged, and when the captured prime number is not repeated, the next prime number is captured.
Preferably, the menu authority establishing module is further configured to set the menu authority total code to a format of a character string with a character length of 20;
the user authority establishing module is also used for setting the user authority total code into a format of a character string with the character length of 20.
It is worth to say, the system further comprises an intercepting module, the intercepting module is configured to set an interceptor before the controller, and is further configured to intercept the current operation of the user id when the obtained remaining value is not 0.
One of the above technical solutions has the following beneficial effects: according to the definition of prime number and composite number, a natural number is called prime number if only 1 and the natural number have two factors; a natural number is called a composite number if it has other factors than 1 and itself. The menu authority total code and the user authority total code are obtained by multiplying the corresponding authority codes, and because the authority codes are prime numbers, namely the authority codes except 1 cannot be divided by other natural numbers, the authority codes corresponding to the menu authority total code and the product combination of the authority codes are obtained by multiplying the natural numbers except 1 of the menu authority total code, and the authority codes corresponding to the user authority total code and the product combination of the authority codes are obtained by multiplying the natural numbers except 1 of the user authority total code. Therefore, when the user authority total code is continuously subtracted from the menu authority total code, and the obtained residual value is not 0, the user authority total code is not multiplied to obtain the authority code corresponding to the menu authority total code and the product combination of the authority codes, that is, the authority code corresponding to the user Id is completely different from the authority code corresponding to the menu Id; and when the remaining value is 0, at least one of the authority codes corresponding to the user Id and the authority code corresponding to the menu Id is the same. Whether the user id has the operation authority under the menu id can be distinguished by judging whether the residual value is 0 or not, so that the storage of the relation among the authority, the role and the user is reduced, the running efficiency of an application system is improved, the risk of tampering by a third party can be effectively prevented, and the safety of the system is improved.
Drawings
FIG. 1 is a block diagram of a menu privilege control system of a prior art RBAC-based privilege model;
FIG. 2 is a flow diagram of a menu privilege control method of one embodiment of the invention;
fig. 3 is a block diagram of the structure of the menu authority control system of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
The following disclosure provides many different embodiments or examples for implementing different configurations of embodiments of the invention. In order to simplify the disclosure of embodiments of the invention, the components and arrangements of specific examples are described below. Of course, they are merely examples and are not intended to limit the present invention. Furthermore, embodiments of the invention may repeat reference numerals and/or reference letters in the various examples, which have been repeated for purposes of simplicity and clarity and do not in themselves dictate a relationship between the various embodiments and/or arrangements discussed. In addition, embodiments of the present invention provide examples of various specific processes and materials, but one of ordinary skill in the art may recognize applications of other processes and/or use of other materials.
As shown in fig. 2, a menu authority control method based on prime number multiplication includes the following steps:
establishing an authority table: establishing an authority name and an authority code, associating the authority name with the authority code, and giving different prime numbers to different authority codes;
a menu authority establishing step: constructing a menu id, capturing an authority name required by the menu id, and associating the menu relative path, the menu id and the authority name; establishing a menu authority total code under the menu id, wherein the menu authority total code is the product of authority codes selected in the menu id;
user authority establishing step: constructing a user id, capturing an authority name required by the user id, and associating the user id with the authority name; establishing a user authority total code under the user id, wherein the user authority total code is the product of authority codes required by the user id;
and (3) checking menu authority: and continuously subtracting the user authority total code from the menu authority total code until the difference value is smaller than the user authority total code to obtain a residual value, marking that the user id does not have the operation authority of the menu id when the residual value is not 0, and marking that the user id has the operation authority of the menu id when the residual value is not 0.
According to the definition of prime number and composite number, a natural number is called prime number if only 1 and the natural number have two factors; a natural number is called a composite number if it has other factors than 1 and itself. The menu authority total code and the user authority total code are obtained by multiplying the corresponding authority codes, and because the authority codes are prime numbers, namely the authority codes except 1 cannot be divided by other natural numbers, the authority codes corresponding to the menu authority total code and the product combination of the authority codes are obtained by multiplying the natural numbers except 1 of the menu authority total code, and the authority codes corresponding to the user authority total code and the product combination of the authority codes are obtained by multiplying the natural numbers except 1 of the user authority total code. Therefore, when the user authority total code is continuously subtracted from the menu authority total code, and the obtained residual value is not 0, the user authority total code is not multiplied to obtain the authority code corresponding to the menu authority total code and the product combination of the authority codes, that is, the authority code corresponding to the user Id is completely different from the authority code corresponding to the menu Id; and when the remaining value is 0, at least one of the authority codes corresponding to the user Id and the authority code corresponding to the menu Id is the same. Whether the user id has the operation authority under the menu id can be distinguished by judging whether the residual value is 0 or not, so that the storage of the relation among the authority, the role and the user is reduced, the running efficiency of an application system is improved, the risk of tampering by a third party can be effectively prevented, and the safety of the system is improved.
For example, the total menu authority code is 95(5 × 19 is 95), the total user authority code is 43, the total user authority code subtracted from the total menu authority code is 95-43 is 52, in which case 52 is greater than 43, and then 95-43-43 is executed to 9, in which case 11 is smaller than 43, 9 is a residual value, and the residual value 9 is not 0, and it is marked that the user id does not have the operation authority of the menu id, and the background does not need to care about the value of the quotient, and it is sufficient to simply find the residual value and determine whether the residual value is 0. In another embodiment, the authority code of the operation authority in the requested menu id is 9, and the obtained remaining value is 0, which marks that the user id has the operation authority of the menu id. Specifically, when the order of magnitude difference between the menu authority total code and the user authority total code is large, preferably, the order of magnitude difference is larger than five order of magnitude, the menu authority total code and the user authority total code are subjected to remainder, when the remainder is not 0, the user id is marked to have no operation authority of the menu id, and when the remainder is 0, the user id is marked to have the operation authority of the menu id.
In some embodiments, the user right establishing step further comprises: after the user id is constructed, checking the user id and checking a menu id needing authorization; and calculating a menu authority total code corresponding to the menu id needing authorization, and storing the value of the menu authority total code in a user authority total code corresponding to the user id. The user id corresponding to the page checking role and the authority name of the menu are recorded in the role-authority code value by calculating the product of the authority codes of the checked authority name in the background. In one embodiment, the permissions are checked, added, edited, deleted and exported for a user id corresponding to a certain role under a menu managed by a page user, and then the request parameters are a set of the user id, the menu id and the permission id code. The background will find the set of authority codes first, and then multiply the authority codes, in this embodiment, the set of authority codes is [2, 3, 5, 19, 23, 29 ], and then calculate 2 x 3 x 5 x 19 x 23 x 29, and obtain the corresponding authority total code of 380190. The database records are (role-authority table id, role id, user management menu id, 380190) as the role-authority table (role-authority table id, user id, menu id, user authority total code).
It should be noted that the step of establishing the authority table further includes: randomly grabbing prime numbers in a prime number table from 1 to 100, and giving the grabbed prime numbers to the authority codes according to time established by the authority names; after the prime number is randomly captured each time, whether the captured prime number is repeated with the prime number which is captured before is judged, and when the captured prime number is not repeated, the next prime number is captured. When a weight limit needs to be added to a certain menu page, the relative path, the menu id and the authority name of the certain menu page are recorded, the authority code of the certain menu page is automatically calculated in a background, for example, the prime number captured for the first time is 1, the prime number captured for the second time is 3, the prime number captured for the third time cannot be 1 or 3, but can be other prime numbers except 1 or 3, and after the prime number is captured, the grasped prime number is given to the authority code according to the time established by the authority name. In the step of establishing the authority list, the randomness of the authority total code can be increased by adopting a mode of randomly grabbing the prime numbers in the prime number list from 1 to 100, and the authority total code is prevented from being cracked by a malignant user due to a certain rule. In one embodiment, an additional operation authority is added to the menu managed by the user, and the existing recorded authority code managed by the user is 2. The newly added permission request parameters are as follows: "/user/add", "user management menu id", and "new user", respectively represent the menu relative path, menu id, and authority name. The authority code recorded in the menu id is queried in the background to be 2, and then the system can not capture the prime number of 2.
Optionally, in the menu permission establishing step, the menu permission total code is set to a format of a character string with a character length of 20; in the user authority establishing step, the user authority total code is set to be in a character string format with the character length of 20, and the situation that the product obtained by multiplying each prime number is too large to exceed the limit of the int digit of the computer is prevented. As the number of the setting of the authority codes increases, the value of the authority total code becomes larger. Based on business consideration, the same menu is not friendly to both a system and a user, is bloated, and is not friendly to later expansion, in the embodiment, the most friendly permission number supported by the permission scheme is 10, that is, the menu permission total code is set to be in a character string varchar (20) format, and the user permission total code is set to be in the character string varchar (20) format, which certainly can support more permissions, but it is not recommended to stack too many permissions in the same menu. If all the first 10 authority values are checked, the corresponding authority total code is 6469693230.
Specifically, the method further comprises an intercepting step, wherein the intercepting step comprises the following steps: and setting an interceptor in front of the controller, and intercepting the current operation of the user id when the residual value obtained in the menu authority verification step is not 0. Through the interceptor, the interception can be immediately carried out when the user id is identified to have no authority, so that the cross-authority operation of the non-authority user is avoided.
In some embodiments, as shown in fig. 3, a menu authority control system based on prime number multiplication includes an authority table establishing module, a menu authority establishing module, a user authority establishing module, and a menu authority verifying module; the authority table establishing module is used for establishing an authority name and an authority code, associating the authority name with the authority code and endowing different prime numbers to different authority codes; the menu authority establishing module is used for establishing a menu id, capturing an authority name required by the menu id and associating the menu relative path, the menu id and the authority name; the menu management system is also used for establishing a menu authority total code under the menu id, wherein the menu authority total code is the product of authority codes selected in the menu id; the user authority establishing module is used for establishing a user id, capturing an authority name required by the user id and associating the user id with the authority name; the system is also used for establishing a user authority total code under the user id, wherein the user authority total code is the product of authority codes required by the user id; the menu authority checking module is used for continuously subtracting the user authority total code from the menu authority total code until the difference value is smaller than the user authority total code to obtain a residual value, marking that the user id has no operation authority of the menu id when the residual value is not 0, and marking that the user id has the operation authority of the menu id when the residual value is not 0.
It is worth to be noted that the user authority establishing module is further used for checking a user id and checking a menu id which needs to be authorized; and the method is also used for calculating a menu authority total code corresponding to the menu id needing authorization and storing the value of the menu authority total code in the user authority total code corresponding to the user id.
Optionally, the authority table establishing module is further configured to randomly capture prime numbers in a prime number table from 1 to 100, and assign the captured prime numbers to the authority codes according to time sequence established by the authority names; after the prime number is randomly captured each time, whether the captured prime number is repeated with the prime number which is captured before is judged, and when the captured prime number is not repeated, the next prime number is captured.
Specifically, the menu authority establishing module is further configured to set the menu authority total code to a format of a character string with a character length of 20; the user authority establishing module is also used for setting the user authority total code into a format of a character string with the character length of 20.
Preferably, the system further comprises an interception module, wherein the interception module is configured to set an interceptor in front of the controller, and is further configured to intercept the current operation of the user id when the obtained remaining value is not 0.
In the description herein, references to the description of the terms "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example" or "some examples" or the like mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and not to be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made in the above embodiments by those of ordinary skill in the art within the scope of the present invention.

Claims (10)

CN202210032068.2A2022-01-122022-01-12Menu permission control method and system based on prime number multiplicationPendingCN114239040A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202210032068.2ACN114239040A (en)2022-01-122022-01-12Menu permission control method and system based on prime number multiplication

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202210032068.2ACN114239040A (en)2022-01-122022-01-12Menu permission control method and system based on prime number multiplication

Publications (1)

Publication NumberPublication Date
CN114239040Atrue CN114239040A (en)2022-03-25

Family

ID=80746335

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202210032068.2APendingCN114239040A (en)2022-01-122022-01-12Menu permission control method and system based on prime number multiplication

Country Status (1)

CountryLink
CN (1)CN114239040A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116415281A (en)*2023-04-182023-07-11青海省第三地质勘查院Authority control method and system based on improved last-bit checksum double hash function

Citations (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101620601A (en)*2008-06-302010-01-06上海全成通信技术有限公司Method for building directory tree based on user permissions
CN103500297A (en)*2013-10-112014-01-08济钢集团有限公司Fine grit authority management method in information system
WO2021152212A1 (en)*2020-01-312021-08-05Widlund SamMethod and device for encrypting data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101620601A (en)*2008-06-302010-01-06上海全成通信技术有限公司Method for building directory tree based on user permissions
CN103500297A (en)*2013-10-112014-01-08济钢集团有限公司Fine grit authority management method in information system
WO2021152212A1 (en)*2020-01-312021-08-05Widlund SamMethod and device for encrypting data

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WINDER: "权限设计", pages 1 - 2, Retrieved from the Internet <URL:https://bbs.csdn.net/topics/90090460>*

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116415281A (en)*2023-04-182023-07-11青海省第三地质勘查院Authority control method and system based on improved last-bit checksum double hash function
CN116415281B (en)*2023-04-182023-10-20青海省第三地质勘查院Authority control method and system based on improved last-bit checksum double hash function

Similar Documents

PublicationPublication DateTitle
CN110321735B (en) Business processing method, system and storage medium based on zero-knowledge proof
Anagnostopoulos et al.Persistent authenticated dictionaries and their applications
CN113205415B (en)Financial process automation method and system based on RPA and block chain technology
CN106127016B (en)System and implementation method for trusted authentication of user login of operating system
CN105101196A (en)User account management method and device
CN103299268B (en) Method and apparatus for determining data access rights of a user group to a group of data elements
CN110868286B (en)Method for generating random number based on blockchain intelligent contract
CN109388971B (en) Cloud-based big data platform mobile office system
CN105184144A (en)Multi-system privilege management method
CN105471581A (en)Identity verification method and device
CN102044008A (en)Contract management information system
CN107566118A (en)The cloud auditing method that lightweight user Dynamic Revocable and data can dynamically update
US11940987B2 (en)Preventing a transmission of an incorrect copy of a record of data to a distributed ledger system
CN113067871A (en)Digital file management method based on block chain technology
CN113556393B (en)Multi-type intermodal data exchange system and method based on block chain
CN116561228A (en)System and method for archiving based on engineering archive sheet composition
CN114239040A (en)Menu permission control method and system based on prime number multiplication
CN107247643A (en)A kind of data base management method, device, system, storage medium and equipment
CN108846755A (en)A kind of right management method and device based on intelligent contract
CN112184225B (en)Cloud rendering resource exchange method based on blockchain
KR101247564B1 (en)Method of protecting data from malicious modification in data base system
CN102238037B (en) Collaborative Goal Policy Refinement Method
CN104125241A (en)Method for verifying password
CN106203065A (en)Charging pile Subscriber Management System and method
CN114168984B (en) An access control and file encryption method suitable for numerical control systems

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp