Access authentication method, device and computer program product

By using WebAssembly to encapsulate the signature module, generate signature information and use an asymmetric encryption algorithm to sign the request body, the security risks and performance limitations of signature algorithms written in JavaScript are solved, and higher security and performance are achieved.

CN118740470APending Publication Date: 2024-10-01SHENZHEN DACHENG COMM TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410923966.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the existing technology, the signature algorithm of the Web front-end page is written in JavaScript, which has security risks and performance limitations. JavaScript is a plain text code in the browser and is easy to be stolen, and may affect page rendering when executing encryption and decryption logic, causing lags.

Method used

The network assembly language WebAssembly is used to encapsulate the signature module, generate signature information, and sign the request body through an asymmetric encryption algorithm to ensure signature security and performance.

Benefits of technology

It improves the security and performance of the signature, prevents the signature algorithm from being forged, ensures that the data sent by the client is not tampered with, and enhances data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740470A_ABST
    Figure CN118740470A_ABST
Patent Text Reader

Abstract

The invention discloses an access authentication method and device and a computer program product, and relates to the technical field of the Internet, and the method comprises the steps: obtaining a specified content after a target access request is obtained, and the specified content comprises a request body in the target access request; on the basis of a signature module, signature information is generated through the specified content, and the signature module is obtained after a signature algorithm is packaged on the basis of a network assembly language in advance; and sending a target access request carrying the signature information to a server, wherein the server is used for verifying the signature information. Therefore, the signature module is obtained after the signature algorithm is packaged in advance based on the network assembly language, so that the code logic of the signature module cannot be directly read, the signature algorithm can be prevented from being counterfeited, and the signature security is guaranteed. In addition, the signature is generated by the request body, so that the data sent by the client can be prevented from being tampered, and the data security is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and more specifically, to an access authentication method, device and computer program product. Background Art

[0002] With the popularization and application of information systems, there will inevitably be a need to interact with other platform systems for data. Due to the confidentiality requirements of data, an authentication mechanism is generally added to the interface (Application Programming Interface, API for short) to identify the true identity of the data caller and the legitimacy of the calling behavior. If the data caller passes the authentication, the called data will be returned to it. If the data caller fails to pass the authentication, its data call request will be ignored and no processing will be done on its request. At present, interface security signature is a technical means to ensure the integrity and source credibility of interface data. It is usually used in network communications, especially in scenarios such as API calls and microservice communications, to ensure that the transmitted data has not been tampered with or forged during the transmission process. Summary of the invention

[0003] The present application proposes an access authentication method, device and computer program product.

[0004] In a first aspect, the present application provides an access authentication method, characterized in that, when applied to a client, the method comprises: after obtaining a target access request, obtaining specified content, wherein the specified content comprises a request body in the target access request; based on a signature module, generating signature information through the specified content, wherein the signature module is pre-encapsulated based on a network assembly language to obtain a signature algorithm; and sending a target access request carrying the signature information to a server, wherein the server is used to verify the signature information.

[0005] In a third aspect, the present application also provides an access authentication device, which includes: an acquisition unit, a generation unit and a sending unit. The acquisition unit is used to obtain specified content after obtaining a target access request, and the specified content includes a request body in the target access request. The generation unit is used to generate signature information through the specified content based on a signature module, wherein the signature module is pre-encapsulated based on a network assembly language to obtain a signature algorithm. The sending unit is used to send a target access request carrying the signature information to a server, and the server is used to verify the signature information.

[0006] In a fifth aspect, the present application also provides a computer program product, wherein the computer program product includes a computer program, and the computer program implements the above method when executed by a processor.

[0007] The access authentication method, device and computer program product provided by the present application obtain the specified content, wherein the specified content includes the request body in the target access request; based on the signature module, the signature information is generated through the specified content, wherein the signature module is obtained by encapsulating the signature algorithm based on the network assembly language in advance; the target access request carrying the signature information is sent to the server, and the server is used to verify the signature information. Therefore, the signature module is obtained by encapsulating the signature algorithm based on the network assembly language in advance, so that the code logic of the signature module cannot be directly read, and the signature algorithm can be guaranteed not to be forged, so that the security of the signature is guaranteed. In addition, since the signature is generated by the request body, it can be guaranteed that the data sent by the client is not tampered with, further improving the data security.

[0008] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 A schematic diagram of signature verification for an ajax request is shown;

[0011] Figure 2 A schematic diagram of a network system provided by an embodiment of the present application is shown;

[0012] Figure 3 A method flow chart of an access authentication method provided by an embodiment of the present application is shown;

[0013] Figure 4 A method flow chart of an access authentication method provided by another embodiment of the present application is shown;

[0014] Figure 5 A schematic diagram of a network system provided by another embodiment of the present application is shown;

[0015] Figure 6 An interaction sequence diagram of a network system provided by an embodiment of the present application is shown;

[0016] Figure 7 A method flow chart of an access authentication method provided by yet another embodiment of the present application is shown;

[0017] Figure 8 A module block diagram of an access authentication device provided by an embodiment of the present application is shown;

[0018] Fig. 9 A module block diagram of an access authentication device provided by another embodiment of the present application is shown;

[0019] Fig.10 A structural block diagram of an electronic device provided in an embodiment of the present application is shown;

[0020] Fig.11 A storage unit for storing or carrying a program code for implementing an access authentication method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0021] In order to make those skilled in the art better understand the present application scheme, the technical scheme in the present application embodiment will be clearly and completely described below in conjunction with the drawings in the present application embodiment. Obviously, the described embodiment is only a part of the present application embodiment, rather than all the embodiments. The components of the present application embodiment usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application for protection, but merely represents the selected embodiment of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0022] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0023] With the popularization and application of information systems, there will inevitably be a need to interact with other platform systems for data. Due to the confidentiality requirements of data, an authentication mechanism is generally added to the interface (Application Programming Interface, API for short) to identify the true identity of the data caller and the legitimacy of the calling behavior. If the data caller passes the authentication, the called data will be returned to it. If the data caller fails to pass the authentication, its data call request will be ignored and no processing will be done on its request. At present, interface security signature is a technical means to ensure the integrity and source credibility of interface data. It is usually used in network communications, especially in scenarios such as API calls and microservice communications, to ensure that the transmitted data has not been tampered with or forged during the transmission process.

[0024] Currently, the code logic of the Web front-end page is written in a network scripting language (JavaScript, JS) file. The client (for example, the browser) loads the js file and executes the code logic therein. When the interface needs to be signed, the signature algorithm written in JS is called to generate a signature, and then the signature string is carried in the request header of the access request (for example, an ajax request), and the server verifies the signature string. Figure 1 As shown, taking the ajax request as an example, for an ajax request that is verified by the server, the server will return a valid response status code 200 to the Web front end, indicating that the request is allowed. If the server verification fails, the server will return an invalid response status code 403 to the Web front end, indicating that the request is prohibited.

[0025] However, the inventors found in their research that the current signature algorithm written in JS to generate signatures has security risks and performance limitations. Specifically, JavaScript runs in the browser and is plain text code, which is easy to steal code logic, directly affecting the security of interface signatures. JavaScript has performance bottlenecks when performing computationally intensive tasks. At the same time, JavaScript is single-threaded, and executing the encryption and decryption logic in the signature algorithm may affect page rendering and cause freezes.

[0026] Therefore, in order to overcome the above-mentioned defects, an embodiment of the present application provides an access authentication method, which can generate a signature using a signature module encapsulated in the network assembly language (WebAssembly), thereby improving security and performance.

[0027] like Figure 2 As shown, the method is applied to a network system, which includes a client 101 and a server 200, wherein the client 101 runs on an electronic device 100. The client 101 can access the server 200 after being authenticated by the server 200.

[0028] See also Figure 3 , Figure 3 An access authentication method provided in an embodiment of the present application is shown. The method is applied to a client. Specifically, the method includes: S301 to S303.

[0029] S301: After obtaining a target access request, obtaining specified content, wherein the specified content includes a request body in the target access request.

[0030] It is understandable that when the client needs to access the server, the client will first generate an access request, such as an API request. For example, in the scenario where the client accesses the server, it is usually necessary to first determine the request object, that is, the client needs to send the specific address and resource of the request to the server, and then generate the access request. Taking the API request as an example, the client generates the corresponding API request according to the operation to be performed (getting data, submitting data, etc.), for example, selecting the appropriate HTTP method (for example, GET, POST, PUT, DELETE, etc.), setting the request header (Headers), and constructing the request body (body).

[0031] It should be noted that the request header is a collection of metadata included in the HTTP request, usually organized in the form of key-value pairs, each of which represents an attribute or parameter. The request header provides information about the request, such as the request method (GET, POST, etc.), the target URL of the request, the content types supported by the client, the acceptable response content types, etc. The request body is an optional part of the HTTP request, usually containing data or information sent to the server. For some requests, such as POST, PUT, etc., when data needs to be submitted to the server, the request body is the carrier of this data. The content format of the request body is usually specified by the Content-Type field in the request header.

[0032] For example, when a client requests to send the order information of an Internet transaction to the server, the request header and request body can be configured by configuring Host, User-Agent, Content-Type, Authorization, and Content-Length in the request header. Among them, Host is the host name and port number of the specified server, such as Host:example.com, User-Agent contains information about the user agent software that initiates the request, such as the browser type and operating system version, and Content-Type is used to specify the type of data contained in the request body; Authorization is used to set authentication credentials, for example, to set the authentication method; Content-Length is used to set the length of the request body, usually in bytes. In addition, the actual data submitted by the client to the server is configured in the request body. This data is usually detailed information about the order, which can be form data or JSON format data, depending on the receiving method and convention of the server.

[0033] In the embodiment of the present application, the specified content is used for the subsequent generation of signature information. The target access request is a request from the client to interact with the server data, and the target access request includes a request body, which is used as the specified content, that is, the generation of the signature information in the embodiment of the present application uses the request body of the target access request.

[0034] S302: Generate signature information through the specified content based on a signature module, wherein the signature module is pre-encapsulated by a signature algorithm based on a network assembly language.

[0035] It should be noted that the network assembly language (WebAssembly, wasm) is a low-level binary instruction format of a stack-based virtual machine. In an embodiment of the present application, before using the signature module to generate signature information by specifying the content, the signature algorithm can be pre-encapsulated based on WebAssembly to obtain a signature module. Exemplarily, the signature algorithm to be used is first determined, for example, an asymmetric encryption algorithm, or other signature algorithms, which are not limited here. Then, the implementation of the signature algorithm is written in a programming language to obtain the signature algorithm code, wherein the programming language may include C, C++, Rust, etc., which are not limited. Then, the aforementioned signature algorithm code implementation is compiled into a WebAssembly binary module through a code conversion tool, thereby obtaining a signature wasm file with an extension name of wasm. The necessary function interface of the signature wasm file is exported, that is, the function definition of the signature wasm file (including function name, parameter list, return value, etc.) is exposed so that other modules or programs can call the function of the signature algorithm. Thus, the client can use JavaScript to load and call the signature algorithm code written in WebAssembly, that is, the signature wasm file. Finally, the logic of loading and calling the signature wasm file is encapsulated into an advanced JavaScript class or module to obtain a signature module.

[0036] It is understandable that the function of the signature module obtained after encapsulating the signature algorithm through the network assembly language is to obtain signature information using the specified content, that is, to process the specified content using the signature algorithm encapsulated by WebAssembly to generate signature information. Exemplarily, assuming that the signature algorithm is an asymmetric algorithm, the way to generate signature information for the specified content through the asymmetric algorithm can be to generate a pair of RSA keys, namely a public key and a private key, and the public key is generated by the private key. Among them, the public key is used to verify the validity of the signature. The private key is used to sign the data. After obtaining the specified content, the specified content is encrypted by the private key to generate signature information. Exemplarily, a hash function (such as SHA-256) is used to calculate the summary of the request body, and the private key of RSA is used to sign the summary of the request body, that is, the summary is encrypted into signature data, that is, the signature information is obtained.

[0037] S303: Send a target access request carrying the signature information to the server, and the server is used to verify the signature information.

[0038] As an implementation method, the signature information can be added to the target access request, so that when the target access request is sent to the server, the target access request carrying the signature information can be sent to the server. Exemplarily, the signature information can be added to the request header of the target access request, for example, the signature information can be added to the Authorization field of the HTTP request header. Of course, the signature information can also be added to the request body of the target access request, for example, the request body includes a data field and a signature field, wherein the data field is the actual request data, for example, it may be business data that needs to be transmitted or processed, and the signature field is a word for storing the generated signature information. The specific method of adding can be selected based on actual needs and the agreement with the server, and is not limited here.

[0039] After obtaining the target access request carrying the signature information, the server verifies the signature information. Specifically, taking the asymmetric signature algorithm as an example, the server extracts the request data and signature information from the received request. The request data is usually in the request body, and the signature information is usually a field in the request header or the request body. As mentioned above, the signature information can be added to the request body or to the request header. The server obtains the stored public key that is the same as the client's public key. In asymmetric encryption, the verification of the signature requires the use of the public key, while the generation of the signature uses the private key.

[0040] Specifically, the server extracts the original data used to generate the signature from the target access request, that is, the aforementioned specified content. The server uses the same asymmetric algorithm and the aforementioned public key used by the client to perform signature verification on the specified content. In other words, the server uses the public key to decrypt or verify the received signature information. The server will obtain the hash value of the original message (that is, the specified content) of the signature information (for example, recalculated by the same hash algorithm), and the server decrypts the signature (the characteristics of asymmetric encryption ensure that only the corresponding private key can decrypt), for example, using the public key signature for decryption to obtain a hash value, and then compare the two hash values. If they are consistent, it indicates that the signature is valid, that is, the signature information verification is passed, otherwise, it is determined that the signature information verification has failed.

[0041] Therefore, in the embodiment of the present application, the signature algorithm is pre-encapsulated based on the network assembly language to obtain the signature module, so that the code logic of the signature module cannot be directly read, which can ensure that the signature algorithm is not forged and the security of the signature is guaranteed. In addition, since the signature is generated by the request body, it can ensure that the data sent by the client is not tampered with, further improving data security.

[0042] See also Figure 4 , Figure 4 An access authentication method provided in an embodiment of the present application is shown. The method is applied to a client. Specifically, the method includes: S401 to S404.

[0043] S401: Encapsulate the signature code of the signature algorithm into an SDK component as a signature module through network assembly language.

[0044] As mentioned above, the signature module is obtained by encapsulating the signature algorithm based on the network assembly language in advance. In the embodiment of the present application, the signature SDK component is encapsulated using WebAssembly technology as the signature module.

[0045] Exemplarily, a programming language is used to write an implementation of the signature algorithm to obtain a signature code, and the signature code is compiled through WebAssembly to obtain a signature wasm file, wherein the implementation method of obtaining the signature wasm file can refer to the aforementioned embodiment and will not be repeated here. Then, the wasm file is encapsulated into an SDK component.

[0046] As an implementation method, the implementation method of encapsulating the signature code of the signature algorithm into an SDK component through network assembly language can be: converting the signature code of the signature algorithm into a first file corresponding to the network assembly language through network assembly language; creating an access interface based on the network scripting language, obtaining a second file corresponding to the access interface, the access interface is used for data interaction between the client and the signature module, and packaging the first file and the second file into an SDK component.

[0047] Exemplarily, the first file is the aforementioned wasm file. After obtaining the wasm file, an access interface (e.g., JavaScript API) is created using JavaScript to obtain a JS file, which is the second file, and is used to encapsulate the functions of the Wasm module so that it is easy to use in an application. For example, the corresponding functions of the access interface are defined by JavaScript to receive input parameters, call Wasm functions, process return values, etc. Then, the wasm file and the JS file are packaged into an SDK component.

[0048] Therefore, after obtaining the SDK component, the SDK component can be used as a signature module, so that the client can call the SDK component to generate signature information before sending a target access request. As an implementation, the SDK component can be installed in the electronic device as a client other than the client of the electronic device, and the SDK component is called by the client as a plug-in of the operating system of the electronic device. As another implementation, the SDK component can be installed in the client, so that the SDK component is used by the client as a plug-in of the client.

[0049] As an implementation, after encapsulating the signature code of the signature algorithm into an SDK component through WebAssembly, the method further includes: installing the SDK component in the client. Exemplarily, the SDK component can be used as a plug-in, and the client installs the plug-in, thereby installing the SDK component in the client.

[0050] In the embodiment of the present application, the SDK component can be an installation package so that the client can install the SDK component in the client. That is, after obtaining the first file and the second file, the first file and the second file are packaged into an SDK installation package, which not only facilitates the client to install the SDK installation package, thereby integrating the SDK component in the client, but also allows the SDK installation package to be published on a designated platform, and other clients can download the SDK installation package from the designated platform.

[0051] Furthermore, the SDK component may be a node package, which is a (Node Package Manager, NPM) installation package, and an NPM package refers to a software package or module available in the npm registry (npm registry). The node package is a standardized way for developers to easily share, manage, and reuse JavaScript modules and software packages. Since the SDK component is an NPM package, the SDK component can support JavaScript modular development, and can easily introduce, manage, and update various functional modules. In addition, since the npm registry has a large number of open source software packages, developers can quickly obtain and use modules shared by others. In addition, the NPM package defines and manages dependencies through the package.json file to ensure the compatibility and stability of each module version used in the project.

[0052] S402: After obtaining the target access request, obtaining specified content, wherein the specified content includes a request body in the target access request.

[0053] S403: Generate signature information through the specified content based on a signature module, wherein the signature module is pre-encapsulated by a signature algorithm based on a network assembly language.

[0054] In the above manner, the SDK component obtained by encapsulating the signature algorithm based on the WebAssembly technology is used to generate signature information based on the specified content. The specific method of generating signature information can refer to the aforementioned embodiment and will not be repeated here.

[0055] S404: Sending a target access request carrying the signature information to a server, where the server is used to verify the signature information.

[0056] It should be noted that after the server obtains the target access request, the server determines whether the target access request has been verified, wherein the verification includes the verification of the signature information carried by the target access request, that is, the verification of the signature information carried by the target access request. If the target access request is verified, the target content is sent to the client. The target content may be the content requested to be obtained corresponding to the target access request, for example, the target access request is used to request the server to obtain the target content. In addition, the target content may also be the response content returned by the server to the target access request. For example, the target access request is used to submit order information to the server to complete an e-commerce order. The target content may be the content returned by the server after processing the order, for example, product delivery information, etc., which is not specifically limited here.

[0057] It is understandable that when the content carried in the target access request sent by the client is different, the implementation method of the aforementioned verification is also different. For example, the target access request also carries a timestamp corresponding to the target access request, then the aforementioned verification can also include a re-detection result based on the timestamp as a detection pass, for example, the time difference between the specified moment and the timestamp is less than a preset time length, wherein the specified moment is the moment when the server receives the target access request, that is, a replay detection is performed, and the replay detection passes. In other words, when the client sends a target access request, the request carries a timestamp, and the server needs to perform a replay detection in addition to verifying the signature information.

[0058] For another example, the target access request also carries the device identification of the electronic device, and the verification also includes the identity detection result of the device identification being a detection pass. That is, when the client sends a target access request, the request carries the device identification, and the server needs to perform an identity detection on the device identification in addition to verifying the signature information.

[0059] It should be noted that, in addition to the verification of the signature information, at least one of the replay detection and the identity detection may be included. Specifically, the above verification method is described later through the interaction diagram between the client and the server.

[0060] Assume that the access authentication method is applied to a network system in a financial business scenario, that is, the access authentication method is used to solve the security problem of data interaction between the client and the server in the financial business scenario. Figure 5 As shown, the network system includes an electronic device 100, a financial gateway 501 and a business service end 505. The electronic device 100 is installed with a client 101. In the embodiment of the present application, the client 101 sends a target access request carrying at least signature information to the financial gateway 501. After determining that the target access request has been verified, the financial gateway 501 sends the target access request to the business service end 502, thereby returning the target content to the client 101. For the specific processing process, please refer to Figure 6 Interaction diagram shown.

[0061] Assume that the target access request is an API request, and the client is an H5 front-end, that is, a Web front-end application developed using technologies such as HTML5, CSS3, and JavaScript. Figure 6As shown, the client 101 calls the signature method before sending the API request. In the embodiment of the present application, the signature method is encapsulated in the SDK component through WebAssembly technology. Therefore, after the client 101 generates the API request, the signature required parameters are determined, that is, the specified content mentioned in the above embodiment. After the SDK component obtains the specified content, it generates signature information based on the specified content by calling the signature algorithm encapsulated based on WebAssembly. The SDK component returns the generated signature information to the client 101, and the client sends the API request carrying the signature information to the financial gateway 501.

[0062] After obtaining the API request, the financial gateway 501 extracts the signature information therein and performs a verification operation on the API request. Exemplarily, the verification operation performed by the financial gateway 501 includes verifying the signature information carried by the API request. If the signature information is verified, it is determined that the API request is verified. If the signature information is not verified, it is determined that the API request is not verified.

[0063] In some embodiments, in addition to performing the aforementioned signature verification, the verification operation on the access request may also include replay detection. The API request carries a timestamp corresponding to the target access request, which is the time when the target access request is generated. The financial gateway 501 performs verification operations on the API request, which may specifically include verifying the signature information carried by the API request and performing replay detection based on the timestamp. Replay detection refers to a network security technology used to prevent malicious users or automated programs (such as malware or attack scripts) from making repeated requests to a system or service. A replay attack is an attempt by an attacker to deceive the system by recording previously valid access requests and then resending the data at the appropriate time.

[0064] As an implementation method, the way to perform replay detection can be to determine the moment when the server receives the API request as the designated moment, and determine whether the time difference between the designated moment and the timestamp is less than the first duration. If it is less than the first duration, the detection result of the replay detection is determined to be a pass. If it is greater than or equal to the first duration, the detection result of the replay detection is determined to be a failure. In other words, to prevent the API request from being sent to the server again after being intercepted by the attacker before, the logic is that since the access request is stolen and then sent to the server, it takes longer than the client directly sending the access request to the server. In the former case, the time between the moment when the server receives the access request and the timestamp of the access request is greater. Therefore, by reasonably setting the first duration, the behavior of stealing the access request and then sending it to the server can be eliminated, so that the verification cannot pass. In addition, the setting of the first duration can also prevent the access request from being repeatedly initiated after being captured by the attacker. Through the setting of the first duration, the financial gateway can only pass the replay detection if the access request is received within the first duration.

[0065] As an implementation mode, the setting of the first duration can be set based on the type of the client or the type of the access request. Exemplarily, the time difference between the time when the server receives the access request and the timestamp corresponding to the access request each time the client sends an access request to the server can be counted in advance as a historical time difference, and the historical time differences corresponding to multiple access requests can be counted in advance, and the specified time difference is obtained based on the multiple historical time differences, for example, the average value of the multiple historical time differences is used as the specified time difference, or the largest historical time difference among the multiple historical time differences is used as the specified time difference, or the smallest historical time difference among the multiple historical time differences is used as the specified time difference. In addition, in order to increase the accuracy of obtaining the specified time difference, the network signal quality corresponding to the access requests corresponding to the multiple historical time differences is distributed in different quality ranges, wherein the network signal quality corresponding to the access request refers to the communication quality between the client and the server when the client sends the access request, and the different quality ranges can refer to the numerical distribution range of the communication quality, and the higher the value, the better the communication quality. Therefore, by obtaining the time it takes for the client to send an access request to the server under network signal qualities distributed in different quality ranges (i.e., the historical time difference), the statistics of the historical time difference can take into account the impact of network quality, thereby making the statistics of the specified time difference more accurate.

[0066] Then, the first duration is obtained based on the specified time difference. For example, the product of the specified time difference and the first weight can be used as the first duration, wherein the first weight is a natural number greater than 0. Exemplarily, considering that the specified time difference can be used as the minimum value that can be set for the first duration, the first weight can be set to a natural number greater than or equal to 1. Specifically, the first weight is related to the information of the client. For example, the information of the client can be the privacy level of the client, and the privacy level is negatively correlated with the first weight, so that the access request sent by the high-privacy client needs to reach the server as soon as possible, and it can also make it more difficult for the attacker to steal the access request and attack the server. For clients with lower privacy levels, the first duration is made larger on the basis of the specified time difference, so that the setting of the first duration can be compatible with more usage scenarios of the client, for example, in a worse network environment or an electronic device that sends an access request too slowly due to excessive load, by increasing the first duration, the access request in these scenarios can also pass the replay detection, thereby improving the fault tolerance rate. The privacy level of a client may be pre-selected for client configuration, or may be set based on the frequency of the client operating privacy data within a preset time period, where the privacy data includes personal identity information, device information, geographic location, etc., and the frequency is positively correlated with the privacy level.

[0067] It should be noted that the timestamp can be located in the access request, for example, the timestamp is added to the request header. For example, when using the REST API, the timestamp can be added to the header of the HTTP request as a custom header field. As an implementation method, the timestamp can not only be used to perform replay detection, but also can be used as part of the specified content for generating signature information. That is, the specified content includes not only the request body but also the timestamp. Then, the request body and the timestamp can be concatenated into a string, and the signature information is generated based on the signature module using the string. That is to say, when the client sends the signature required parameters to the SDK component, the timestamp and the request body are sent together as the signature required parameters, that is, the specified content, to the SDK component, so that the SDK component uses the timestamp and the request body to generate the signature information at the same time, and returns the signature information to the client.

[0068] In other embodiments, in addition to performing the aforementioned signature verification, the verification operation of the access request may also include the identity detection of the electronic device. If the target access request also carries the device identification of the electronic device, the aforementioned verification of the target access request may include the identity detection result of the device identification as a detection pass in addition to the verification of the signature information carried by the target access request. Exemplarily, the device identification may be added to the request header or request body of the target access request as a custom field. It should be noted that if the device identification is located in the request body, the device identification is also used as part of the specified content for generating the signature information. Therefore, it can be based on whether the device identification is used to generate the signature information, and whether the device identification is stored in the request header or the request body, which is not limited here. The device identification may be the device identification of the electronic device on which the client is installed. For example, if the electronic device is a mobile terminal, the device identification may be the hardware ID (such as MAC address, IMEI number) of the mobile terminal, the software ID provided by the operating system (such as Android ID of Android, Identifier for Vendor of iOS), etc., which is not limited here.

[0069] For the server, the server can pre-store a list of devices, which includes the device identifiers of authorized access. Figure 6 Taking the financial gateway shown as an example, the device list is stored in the financial gateway. After the financial gateway obtains the device identifier carried by the target access request, the device identifier is matched with the device list. If a device identifier matching the device identifier carried by the target access request can be found in the device list, the identity detection result of the device identifier is determined to be passed. Otherwise, the identity detection result of the device identifier is determined to be failed.

[0070] It is understandable that in applications that need to protect the real user experience, such as games, financial services, or online learning platforms, the use of device identification can effectively prevent illegal access by simulators or virtual machines. In other words, only when the target access request initiated by the device identification that has passed the server detection passes its signature verification, it is possible to allow it to access the server. In addition, the use of device identification can increase the recognition of real devices to a certain extent. Although virtual machines or simulators can theoretically simulate device identification, additional technology and configuration may be required for virtual machines or simulators to simulate real device IDs. This additional complexity will increase the threshold for attacks, making it difficult for casual attackers to carry out attacks. On this basis, it is also possible to add IP address detection, user behavior analysis, and other methods on the basis of identity detection of device identification to increase the difficulty for attackers to attack the server through virtual machines or simulators.

[0071] like Figure 6 As shown, after the financial gateway verifies the API request, the financial gateway forwards the API request to the business service end, and the business service end responds with data to the client, for example, sending the target content to the client. Among them, the verification of the API request includes the aforementioned signature verification, and may also include at least one of identity detection and replay detection. The specific method refers to the aforementioned content and will not be repeated here. If the financial gateway fails to verify the API request, it returns a specified error code to the client, wherein the specified error code is used to inform the client that the target access request is not allowed to access. Exemplarily, after receiving the specified error code, the client displays a prompt content, and the prompt content is used to prompt that the target access request is not allowed to access. Exemplarily, the prompt content is displayed through a notification message, or through a pop-up window. The prompt content can also be used to prompt the user to refresh the client's interface, or switch to an interface other than the current interface of the client for display, wherein the interface other than the current interface can be the upper-level interface of the current interface.

[0072] Therefore, in the embodiment of the present application, not only can the signature information of the target access request be verified, but also replay detection can be performed based on the timestamp and / or identity detection can be performed based on the device identification, thereby improving the security of access.

[0073] See also Figure 7 , Figure 7 An access authentication method provided in an embodiment of the present application is shown. The method is applied to a server. Specifically, the method includes: S701 to S702.

[0074] S701: Receive a target access request carrying the signature information, which is sent by a client based on the method of the aforementioned embodiment.

[0075] S702: Verify the signature information.

[0076] As an implementation method, after obtaining the target access request carrying signature information, the server performs a verification operation on the target access request. The verification operation includes verifying the signature information carried by the target access request. If the signature information is verified, it is determined that the API request is verified. If the signature information is not verified, it is determined that the API request is not verified.

[0077] As an implementation method, the target access request sent by the client carries a timestamp in addition to the signature information. After the server obtains the target access request, the verification operation performed includes: verifying the signature information carried by the target access request and re-verification detection based on the timestamp. If the signature information verification passes and the re-verification detection result is a pass, it is determined that the API request verification passes; otherwise, it is determined that the API request verification fails.

[0078] As another implementation, the target access request sent by the client carries, in addition to the signature information, also the device identification of the electronic device on which the client is installed. After the server obtains the target access request, the verification operations performed include: verifying the signature information carried by the target access request and detecting the identity of the device identification. If the signature information verification passes and the identity detection passes, it is determined that the API request verification passes; otherwise, it is determined that the API request verification fails.

[0079] As another implementation method, the target access request sent by the client carries, in addition to the signature information, a timestamp and a device identification of the electronic device on which the client is installed. After the server obtains the target access request, the verification operations performed include: verification of the signature information carried by the target access request, re-entry detection based on the timestamp, and identity detection of the device identification. If the signature information verification passes, the re-entry detection result is a detection pass, and the identity detection passes, then it is determined that the API request verification passes; otherwise, it is determined that the API request verification fails.

[0080] See also Figure 8 , which shows a structural block diagram of an access authentication device 800 provided in an embodiment of the present application. The device is applied to a client and may include: an acquisition unit 801, a generation unit 802 and a sending unit 803.

[0081] The acquisition unit 801 is used to acquire specified content after obtaining a target access request, where the specified content includes a request body in the target access request.

[0082] The generating unit 802 is used to generate signature information through the specified content based on a signature module, wherein the signature module is pre-encapsulated by the signature algorithm based on the network assembly language.

[0083] Furthermore, the generating unit 802 is further used to encapsulate the signature code of the signature algorithm into an SDK component as a signature module through network assembly language.

[0084] Furthermore, the generation unit 802 is also used to convert the signature code of the signature algorithm into a first file corresponding to the network assembly language through the network assembly language; create an access interface based on the network scripting language to obtain a second file corresponding to the access interface, and the access interface is used for data interaction between the client and the signature module; and package the first file and the second file into an SDK component.

[0085] Furthermore, the generating unit 802 is further configured to encapsulate the signature code of the signature algorithm into an SDK component through a network assembly language, and then install the SDK component in the client.

[0086] Furthermore, the SDK component is a node package.

[0087] The sending unit 803 is used to send a target access request carrying the signature information to the server, and the server is used to verify the signature information.

[0088] Furthermore, the access authentication device 800 also includes an acquisition unit, which is used to send a target access request carrying the signature information to the server, and obtain the target content returned by the server after determining that the target access request has been verified, wherein the verification includes the verification of the signature information carried by the target access request.

[0089] Furthermore, the target access request also carries a timestamp corresponding to the target access request, and the verification passing also includes a re-detection result based on the timestamp being a detection passing result.

[0090] Furthermore, the client is installed in an electronic device, the target access request also carries a device identification of the electronic device, and the verification passing also includes identity detection passing of the device identification.

[0091] See also Fig. 9 , which shows a structural block diagram of an access authentication device 900 provided in an embodiment of the present application. The device is applied to a client and may include: a receiving unit 901 and a verification unit 902.

[0092] The receiving unit 901 is used to receive a target access request carrying the signature information and sent by the client based on the method of the above embodiment.

[0093] The verification unit 902 verifies the signature information.

[0094] Furthermore, the verification unit 902 is also used to perform a verification operation on the target access request after obtaining the target access request carrying signature information. The verification operation includes verifying the signature information carried by the target access request. If the signature information is verified, it is determined that the API request is verified. If the signature information is not verified, it is determined that the API request is not verified.

[0095] Furthermore, the target access request sent by the client carries a timestamp in addition to the signature information. The verification unit 902 is also used to verify the signature information carried by the target access request and to perform a re-entry detection based on the timestamp. If the signature information verification passes and the re-entry detection result is a passed detection, it is determined that the API request verification passes; otherwise, it is determined that the API request verification fails.

[0096] Furthermore, the target access request sent by the client carries, in addition to the signature information, a device identifier of the electronic device on which the client is installed. The verification unit 902 is also used to verify the signature information carried by the target access request and to detect the identity of the device identifier. If the signature information verification passes and the identity detection passes, it is determined that the API request verification passes; otherwise, it is determined that the API request verification fails.

[0097] Furthermore, the target access request sent by the client carries, in addition to the signature information, a timestamp and a device identification of the electronic device on which the client is installed. The verification unit 902 is also used to verify the signature information carried by the target access request, a re-entry detection based on the timestamp, and an identity detection of the device identification. If the signature information verification passes, the re-entry detection result is a detection pass, and the identity detection passes, then it is determined that the API request verification passes; otherwise, it is determined that the API request verification fails.

[0098] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0099] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0100] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0101] Please refer to Fig.10, which shows a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0102] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0103] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0104] Please refer to Fig.11, which shows a structural block diagram of a computer-readable medium provided in an embodiment of the present application. The computer-readable medium 1100 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0105] The computer readable medium 1100 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable medium 1100 includes a non-transitory computer-readable storage medium. The computer readable medium 1100 has storage space for program code 1110 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 1110 can be compressed, for example, in an appropriate form.

[0106] A computer program product for an electronic device comprises: the computer program product comprises a computer program, and the computer program implements the aforementioned method when executed by a processor.

[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An access authentication method, characterized in that: Applied to a client, the method comprises: After obtaining the target access request, obtaining specified content, the specified content including the request body in the target access request; Based on the signature module, the signature information is generated through the specified content, wherein the signature module is pre-encapsulated by the signature algorithm based on the network assembly language; A target access request carrying the signature information is sent to a server, and the server is used to verify the signature information.

2. The method according to claim 1, characterized in that Before the signature module generates the signature information through the specified content, the method further includes: Through network assembly language, the signature code of the signature algorithm is encapsulated into an SDK component as a signature module.

3. The method according to claim 2, characterized in that The signature code of the signature algorithm is encapsulated into an SDK component through the network assembly language, including: Using the network assembly language, converting the signature code of the signature algorithm into a first file corresponding to the network assembly language; Creating an access interface based on a network scripting language, and obtaining a second file corresponding to the access interface, wherein the access interface is used for data interaction between the client and the signature module; The first file and the second file are packaged into an SDK component.

4. The method according to claim 2 or 3, characterized in that: After the signature code of the signature algorithm is encapsulated into an SDK component through the network assembly language, it also includes: Install the SDK component in the client.

5. The method according to claim 2 or 3, characterized in that: The SDK component is a node package.

6. The method according to claim 1, characterized in that After sending the target access request carrying the signature information to the server, the method further includes: Obtain the target content returned by the server after determining that the target access request has been verified, wherein the verification includes the verification of the signature information carried by the target access request.

7. The method according to claim 6, characterized in that The target access request also carries a timestamp corresponding to the target access request, and the verification passing also includes a re-detection result based on the timestamp being a detection passing result.

8. The method according to claim 6, characterized in that The client is installed in an electronic device, the target access request also carries a device identification of the electronic device, and the verification passing also includes identity detection passing of the device identification.

9. An access authentication device, characterized in that: The device comprises: An acquisition unit, configured to acquire specified content after obtaining a target access request, wherein the specified content includes a request body in the target access request; A generating unit, configured to generate signature information through the specified content based on a signature module, wherein the signature module is preliminarily obtained by encapsulating a signature algorithm based on a network assembly language; The sending unit is used to send a target access request carrying the signature information to a server, and the server is used to verify the signature information.

10. A computer program product, characterized in that The computer program product includes a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Interface request security verification method, device and system, and electronic equipment

    CN119628830A

  • Network layer security guarantee method and system for remotely accessing intelligent device with body

    CN121585400A

  • Method and system for securing network layer of a remote access embodied smart device

    CN121585400B