Interface calling method, device and computer equipment
By verifying the signature and time-limited unique request identification in interface calls, combined with the source return confirmation mechanism, the problem of insufficient security of interface calls in the existing technology is solved, effective protection against illegal calls and attacks is achieved, and the security of interface calls is improved sex.
Patent Information
- Application Number
- CN202211214698.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-01
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2042-10-01
AI Technical Summary
Existing interface calling schemes are difficult to prevent illegal calls and attacks from intranet or IP whitelists, such as playback attacks, brute-force cracking, etc., resulting in insufficient security of interface calls.
By receiving interface call requests, we obtain business parameters, interface call end identification, time-limited unique request identification and call request signature information, verify the signature information and obtain the key, send back the source confirmation request, and authenticate it with time-limited unique request identification. Prevent illegal forgery and replay attacks.
Effectively prevent illegal forgery requests and attacks, improve the security of interface calls, support intercepting internal and external illegal calls and man-in-the-middle attacks, and enhance the security of the system.
Smart Images

Figure CN116055053B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to an interface calling method, device, computer equipment and computer-readable storage medium. Background Art
[0002] With the development of information technology, the complexity of software service applications is increasing. It is difficult for a single server application to meet software requirements, which will involve remote calls between internal service applications, or even remote calls between external applications across the Internet. For example, a business system of an enterprise is often composed of different applications, developed and maintained by different teams; software applications involving payment, SMS and other functions will need to call third-party interfaces to complete the corresponding functions. How to identify illegal calls and attacks with high security authentication is a problem that needs to be solved in these application scenarios.
[0003] Most of the interface calling solutions provided in the current technology encrypt and decrypt the request parameters when calling the interface, and in some cases add IP whitelists or intranet restrictions to implement interface calling. However, this technology is difficult to prevent illegal calls or attacks initiated from the intranet or IP whitelist, replay attacks, brute force cracking, etc., and the security of its interface calling still needs to be improved. Summary of the invention
[0004] Based on this, it is necessary to provide an interface calling method, apparatus, computer device and computer-readable storage medium to address the above technical problems.
[0005] In a first aspect, the present application provides an interface calling method, which is applied to an interface providing end. The method comprises:
[0006] Receive an interface call request from an interface call end;
[0007] Obtaining the service parameters, interface calling terminal identifier, time-limited unique request identifier and calling request signature information included in the interface calling request;
[0008] Obtaining a key corresponding to the interface calling end identifier, and verifying the calling request signature information according to the key corresponding to the interface calling end identifier;
[0009] When the verification of the call request signature information is passed, the back-to-source address corresponding to the interface call end identifier is obtained, and a back-to-source confirmation request is sent according to the back-to-source address; the back-to-source confirmation request includes the interface provider identifier, the time-limited unique request identifier and the back-to-source request signature information;
[0010] When the back-to-source verification pass information is received, the interface call result is returned to the interface call end according to the business parameters.
[0011] In one of the embodiments, after obtaining the business parameters, interface caller identifier, time-limited unique request identifier and call request signature information included in the interface call request, the method further includes: obtaining the interface call authority scope corresponding to the interface caller according to the interface caller identifier; judging whether the interface caller has the interface call authority corresponding to the interface call request according to the interface call authority scope corresponding to the interface caller; and if so, executing the step of obtaining the key corresponding to the interface caller identifier and verifying the call request signature information according to the key corresponding to the interface caller identifier.
[0012] In one of the embodiments, the obtaining of the key corresponding to the interface call end identifier and the verification of the call request signature information according to the key corresponding to the interface call end identifier include: obtaining a preset key library pre-agreed with each interface call end; obtaining the key corresponding to the interface call end identifier from the preset key library according to the interface call end identifier included in the interface call request; and verifying the call request signature information according to the key corresponding to the interface call end identifier.
[0013] In one of the embodiments, obtaining the back-to-source address corresponding to the interface calling end identifier and sending a back-to-source confirmation request based on the back-to-source address include: obtaining a back-to-source address library pre-agreed with each interface calling end; obtaining the back-to-source address corresponding to the interface calling end identifier from the back-to-source address library based on the interface calling end identifier included in the interface calling request; obtaining the interface providing end identifier; signing the interface providing end identifier and the time-limited unique request identifier to obtain the back-to-source request signature information; obtaining the back-to-source confirmation request based on the interface providing end identifier, the time-limited unique request identifier and the back-to-source request signature information; and sending the back-to-source confirmation request based on the back-to-source address.
[0014] In a second aspect, the present application provides an interface calling method. Applied to an interface calling end. The method comprises:
[0015] Obtain an interface call request based on business parameters, interface call end identifier, time-limited unique request identifier, and call request signature information;
[0016] Sending the interface call request to the interface provider;
[0017] Receive a back-to-source confirmation request from the interface provider, and obtain the interface provider identifier, a time-limited unique request identifier, and back-to-source request signature information included in the back-to-source confirmation request;
[0018] When it is determined that the received time-limited unique request identifier meets the time limit condition, obtaining a key corresponding to the interface provider identifier, and verifying the back-to-source request signature information according to the key corresponding to the interface provider identifier;
[0019] When the verification of the signature information of the back-to-source request is passed, sending back-to-source verification passing information to the interface provider;
[0020] Receive the interface call result returned by the interface provider.
[0021] In one of the embodiments, the interface call request is obtained according to the business parameters, the interface call end identifier, the time-limited unique request identifier and the call request signature information, including: generating a time-limited unique request identifier with a certain time limit condition; obtaining the business parameters and the interface call end identifier; signing the business parameters, the time-limited unique request identifier and the interface call end identifier to obtain the call request signature information; obtaining the interface call request according to the business parameters, the interface call end identifier, the time-limited unique request identifier and the call request signature information.
[0022] In one of the embodiments, the generation of a time-limited unique request identifier with a certain time limit condition includes: obtaining the requested interface call level; obtaining the time limit condition corresponding to the interface call level among multiple preset time limit conditions; and generating a time-limited unique request identifier with the time limit condition corresponding to the interface call level.
[0023] In a third aspect, the present application also provides an interface calling device, which is applied to an interface providing end. The device includes:
[0024] A call request receiving module, used for receiving an interface call request from an interface call end;
[0025] A call information acquisition module, used to obtain the service parameters, interface call end identifier, time-limited unique request identifier and call request signature information included in the interface call request;
[0026] A call request verification module, used to obtain the key corresponding to the interface call end identifier, and verify the call request signature information according to the key corresponding to the interface call end identifier;
[0027] A back-to-source request sending module is used to obtain the back-to-source address corresponding to the interface calling end identifier when the verification of the call request signature information is passed, and send a back-to-source confirmation request according to the back-to-source address; the back-to-source confirmation request includes the interface providing end identifier, the time-limited unique request identifier and the back-to-source request signature information;
[0028] The call result returning module is used to return the interface call result to the interface calling end according to the business parameters when receiving the back-to-source verification pass information.
[0029] In a fourth aspect, the present application further provides an interface calling device, which is applied to an interface calling end. The device comprises:
[0030] A call request obtaining module is used to obtain an interface call request according to business parameters, an interface call end identifier, a time-limited unique request identifier, and a call request signature information;
[0031] A call request sending module, used to send the interface call request to the interface provider;
[0032] A back-to-source request receiving module, used to receive a back-to-source confirmation request from the interface provider, and obtain the interface provider identifier, a time-limited unique request identifier, and a back-to-source request signature information included in the back-to-source confirmation request;
[0033] A back-to-source request verification module, used to obtain a key corresponding to the interface provider identifier when determining that the received time-limited unique request identifier meets a time limit condition, and verify the back-to-source request signature information according to the key corresponding to the interface provider identifier;
[0034] A verification information sending module, used for sending back-to-source verification passing information to the interface providing end when the verification of the back-to-source request signature information is passed;
[0035] The call result receiving module is used to receive the interface call result returned by the interface provider.
[0036] In a fifth aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0037] Receive an interface call request from an interface caller; obtain the business parameters, interface caller identifier, time-limited unique request identifier and call request signature information included in the interface call request; obtain the key corresponding to the interface caller identifier, and verify the call request signature information according to the key corresponding to the interface caller identifier; when the verification of the call request signature information passes, obtain the return-to-source address corresponding to the interface caller identifier, and send a return-to-source confirmation request according to the return-to-source address; the return-to-source confirmation request includes the interface provider identifier, time-limited unique request identifier and return-to-source request signature information; when the return-to-source verification pass information is received, return the interface call result to the interface caller according to the business parameters.
[0038] In a sixth aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0039] An interface call request is obtained according to business parameters, an interface call end identifier, a time-limited unique request identifier and a call request signature information; the interface call request is sent to an interface provider; a back-to-source confirmation request from the interface provider is received, and the interface provider identifier, the time-limited unique request identifier and the back-to-source request signature information included in the back-to-source confirmation request are obtained; when it is determined that the received time-limited unique request identifier meets a time limit condition, a key corresponding to the interface provider identifier is obtained, and the back-to-source request signature information is verified according to the key corresponding to the interface provider identifier; when the back-to-source request signature information is verified, back-to-source verification pass information is sent to the interface provider; and an interface call result returned by the interface provider is received.
[0040] In a seventh aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0041] Receive an interface call request from an interface caller; obtain the business parameters, interface caller identifier, time-limited unique request identifier and call request signature information included in the interface call request; obtain the key corresponding to the interface caller identifier, and verify the call request signature information according to the key corresponding to the interface caller identifier; when the verification of the call request signature information passes, obtain the return-to-source address corresponding to the interface caller identifier, and send a return-to-source confirmation request according to the return-to-source address; the return-to-source confirmation request includes the interface provider identifier, time-limited unique request identifier and return-to-source request signature information; when the return-to-source verification pass information is received, return the interface call result to the interface caller according to the business parameters.
[0042] In an eighth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0043] An interface call request is obtained according to business parameters, an interface call end identifier, a time-limited unique request identifier and a call request signature information; the interface call request is sent to an interface provider; a back-to-source confirmation request from the interface provider is received, and the interface provider identifier, the time-limited unique request identifier and the back-to-source request signature information included in the back-to-source confirmation request are obtained; when it is determined that the received time-limited unique request identifier meets a time limit condition, a key corresponding to the interface provider identifier is obtained, and the back-to-source request signature information is verified according to the key corresponding to the interface provider identifier; when the back-to-source request signature information is verified, back-to-source verification pass information is sent to the interface provider; and an interface call result returned by the interface provider is received.
[0044] The above-mentioned interface calling method, device, computer equipment and storage medium receive the interface calling request of the interface calling end, obtain the business parameters, interface calling end identifier, time-limited unique request identifier and calling request signature information included therein, verify the calling request signature information according to the key corresponding to the interface calling end identifier, obtain the back-to-source address corresponding to the interface calling end identifier when the verification is passed, send a back-to-source confirmation request according to the back-to-source address, and return the interface calling result to the interface calling end according to the business parameters when the back-to-source verification pass information is received. The scheme uses signature verification to effectively prevent illegal forged requests, and can support interception of internal and external illegal calls and brute force attacks. In addition to signature verification and authentication, it also combines back-to-source and time-limited expired unique request identifiers to implement verification and authentication, prevent various attacks such as replay attacks and man-in-the-middle attacks, and improve the security of interface calls. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is an application environment diagram of the interface calling method in the embodiment of the present application;
[0046] Figure 2 This is a flowchart of the interface calling method in the embodiment of the present application;
[0047] Figure 3 This is a flowchart of an interface calling method in another embodiment of the present application;
[0048] Figure 4 This is a timing diagram of the interface calling method in a specific example of this application;
[0049] Figure 5 This is a structural block diagram of the interface calling device in the embodiment of the present application;
[0050] Figure 6 This is a structural block diagram of an interface calling device in another embodiment of the present application;
[0051] Figure 7 Schematic diagram of the internal structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] The interface calling method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown, the application environment may include an interface calling end and an interface providing end, the interface providing end is a device end for providing interface services, the interface calling end is a device end for requesting interface services from the interface providing end, and the interface calling end and the interface providing end may communicate through a network. Specifically, both the interface calling end and the interface providing end may be computer devices such as servers and terminals, wherein the terminals may be, but are not limited to, various personal computers, notebook computers, etc., and the servers may be implemented by independent servers or server clusters consisting of multiple servers.
[0054] In one embodiment, Figure 2 As shown, the present application provides an interface calling method, which can be applied to Figure 1 The interface provider in the method may include the following steps:
[0055] Step S201, receiving an interface calling request from an interface calling end.
[0056] Step S202, obtaining the service parameters, interface calling end identifier, time-limited unique request identifier and calling request signature information included in the interface calling request.
[0057] In step S201 and step S202, the interface provider may receive an interface call request from the interface caller, which is used by the interface caller to request an interface service from the interface provider. The interface caller may put business parameters in the interface call request, and the interface provider may feedback the corresponding interface call result according to the business parameters. To ensure the security of the interface call, in addition to the business parameters, the interface call request of the interface caller must also include the interface caller identifier, the time-limited unique request identifier, and the call request signature information. Among them, the interface calling end identifier can be a number used to identify the interface calling end; the time-limited unique request identifier is generated by the interface calling end, and is a request identifier with uniqueness and certain time-limited conditions. It can be generated specifically for this interface calling request, so the time-limited unique request identifier can be a one-time and time-limited identifier. For example, the interface calling end can use UUID (Universally Unique Identifier), timestamp or participate in the encrypted signature string and assign it a certain validity period (such as 1 minute expiration) to generate the time-limited unique request identifier; the call request signature information refers to the signature information formed by the interface calling end for the call request. The interface calling end can sign the business parameters, the interface calling end identifier, and the time-limited unique request identifier to obtain the call request signature information. For example, the encrypted signature in this application can use symmetric encryption such as MD5, SHA1, AES or asymmetric encryption signature schemes such as RSA. Based on this, the interface calling end can send an interface call request containing the business parameters, interface calling end identifier, time-limited unique request identifier and call request signature information to the interface providing end, and the interface providing end receives and obtains the business parameters, interface calling end identifier, time-limited unique request identifier and call request signature information.
[0058] Step S203, obtaining the key corresponding to the interface calling end identifier, and verifying the calling request signature information according to the key corresponding to the interface calling end identifier.
[0059] Step S204, when the verification of the call request signature information is passed, the back-to-source address corresponding to the interface call end identifier is obtained, and a back-to-source confirmation request is sent according to the back-to-source address.
[0060] For step S203 and step S204, the interface provider and the interface caller may pre-agree on the encryption signature scheme, key, identifier, and return source address of both parties. Therefore, in step S203, after obtaining the interface caller identifier, the interface provider may pre-agree on the encryption signature scheme, key, and identifier with the interface caller, obtain the key and encryption signature scheme corresponding to the interface caller identifier, and verify the call request signature information according to the key and encryption signature scheme corresponding to the interface caller identifier. If the interface provider fails to verify the call request signature information, the interface provider may not respond to the interface call request.
[0061] In step S204, if the interface provider passes the verification of the call request signature information, the interface provider can obtain the back-to-source address pre-agreed with the interface caller. Specifically, the interface provider obtains its back-to-source address according to the identifier corresponding to the interface caller identifier, and then the interface provider sends a back-to-source confirmation request according to the back-to-source address. Among them, the back-to-source confirmation request needs to include the interface provider identifier, the aforementioned time-limited unique request identifier and the back-to-source request signature information. Among them, the interface provider identifier can be a number used to identify the interface provider; the back-to-source request signature information refers to the signature information formed by the interface provider for the back-to-source confirmation request. Specifically, the interface provider can sign the interface provider identifier and the time-limited unique request identifier to obtain the back-to-source request signature information. As a result, the interface provider can send the back-to-source confirmation request containing the interface provider identifier, the time-limited unique request identifier and the back-to-source request signature information to the interface caller according to the back-to-source address.
[0062] Further, as an embodiment, obtaining the back-to-source address corresponding to the interface calling end identifier in step S204 and sending the back-to-source confirmation request according to the back-to-source address may include:
[0063] Obtain a back-to-source address library pre-agreed with each interface caller; obtain the back-to-source address corresponding to the interface caller identifier included in the interface call request from the back-to-source address library; obtain the interface provider identifier; sign the interface provider identifier and the time-limited unique request identifier to obtain the back-to-source request signature information; obtain the back-to-source confirmation request based on the interface provider identifier, the time-limited unique request identifier and the back-to-source request signature information; send the back-to-source confirmation request according to the back-to-source address.
[0064] In this embodiment, the interface provider can pre-agree with each interface caller on their respective return-to-source addresses, and make a one-to-one correspondence between their respective return-to-source addresses and their respective interface caller identifiers, thereby forming a return-to-source address library. Thus, after the interface provider obtains the interface caller identifier contained in the interface call request, it can accurately obtain the return-to-source address corresponding to the interface caller identifier from the return-to-source address library, and the formation of the return-to-source address library also facilitates the interface provider to record and manage the return-to-source addresses of each interface caller. In addition, the interface provider also obtains its own identifier, that is, the interface provider identifier, and then the interface provider can sign the interface provider identifier and the time-limited unique request identifier according to the encrypted signature scheme and key pre-agreed with the interface caller to obtain the return-to-source request signature information, thereby obtaining the return-to-source confirmation request containing the interface provider identifier, the time-limited unique request identifier and the return-to-source request signature information, and then the interface provider can send the return-to-source confirmation request to the interface caller according to the return-to-source address for return-to-source confirmation, in order to inquire whether the aforementioned interface call request is issued by it.
[0065] Step S205, when the back-to-source verification pass information is received, the interface call result is returned to the interface call end according to the business parameters.
[0066] In this step, after the interface provider sends a back-to-source confirmation request according to the back-to-source address, if the back-to-source verification information is received from the interface caller, the interface provider can determine that the back-to-source verification is passed, proving that the aforementioned interface call request is legal and issued by the interface caller, so that the interface provider can execute specific interface business logic and return the interface call result to the interface caller according to the business parameters. In some embodiments, if the back-to-source verification information is not received, the interface provider may not respond to the aforementioned interface call request.
[0067] In the interface calling method of this embodiment, the interface provider receives the interface calling request of the interface calling end, obtains the business parameters, interface calling end identifier, time-limited unique request identifier and calling request signature information included therein, verifies the calling request signature information according to the key corresponding to the interface calling end identifier, and when the verification is passed, the interface provider obtains the return-to-source address corresponding to the interface calling end identifier, sends a return-to-source confirmation request according to the return-to-source address, and when the interface provider receives the return-to-source verification pass information, returns the interface calling result to the interface calling end according to the business parameters. The scheme uses signature verification to effectively prevent illegal forged requests, and can support interception of internal and external illegal calls and brute force attacks. In addition to signature verification and authentication, it also combines return-to-source and time-limited expired unique request identifiers to implement verification and authentication, prevent various attacks such as replay attacks and man-in-the-middle attacks, and improve the security of interface calls.
[0068] In one embodiment, after obtaining the service parameters, interface call end identifier, time-limited unique request identifier and call request signature information included in the interface call request in step S202, the following steps may be included:
[0069] According to the interface caller identifier, obtain the interface call permission scope corresponding to the interface caller; according to the interface call permission scope corresponding to the interface caller, determine whether the interface caller has the interface call permission corresponding to the interface call request; if so, execute the steps of obtaining the key corresponding to the interface caller identifier, and verifying the call request signature information according to the key corresponding to the interface caller identifier.
[0070] In this embodiment, after obtaining the interface call end identifier included in the interface call request, the interface provider may first obtain the corresponding interface call permission scope according to the interface call end identifier, that is, on the interface provider, different interface call ends may have different interface call permission scopes accordingly, and the interface provider may make a one-to-one correspondence between each interface call end's respective interface call end identifier and its respective interface call permission scope, thereby, the interface provider may obtain the corresponding interface call permission scope according to the interface call end identifier included in the interface call request, and then the interface provider may determine whether the interface call end has the interface call permission corresponding to the interface call request according to the interface call permission scope. Exemplarily, if the interface call permission corresponding to the interface call request is within its interface call permission scope, the interface provider may determine that it has the interface call permission corresponding to the interface call request, thereby, the interface provider may execute step S203 of obtaining the key corresponding to the interface call end identifier, and verify the call request signature information according to the key corresponding to the interface call end identifier; if the interface provider determines that the interface call end does not have the interface call permission corresponding to the interface call request, the interface provider may not respond to the interface call request. The solution of this embodiment can facilitate the flexible setting of the interface calling authority range corresponding to the interface calling end at the interface providing end according to actual needs, and can perform authority judgment before the verifier signs its information, thereby improving the security of interface calling.
[0071] In one embodiment, obtaining the key corresponding to the interface caller identifier in step S203 and verifying the call request signature information according to the key corresponding to the interface caller identifier may include:
[0072] Obtain a preset key library pre-agreed with each interface caller; obtain the key corresponding to the interface caller identifier from the preset key library according to the interface caller identifier included in the interface call request; verify the call request signature information according to the key corresponding to the interface caller identifier.
[0073] In this embodiment, the interface provider can pre-agree with each interface caller on their respective keys and encryption signature schemes, and make one-to-one correspondence between their respective keys and encryption signature schemes and their respective interface caller identifiers to form a preset key library. Thus, after the interface provider obtains the interface caller identifier contained in the interface call request, it can obtain the key and encryption signature scheme corresponding to the interface caller identifier from the preset key library according to the interface caller identifier, and then verify the call request signature information according to the key and encryption signature scheme. The scheme of this embodiment enables the interface provider to obtain the interface caller identifier contained in the interface call request, and accurately obtain the key and encryption signature scheme corresponding to the interface caller identifier from the preset key library and other information to verify the call request signature information, and the formation of the preset key library facilitates the interface provider to record and manage the key and encryption signature scheme and other related information of each interface caller.
[0074] In one embodiment, Figure 3 As shown, an interface calling method is provided, which can be applied to Figure 1 The interface calling end in the method may include the following steps:
[0075] Step S301, obtaining an interface call request according to business parameters, an interface call end identifier, a time-limited unique request identifier and a call request signature information.
[0076] In this step, when the interface caller needs to request an interface service from the interface provider, it can obtain an interface call request containing the business parameters, interface caller identifier, time-limited unique request identifier and call request signature information according to the business parameters, interface caller identifier, time-limited unique request identifier and call request signature information for this request. Specifically, the interface caller can sign the business parameters, interface caller identifier and time-limited unique request identifier to obtain the call request signature information, and can use symmetric encryption such as MD5, SHA1, AES or asymmetric encryption signature schemes such as RSA. The encryption signature scheme and key used by the interface caller can be pre-agreed with the interface provider so that when the interface provider receives the request, it can verify the call request signature information according to the pre-agreed encryption signature scheme and key.
[0077] Step S302: Send an interface call request to the interface provider.
[0078] In this step, after receiving the interface call request, the interface calling end sends the interface call request to the interface providing end, so that the interface providing end can perform relevant processing to verify the call request signature information in the interface call request. The processing performed by the interface providing end can refer to the relevant description in the embodiment of the interface calling method applied to the interface providing end.
[0079] Step S303: Receive a back-to-source confirmation request from the interface provider, and obtain the interface provider identifier, a time-limited unique request identifier, and back-to-source request signature information included in the back-to-source confirmation request.
[0080] In this step, when the interface provider passes the verification of the call request signature information, it can send a back-to-source confirmation request according to the back-to-source address corresponding to the interface caller identifier, and the interface caller can receive the back-to-source confirmation request. The back-to-source confirmation request includes the interface provider identifier, the time-limited unique request identifier, and the back-to-source request signature information. The back-to-source request signature information can be obtained by the interface provider according to the encrypted signature scheme and key pre-agreed with the interface caller to sign the interface provider identifier and the time-limited unique request identifier. Thus, the interface provider can send the back-to-source confirmation request containing the interface provider identifier, the time-limited unique request identifier, and the back-to-source request signature information to the receiving interface caller according to the back-to-source address. As a result, the interface caller receives the back-to-source confirmation request and obtains the interface provider identifier, the time-limited unique request identifier, and the back-to-source request signature information from it.
[0081] Step S304: When it is determined that the received time-limited unique request identifier meets the time limit condition, a key corresponding to the interface provider identifier is obtained, and the back-to-source request signature information is verified according to the key corresponding to the interface provider identifier.
[0082] In this step, the interface calling end can first determine whether the received time-limited unique request identifier meets the time limit condition. For example, if the time limit for the interface calling end to generate the time-limited unique request identifier expires in one minute, the interface calling end can first determine whether the received time-limited unique request identifier exceeds one minute. If so, it is determined that the time limit condition is not met. At this time, a back-to-source verification failure message can be sent to the interface providing end. If the received time-limited unique request identifier meets the time limit condition, the interface calling end can obtain the key and encryption signature scheme pre-determined with the interface providing end according to the interface providing end identifier, and then verify the back-to-source request signature information according to the key and encryption signature scheme.
[0083] Step S305: When the verification of the back-to-source request signature information is passed, back-to-source verification pass information is sent to the interface provider.
[0084] Specifically, when the interface calling end passes the verification of the back-to-source request signature information, the interface calling end can send back-to-source verification pass information to the interface providing end; when the interface calling end fails the verification of the back-to-source request signature information, the interface calling end can send back-to-source verification fail information to the interface providing end.
[0085] Step S306: receiving the interface call result returned by the interface provider.
[0086] Specifically, if the interface provider receives back-to-source verification pass information from the interface caller, the interface provider can determine that the back-to-source verification is passed, proving that the aforementioned interface call request is legal and issued by the interface caller, so that the interface provider can execute specific interface business logic and return the interface call result to the interface caller according to the business parameters. The interface caller can then receive the interface call result returned by the interface provider.
[0087] The interface calling method of this embodiment uses signature verification to effectively prevent illegal forged requests, and can support intercepting internal and external illegal calls and brute force attacks. In addition to signature verification and authentication, it also combines return to the source and a unique request identifier with a time limit to implement verification and authentication, prevent various attacks such as replay attacks and man-in-the-middle attacks, and improve the security of interface calls.
[0088] In one embodiment, obtaining the interface call request according to the business parameters, the interface call end identifier, the time-limited unique request identifier and the call request signature information in step S301 specifically includes:
[0089] Generate a time-limited unique request identifier with a certain time limit condition; obtain business parameters and interface call end identifier; sign the business parameters, time-limited unique request identifier and interface call end identifier to obtain call request signature information; obtain the interface call request based on the business parameters, interface call end identifier, time-limited unique request identifier and call request signature information.
[0090] In this embodiment, the interface calling end can generate a time-limited unique request identifier with a certain time limit condition for this request when it needs to request an interface service from the interface providing end. Specifically, the time-limited unique request identifier can be randomly generated in combination with a certain time limit condition by using UUID, timestamp or participating in a cryptographic signature string, such as randomly generating a time-limited unique request identifier that expires in one minute based on UUID. In addition, the business parameters and the interface calling end identifier are obtained, and then the business parameters, the time-limited unique request identifier and the interface calling end identifier are signed according to the encrypted signature method and key pre-agreed with the interface providing end to obtain the call request signature information. The interface calling end can thereby obtain the interface call request containing the business parameters, the interface calling end identifier, the time-limited unique request identifier and the call request signature information.
[0091] Further, in one embodiment, the generation of a time-limited unique request identifier with a certain time limit condition in the above embodiment may include:
[0092] Obtain the requested interface call level; obtain the time limit condition corresponding to the interface call level from among the preset multiple time limit conditions; generate a time-limited unique request identifier having the time limit condition corresponding to the interface call level.
[0093] In this embodiment, the interface call end can set a time limit condition in combination with the security level of the requested interface call, and further improve the security of the interface call in combination with business needs. Specifically, different interface call requests may have different interface call levels, and the interface call end sets corresponding time limit conditions according to these interface call levels, such as the higher the interface call level, the stricter the corresponding time limit conditions, etc., thereby forming a time limit condition corresponding to each interface call level, that is, a preset multiple time limit conditions. Based on this, after the interface call end obtains the interface call level of the interface call requested this time, it can obtain the time limit condition corresponding to the interface call level from the preset multiple time limit conditions according to the interface call level, thereby generating a time-limited unique request identifier with the time limit condition, such as the interface call end can generate a time-limited unique request identifier with a time limit condition such as 30 seconds or 1 minute according to the level, so as to achieve the effect of accurately configuring the security of its interface call in combination with business needs.
[0094] Combination Figure 4 In the specific example shown, the interface calling method of the present application may include as a whole: the interface provider and the interface caller may pre-agree on the encryption signature method, key, identifier, and return source address, etc. Based on this, the interface caller may generate a time-limited unique request identifier with a certain time limit condition, and obtain the business parameters and the interface caller identifier, and then sign the business parameters, the time-limited unique request identifier and the interface caller identifier to obtain the call request signature information, and then the interface caller obtains the interface call request containing the business parameters, the time-limited unique request identifier, the interface caller identifier and the call request signature information, and then sends the interface call request to the interface provider. The interface provider may verify the call request signature information according to the pre-determined encryption signature method and key, and after the verification is passed, sign the interface provider identifier and the time-limited unique request identifier according to the pre-determined encryption signature method and key to obtain the return request signature information, and then the interface provider obtains the return confirmation request containing the interface provider identifier, the time-limited unique request identifier and the return request signature information, and then sends the return confirmation request to the interface caller according to the pre-determined return address to inquire whether the aforementioned interface call request is issued by it. After the interface calling end receives the back-to-source confirmation request, it can verify the back-to-source request signature information according to the pre-agreed encryption signature method and key if the received time-limited unique request identifier meets the time limit condition. After the verification passes, the time-limited unique request identifier can be deleted, and the back-to-source verification pass information can be sent to the interface providing end. When the interface providing end receives the back-to-source verification pass information, it determines that the aforementioned interface call request is legal and issued by the interface calling end, and can execute specific interface business logic processing, and return the interface call result to the interface calling end according to the business parameters.
[0095] The solution of the embodiment of the present application applies signature verification, which can effectively prevent illegal forged requests, support interception of internal and external illegal calls and brute force attacks, and on this basis, combined with the return to source and the unique request identification method with a time limit, it can prevent replay attacks, man-in-the-middle attacks and other attacks, and can intercept illegal calls even in the case of key leakage, thereby improving security and maintainability, reducing system complexity and the cost of changing keys. In practical applications, the solution of this embodiment can be used as a high-security application interface to call SDK, which can facilitate integration between systems, thereby improving system security and maintainability, reducing system complexity and the cost of changing keys.
[0096] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0097] Based on the same inventive concept, the embodiment of the present application also provides an interface calling device for implementing the interface calling method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more interface calling device embodiments provided below can refer to the limitations on the interface calling method above, and will not be repeated here.
[0098] In one embodiment, Figure 5 As shown, an interface calling device is provided, which can be applied to an interface providing end. The device 500 may include:
[0099] A call request receiving module 501 is used to receive an interface call request from an interface call end;
[0100] The calling information acquisition module 502 is used to obtain the service parameters, interface calling terminal identifier, time-limited unique request identifier and calling request signature information included in the interface calling request;
[0101] A call request verification module 503 is used to obtain a key corresponding to the interface call end identifier, and verify the call request signature information according to the key corresponding to the interface call end identifier;
[0102] The back-to-source request sending module 504 is used to obtain the back-to-source address corresponding to the interface calling end identifier when the verification of the call request signature information is passed, and send a back-to-source confirmation request according to the back-to-source address; the back-to-source confirmation request includes the interface providing end identifier, the time-limited unique request identifier and the back-to-source request signature information;
[0103] The call result returning module 505 is used to return the interface call result to the interface call end according to the business parameters when receiving the back-to-source verification pass information.
[0104] In one embodiment, the device 500 may also include: an interface authority processing module, which is used to obtain the interface call authority range corresponding to the interface call end according to the interface call end identifier; based on the interface call authority range corresponding to the interface call end, determine whether the interface call end has the interface call authority corresponding to the interface call request; if so, execute the steps of obtaining the key corresponding to the interface call end identifier, and verifying the call request signature information according to the key corresponding to the interface call end identifier.
[0105] In one embodiment, the call request verification module 503 is used to obtain a preset key library pre-agreed with each interface caller; obtain the key corresponding to the interface caller identifier included in the interface call request from the preset key library; and verify the call request signature information according to the key corresponding to the interface caller identifier.
[0106] In one embodiment, the back-to-source request sending module 504 is used to obtain a back-to-source address library pre-agreed with each interface calling end; obtain the back-to-source address corresponding to the interface calling end identifier included in the interface calling request from the back-to-source address library; obtain the interface provider identifier; sign the interface provider identifier and the time-limited unique request identifier to obtain the back-to-source request signature information; obtain the back-to-source confirmation request according to the interface provider identifier, the time-limited unique request identifier and the back-to-source request signature information; and send the back-to-source confirmation request according to the back-to-source address.
[0107] In one embodiment, Figure 6 As shown, an interface calling device is provided, which can be applied to an interface calling end. The device 600 may include:
[0108] The calling request obtaining module 601 is used to obtain the interface calling request according to the business parameters, the interface calling terminal identifier, the time-limited unique request identifier and the calling request signature information;
[0109] A call request sending module 602 is used to send the interface call request to the interface provider;
[0110] The back-to-source request receiving module 603 is used to receive the back-to-source confirmation request from the interface provider, and obtain the interface provider identifier, the time-limited unique request identifier, and the back-to-source request signature information included in the back-to-source confirmation request;
[0111] The back-to-source request verification module 604 is used to obtain the key corresponding to the interface provider identifier when determining that the received time-limited unique request identifier meets the time limit condition, and verify the back-to-source request signature information according to the key corresponding to the interface provider identifier;
[0112] The verification information sending module 605 is used to send the back-to-source verification passing information to the interface provider when the verification of the back-to-source request signature information is passed;
[0113] The call result receiving module 606 is used to receive the interface call result returned by the interface provider.
[0114] In one embodiment, the calling request obtains module 601, which is used to generate a time-limited unique request identifier with a certain time limit condition; obtain business parameters and an interface calling end identifier; sign the business parameters, the time-limited unique request identifier and the interface calling end identifier to obtain the calling request signature information; obtain the interface calling request based on the business parameters, the interface calling end identifier, the time-limited unique request identifier and the calling request signature information.
[0115] In one embodiment, the calling request obtaining module 601 is used to obtain the requested interface calling level; obtain the time limit condition corresponding to the interface calling level among the preset multiple time limit conditions; and generate a time-limited unique request identifier having the time limit condition corresponding to the interface calling level.
[0116] Each module in the above interface calling device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0117] In one embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 7As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as identification, keys, and return source addresses. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an interface calling method is implemented.
[0118] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0119] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0120] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0121] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0123] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0124] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An interface calling method, It is characterized in that Applied to the interface provider, the method includes: Receive an interface call request from an interface call end; Obtaining the service parameters, interface calling terminal identifier, time-limited unique request identifier and calling request signature information included in the interface calling request; Obtaining a key corresponding to the interface calling end identifier, and verifying the calling request signature information according to the key corresponding to the interface calling end identifier; When the verification of the call request signature information is passed, the return-to-source address corresponding to the interface call end identifier is obtained, and a return-to-source confirmation request is sent according to the return-to-source address; the return-to-source confirmation request includes the interface provider identifier, the time-limited unique request identifier and the return-to-source request signature information; the return-to-source address is pre-agreed by the interface provider and the interface call end; When the back-to-source verification pass information is received, the interface call result is returned to the interface call end according to the business parameters.
2. The method according to claim 1, It is characterized in that After obtaining the service parameters, interface call end identifier, time-limited unique request identifier and call request signature information included in the interface call request, the method further includes: According to the interface calling end identifier, obtaining the interface calling authority scope corresponding to the interface calling end; According to the interface calling authority range corresponding to the interface calling end, judging whether the interface calling end has the interface calling authority corresponding to the interface calling request; If so, execute the step of obtaining the key corresponding to the interface calling end identifier and verifying the calling request signature information according to the key corresponding to the interface calling end identifier.
3. The method according to claim 1, It is characterized in that The obtaining of the key corresponding to the interface calling end identifier and verifying the calling request signature information according to the key corresponding to the interface calling end identifier includes: Obtain the preset key library agreed upon in advance with each interface caller; According to the interface calling end identifier included in the interface calling request, obtaining a key corresponding to the interface calling end identifier from the preset key library; The calling request signature information is verified according to the key corresponding to the interface calling end identifier.
4. The method according to any one of claims 1 to 3, It is characterized in that The obtaining the return-to-source address corresponding to the interface calling end identifier, and sending the return-to-source confirmation request according to the return-to-source address, includes: Obtain the back-to-source address library pre-agreed with each interface caller; According to the interface calling end identifier included in the interface calling request, obtaining the back-to-source address corresponding to the interface calling end identifier from the back-to-source address library; Get the interface provider ID; Sign the interface provider identifier and the time-limited unique request identifier to obtain the back-to-source request signature information; Obtain a back-to-source confirmation request according to the interface providing terminal identifier, the time-limited unique request identifier, and the back-to-source request signature information; The back-to-source confirmation request is sent according to the back-to-source address.
5. An interface calling method, It is characterized in that Applied to the interface calling end, the method includes: Obtain an interface call request based on business parameters, interface call end identifier, time-limited unique request identifier, and call request signature information; Sending the interface call request to the interface provider; Receive a return-to-source confirmation request from the interface provider, and obtain the interface provider identifier, a time-limited unique request identifier, and return-to-source request signature information included in the return-to-source confirmation request; the interface provider sends the return-to-source confirmation request according to the return-to-source address corresponding to the interface caller identifier; the return-to-source address is pre-agreed by the interface provider and the interface caller; When it is determined that the received time-limited unique request identifier meets the time limit condition, obtaining a key corresponding to the interface provider identifier, and verifying the back-to-source request signature information according to the key corresponding to the interface provider identifier; When the verification of the signature information of the back-to-source request is passed, sending back-to-source verification passing information to the interface provider; Receive the interface call result returned by the interface provider.
6. The method according to claim 5, It is characterized in that The interface call request is obtained according to the business parameters, the interface call end identifier, the time-limited unique request identifier and the call request signature information, including: Generate a time-limited unique request identifier with certain time limit conditions; Get business parameters and interface call end identifier; Sign the service parameters, the time-limited unique request identifier and the interface calling end identifier to obtain the calling request signature information; An interface call request is obtained according to the business parameters, the interface call end identifier, the time-limited unique request identifier and the call request signature information.
7. The method according to claim 6, It is characterized in that The generating of a time-limited unique request identifier with a certain time limit condition includes: Get the requested interface call level; Obtaining the time limit condition corresponding to the interface call level in the preset multiple time limit conditions; A time-limited unique request identifier having a time limit condition corresponding to the interface call level is generated.
8. An interface calling device, It is characterized in that Applied to an interface provider, the device comprises: A call request receiving module, used for receiving an interface call request from an interface call end; A call information acquisition module, used to obtain the service parameters, interface call end identifier, time-limited unique request identifier and call request signature information included in the interface call request; A call request verification module, used to obtain the key corresponding to the interface call end identifier, and verify the call request signature information according to the key corresponding to the interface call end identifier; A back-to-source request sending module is used to obtain the back-to-source address corresponding to the interface calling end identifier when the verification of the call request signature information is passed, and send a back-to-source confirmation request according to the back-to-source address; the back-to-source confirmation request includes the interface providing end identifier, the time-limited unique request identifier and the back-to-source request signature information; the back-to-source address is pre-agreed by the interface providing end and the interface calling end; The call result returning module is used to return the interface call result to the interface calling end according to the business parameters when receiving the back-to-source verification pass information.
9. An interface calling device, It is characterized in that Applied to the interface calling end, the device comprises: A call request obtaining module is used to obtain an interface call request according to business parameters, an interface call end identifier, a time-limited unique request identifier, and a call request signature information; A call request sending module, used to send the interface call request to the interface provider; A back-to-source request receiving module is used to receive a back-to-source confirmation request from the interface provider, and obtain the interface provider identifier, a time-limited unique request identifier, and back-to-source request signature information included in the back-to-source confirmation request; the interface provider sends the back-to-source confirmation request according to the back-to-source address corresponding to the interface caller identifier; the back-to-source address is pre-agreed by the interface provider and the interface caller; A back-to-source request verification module, used to obtain a key corresponding to the interface provider identifier when determining that the received time-limited unique request identifier meets a time limit condition, and verify the back-to-source request signature information according to the key corresponding to the interface provider identifier; A verification information sending module, used for sending back-to-source verification passing information to the interface providing end when the verification of the back-to-source request signature information is passed; The call result receiving module is used to receive the interface call result returned by the interface provider.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
User identity identifying method and device
CN105812341A
Interface calling method and apparatus
CN107135073A
Interface calling method, terminal equipment, interface calling response method and server
CN108365961A
Interface program calling method and device, equipment and storage medium
CN110851210A
Interface calling method, device and equipment and computer readable storage medium
CN113609520A
