A TOTP-based Web application identity authentication method and system
By using TOTP to generate dynamic verification codes for identity authentication in web applications, the problems of key leakage and request forgery in traditional web authentication are solved, higher authentication security is achieved, and attacks such as man-in-the-middle interception and request forgery are prevented.
Patent Information
- Application Number
- CN202211199863.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-09-29
AI Technical Summary
Traditional Web authentication has security issues such as interception of authentication information by middlemen, brute force cracking of authentication information, and request forgery. How to perform Web authentication more securely has become a topic worthy of study.
Use the TOTP-based Web application identity authentication method to obtain the application number and key information in the main application background management, generate random codes for comparison, and prevent key leaks, and generate dynamic verification codes through TOTP as verification factors to prevent requests. Forgery and brute force attacks.
During the entire authentication process, key information is not leaked, which solves the security problem of middlemen intercepting network information, improves the security of authentication requests, prevents attacks such as authentication information packet capture and request forgery, and significantly improves the security of the authentication process. .
Smart Images

Figure CN115460015B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of Web authentication, and in particular relates to an identity authentication method and system for Web applications based on TOTP. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] Nowadays, Web development has been integrated into various native applications due to its high development efficiency and hot deployment. When integrated into native applications, the issue of login authentication information synchronization is involved. There are many problems in the traditional integration method, such as the middleman intercepting authentication information, brute force cracking of authentication information, authentication request forgery, etc. How to perform Web authentication more securely has become a topic worth studying.
[0004] In the traditional Web authentication process, a second automatic login is generally performed using authentication information. This method can easily leak authentication information in the network during the authentication process, causing various security issues. Therefore, verifying the security of information in Web authentication has become an important issue in the Web authentication process. Summary of the invention
[0005] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides an identity authentication method and system for Web applications based on TOTP. Not only the secret key information is not leaked in the request on the Internet, thus solving the security problem of the middleman intercepting the network information, but also a dynamic verification code is generated by TOTP as the verification factor of the request for authentication, thus preventing the problem of request forgery and brute force attack.
[0006] In order to achieve the above object, the present invention adopts the following technical solution:
[0007] A first aspect of the present invention provides a TOTP-based Web application identity authentication method, comprising:
[0008] The web application obtains the application number and key information from the main application background management, generates a first random code through TOTP based on the key information, and sends the application number and the first random code to the main application;
[0009] The main application obtains key information from the main application background management based on the application number, generates a second random code through TOTP, compares the second random code with the first random code, and sends a token to the Web application if the comparison results are consistent;
[0010] After the web application obtains the token, it communicates with the web application server over the network so that the web application server responds to the web application's request.
[0011] Furthermore, after receiving the registration request of the Web application, the main application background management generates an application number and key information.
[0012] Further, if the comparison result between the second random code and the first random code is inconsistent, the main application returns an error message.
[0013] Furthermore, after the Web application obtains the token, it uses the application number, the first random code and the token to perform network communication with the Web application server.
[0014] Furthermore, the Web application server generates a third random code through TOTP according to the key information, verifies the third random code and the first random code, and responds to the request of the Web application after the verification is successful.
[0015] A second aspect of the present invention provides a TOTP-based Web application identity authentication system, which includes a Web application and a main application;
[0016] The Web application is used to obtain the application number and key information from the main application background management, generate a first random code through TOTP based on the key information, and send the application number and the first random code to the main application;
[0017] The main application is used to obtain key information from the main application background management based on the application number, generate a second random code using the key information through TOTP, compare the second random code with the first random code, and send a token to the Web application if the comparison results are consistent;
[0018] The Web application is also used to perform network communication with the Web application server after obtaining the token, so that the Web application server responds to the request of the Web application.
[0019] Furthermore, after receiving the registration request of the Web application, the main application background management generates an application number and key information.
[0020] Furthermore, the main application is further configured to return an error message when the comparison result between the second random code and the first random code is inconsistent.
[0021] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the identity authentication method for a TOTP-based Web application as described above.
[0022] A fourth aspect of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the identity authentication method for a TOTP-based Web application as described above are implemented.
[0023] Compared with the prior art, the present invention has the following beneficial effects:
[0024] The present invention provides an identity authentication method for Web applications based on TOTP, in which the key is not reported in the request on the Internet during the whole process, thus solving the security problem of the middleman intercepting the network information.
[0025] The present invention provides an identity authentication method for a Web application based on TOTP, which generates a dynamic verification code through TOTP during the transmission process and uses it as a verification factor for the request for authentication. Due to the local calculation, dynamics and randomness of the verification code, compared with the current identity authentication method based on shared authentication information, the security of the authentication request process is greatly improved, and attacks such as stealing authentication information and request forgery by capturing the authentication request are prevented. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0027] Figure 1 This is a flow chart of an identity authentication method for a TOTP-based Web application according to Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0028] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0029] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0030] Terminology explanation:
[0031] TOTP (Time-based One-time Password algorithm) is an algorithm that calculates a one-time password based on a preset shared key and the current time. The password calculated by the algorithm will change within a certain period of time. It has been accepted by the Internet Engineering Task Force as the RFC 6238 standard, becoming the cornerstone of active open authentication and being used in many multi-factor authentication systems. TOTP can generate dynamic keys locally through shared keys, without network interaction, which greatly prevents key leakage and request forgery.
[0032] Embodiment 1
[0033] This embodiment provides a TOTP-based Web application identity authentication method, which generates a dynamic verification code through a TOTP shared key, and can determine the legitimacy of the Web authentication request based on the verification code to achieve a more secure identity authentication. Figure 1 As shown, the specific steps include:
[0034] Step 1: The third-party Web application is registered in the main application background management, and the third-party Web application obtains the application number (appid) and key (key) information from the main application background management.
[0035] Step 2: The third-party Web application generates a first random code through TOTP technology based on the key information obtained in step 1, and sends the appid and the first random code to the main application.
[0036] Step 3: The main application obtains the appid and the first random code, and first obtains the key from the main application background management based on the application number (the main application sends the appid to the main application background, and the main background obtains the key through the appid comparison and returns it to the main application). Then, the key is used to generate a second random code through TOTP, and the second random code is compared with the first random code sent by the third-party Web application. If the comparison results are consistent, the token information is sent to the third-party Web application; if the comparison results are inconsistent, an error message is returned.
[0037] Step 4: After the third-party Web application obtains the token information, it uses the appid, the first random code, the token, and the third-party Web application server to communicate over the network.
[0038] Specifically, the appid is sent to the third-party Web server so that the third-party Web server can match the key of the application. The key obtained by the appid generates a third random code and compares it with the first random code. This is the purpose of sending the first random code. The token is obtained from the main application. This is the authentication information of the main application. The token sent is carried as a parameter to the interface that needs authentication.
[0039] Step 5: The third-party Web application server generates a third random code through TOTP according to the key and verifies the first random code sent by the third-party application, and responds to the request of the third-party Web application after the verification is successful.
[0040] By comparing the third random code with the first random code, if they are equal, the verification is passed. The token can be used directly for other operations, eliminating the authentication process. Using the token to request an interface that requires authentication can directly succeed because the token is an authentication parameter generated after authentication, so after obtaining a legal token, you can make requests after authentication. The other operations here refer to requests that can be made after authentication. These request operations cannot be performed before obtaining the token.
[0041] There are two ways for a third-party Web application server to obtain a key: the first is to use the appid to request it from the main application background; the other is to store the appid and key values in the third-party Web service after the application is registered. When the third-party Web sends a request, the stored key can be obtained by matching the appid.
[0042] This embodiment provides a TOTP-based Web application identity authentication method to solve the identity and interface authentication between the third-party Web application and the main application. The TOTP key is generated when the third-party Web application is registered to the management background. The third-party Web application uses the key to generate a dynamic verification code and sends it to the main application. The main application also generates a dynamic verification code based on the key of the application for verification. If the verification passes, the application is trusted, and the token is sent to the third-party Web application. The third-party Web application uses the token to request, and the dynamic verification code will also be carried in the next request, and the dynamic verification code generated by the key will be verified on the server side. In the whole process, the dynamic verification code generated by TOTP acts as an authentication factor for the legitimacy of the application. Due to local calculation and dynamic changes, the whole process is more secure and reliable.
[0043] This embodiment provides a TOTP-based Web application identity authentication method for integrating a third-party application into a main application. The user registers the third-party application in the background of the main application to obtain the corresponding key information, and then generates a random code based on the key through TOTP and the main application generates a random code based on TOTP for verification. The identity authentication is completed, the token information is obtained, and communication and interaction with the background service are performed. In this process, the key is not reported in the Internet request, which solves the security problem of the middleman intercepting network information. Using TOTP technology and dynamic random code verification prevents the problem of request forgery and brute force attacks; during the transmission process, a dynamic verification code is generated through TOTP as a verification factor for the request for authentication. Due to the local calculation, dynamicity and randomness of the verification code; compared with the current method of identity authentication based on shared authentication information, the security of the authentication request process is greatly improved, and attacks such as packet capture of the authentication request to steal authentication information and request forgery are prevented.
[0044] Embodiment 2
[0045] This embodiment provides an identity authentication system for a Web application based on TOTP, which specifically includes a Web application and a main application;
[0046] The Web application is used to obtain the application number and key information from the main application background management, generate a first random code through TOTP based on the key information, and send the application number and the first random code to the main application;
[0047] The main application is used to obtain key information from the main application background management based on the application number, generate a second random code by using the key information through TOTP, compare the second random code with the first random code, and send a token to the Web application if the comparison results are consistent; when the comparison results of the second random code and the first random code are inconsistent, return an error message;
[0048] The Web application is also used to use the application number, the first random code and the command to perform network communication with the Web application server after obtaining the token, so that the Web application server responds to the request of the Web application.
[0049] After receiving the registration request from the Web application, the main application background management generates an application number and key information.
[0050] The web application server generates a third random code through TOTP according to the key information, verifies the third random code and the first random code, and responds to the request of the web application after the verification is successful.
[0051] This embodiment provides a TOTP-based Web application identity authentication system to solve the identity and interface authentication between the third-party Web application and the main application. The TOTP key is generated when the third-party Web application is registered to the management background. The third-party Web application uses the key to generate a dynamic verification code and sends it to the main application. The main application also generates a dynamic verification code based on the key of this application for verification. If the verification passes, the application is trusted, and the token is sent to the third-party Web application. The third-party Web application uses the token to request, and the dynamic verification code will also be carried in the next request, and the server will verify it based on the dynamic verification code generated by the key. In the whole process, the dynamic verification code generated by TOTP acts as an authentication factor for the legitimacy of the application. Due to local calculation and dynamic changes, the whole process is more secure and reliable.
[0052] It should be noted here that each module in this embodiment corresponds to each step in Example 1 one by one, and the specific implementation process is the same, which will not be repeated here.
[0053] Embodiment 3
[0054] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the identity authentication method for a Web application based on TOTP as described in the first embodiment above are implemented.
[0055] Embodiment 4
[0056] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the identity authentication method for a TOTP-based Web application as described in the first embodiment above are implemented.
[0057] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0058] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0059] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0060] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0061] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0062] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A TOTP-based web application identity authentication method. It is characterized in that include: The web application obtains the application number and key information from the main application background management, generates a first random code through TOTP based on the key information, and sends the application number and the first random code to the main application; The main application obtains key information from the main application background management based on the application number, generates a second random code through TOTP, compares the second random code with the first random code, and sends a token to the Web application if the comparison results are consistent; After the web application obtains the token, it communicates with the web application server over the network so that the web application server responds to the web application's request; After the Web application obtains the token, it uses the application number, the first random code and the token to communicate with the Web application server over the network; The application number is sent to the Web application server so that the Web application server can match the key information of the application, generate a third random code based on the key information obtained by the application number, and compare it with the first random code; The Web application server generates a third random code through TOTP according to the key information, verifies the third random code and the first random code, and responds to the request of the Web application after the verification is successful.
2. The identity authentication method for a Web application based on TOTP as claimed in claim 1, It is characterized in that After receiving the registration request of the Web application, the main application background management generates an application number and key information.
3. The identity authentication method for a Web application based on TOTP as claimed in claim 1, It is characterized in that If the comparison result between the second random code and the first random code is inconsistent, the main application returns an error message.
4. An identity authentication system for web applications based on TOTP, It is characterized in that Including web applications and main applications; The Web application is used to obtain the application number and key information from the main application background management, generate a first random code through TOTP based on the key information, and send the application number and the first random code to the main application; The main application is used to obtain key information from the main application background management based on the application number, generate a second random code using the key information through TOTP, compare the second random code with the first random code, and send a token to the Web application if the comparison results are consistent; The web application is also used to perform network communication with the web application server after obtaining the token, so that the web application server responds to the request of the web application; After the Web application obtains the token, it uses the application number, the first random code and the token to communicate with the Web application server over the network; The application number is sent to the Web application server so that the Web application server can match the key information of the application, generate a third random code based on the key information obtained by the application number, and compare it with the first random code; The Web application server generates a third random code through TOTP according to the key information, verifies the third random code and the first random code, and responds to the request of the Web application after the verification is successful.
5. The identity authentication system for a Web application based on TOTP as claimed in claim 4, It is characterized in that After receiving the registration request of the Web application, the main application background management generates an application number and key information.
6. The identity authentication system for a Web application based on TOTP as claimed in claim 4, It is characterized in that The main application is further configured to return an error message when the comparison result between the second random code and the first random code is inconsistent.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the steps in the identity authentication method for a TOTP-based Web application as described in any one of claims 1 to 3 are implemented.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps in the identity authentication method for a TOTP-based Web application as described in any one of claims 1-3 are implemented.
