Micro-service calling method, electronic device and computer readable storage medium
By working together with the authentication and configuration modules, the key information in the call command is parsed and authenticated, and the service key of the target microservice is generated and used, which solves the security problem in the microservice call process and achieves higher security and stability.
Patent Information
- Application Number
- CN202311114708.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-08-30
AI Technical Summary
In a microservice architecture, how can we improve the security of the microservice call process and prevent risks exposed during calls from multiple or even all microservices?
By working together with the authentication and configuration modules, the key information and access path in the call command are parsed, authentication is performed, a scheduling request is generated, the service key of the target microservice is obtained, and the call request is generated using the key. This ensures that only the key of the target microservice is exposed, reducing the probability that the authentication module will leak the keys of all microservices.
It improves the security of microservice call processes, prevents interference between different call platforms, reduces the risk of microservice key leakage, and enhances the stability and security of the call process.
Smart Images

Figure CN117318997B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network security technology, and in particular to a microservice invocation method, an electronic device, and a computer-readable storage medium. Background Technology
[0002] Microservice architecture is an architectural approach for building applications. Compared to traditional monolithic architecture, microservice architecture breaks down the system into multiple microservices, each of which can run independently. However, in today's increasingly severe cybersecurity environment, even if microservices can run independently, there is still a risk that multiple or even all microservices may be exposed when calling them. Therefore, improving the security of microservice calls has become an urgent problem to be solved. Summary of the Invention
[0003] The main technical problem addressed by this application is to provide a microservice invocation method, electronic device, and computer-readable storage medium that can improve the security of microservice invocation.
[0004] To address the aforementioned technical problems, this application provides a microservice invocation method, applied to an invocation system including an authentication module and a configuration module. The method includes: obtaining an invocation instruction sent by an invocation platform; parsing key information and an access path from the invocation instruction; authenticating the key information; and sending a scheduling request to the configuration module after successful authentication. The invocation platform pre-configures access permissions for at least one of multiple microservices, each microservice having its own service key. The key information is associated with the service keys of the microservices configured on the invocation platform, and the configuration module stores the association. The method also includes obtaining the service key of a target microservice fed back by the configuration module in response to the scheduling request; generating an invocation request based on the service key of the target microservice; the target microservice being the microservice indicated by the access path; and invoking the target microservice using the invocation request.
[0005] To address the aforementioned technical problems, a second aspect of this application provides a microservice invocation method applied to an invocation system including an authentication module and a configuration module. The method includes: responding to an invocation platform sending an invocation instruction to the authentication module, whereby the authentication module parses key information and an access path from the invocation instruction, authenticates the key information, and upon successful authentication, obtains a scheduling request issued by the authentication module; wherein the invocation platform pre-configures access permissions for at least one of multiple microservices, each microservice has its own service key, the key information is associated with the service keys of the microservices configured on the invocation platform, and the configuration module stores the association; based on the association and the access path, obtains the service key of a target microservice, and feeds back the service key of the target microservice to the authentication module, so that the authentication module generates an invocation request based on the service key of the target microservice, and uses the invocation request to invoke the target microservice; wherein the target microservice is the microservice indicated by the access path.
[0006] To address the aforementioned technical problems, a third aspect of this application provides an electronic device comprising: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor invokes the program data to execute the method described in the first or second aspect.
[0007] To address the aforementioned technical problems, a fourth aspect of this application provides a computer-readable storage medium storing program data thereon, wherein the program data, when executed by a processor, implements the method described in the first or second aspect.
[0008] The above scheme obtains the invocation command sent by the invocation platform, parses the invocation command to obtain the key information and access path included in the invocation command, authenticates the key information, and sends a scheduling request to the configuration module after successful authentication. Here, the invocation platform is pre-configured with access permissions for at least one of multiple microservices. Having the corresponding microservice access permission means having the access path of that microservice. Each microservice has its own service key so that when any microservice is invoked, the microservice can verify the service key. The key information of the invocation platform is associated with the service keys of the microservices configured on the invocation platform, and the association is stored in the configuration module so that the configuration module can accurately respond to the invocation request. The scheme obtains the service key of the target microservice indicated by the access path returned by the configuration module after responding to the scheduling request, generates an invocation request using the service key of the target microservice, and sends the invocation request to the target microservice so that the target microservice responds to the invocation request and completes the invocation. Therefore, when calling a target microservice from a different platform, the platforms do not interfere with each other. After the authentication module authenticates the key information, the configuration module returns the service key of the target microservice. Thus, the authentication module only receives the service key of the target microservice, thereby reducing the probability of the authentication module leaking the service keys of all microservices. Furthermore, after the call request is sent to the target microservice, the target microservice can also verify the service key, thereby improving the security of calling the microservice. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0010] Figure 1 This is a flowchart illustrating one implementation method of the microservice invocation method in this application;
[0011] Figure 2 This is a flowchart illustrating another implementation of the microservice invocation method of this application;
[0012] Figure 3 This is a schematic diagram illustrating an application scenario of one implementation method of the microservice invocation method in this application;
[0013] Figure 4 This is a flowchart illustrating another implementation of the microservice invocation method in this application;
[0014] Figure 5 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;
[0015] Figure 6This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0016] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0017] In this paper, the terms "system" and "network" are often used interchangeably. The term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this paper means two or more.
[0018] The microservice invocation method provided in this application is applied to an invocation system that includes an authentication module and a configuration module. The entire invocation process involves information interaction between multiple terminals to complete the invocation of microservices.
[0019] Please see Figure 1 , Figure 1 This is a flowchart illustrating one implementation method of the microservice invocation method of this application, where the corresponding terminal is the authentication module. The method includes:
[0020] S101: Obtain the call instruction sent by the calling platform, parse the key information and access path from the call instruction, authenticate the key information, and send a scheduling request to the configuration module after successful authentication. The calling platform has pre-configured access permissions for at least one of the multiple microservices. Each microservice has its own service key. The key information is associated with the service keys of the microservices configured by the calling platform, and the configuration module stores the association.
[0021] Specifically, the system obtains the invocation command sent by the platform, parses the invocation command to obtain the key information and access path included in the invocation command, authenticates the key information, and sends a scheduling request to the configuration module after successful authentication.
[0022] It should be noted that the calling platform pre-configures access permissions for at least one of the multiple microservices. Having access permissions for a given microservice means having access to that microservice's path. Each microservice has its own service key, allowing it to verify the key when any microservice is invoked. Different calling platforms correspond to their respective pre-configured access permissions for the microservices; the pre-configured microservices of two calling platforms may or may not overlap.
[0023] Furthermore, the key information of the calling platform is associated with the service key of the microservice configured on the calling platform, and the association is stored in the configuration module so that the configuration module can accurately respond to the call request. After receiving the call request, the configuration module can obtain the service key of the target microservice indicated by the access path based on the association and the access path.
[0024] It should be noted that regardless of the number of microservices with access permissions pre-configured on the calling platform, the authentication module can perform unified authentication on the key information. The association relationship is stored on the configuration module. When the configuration module obtains the key information, it can determine the microservices with access permissions on the calling platform. After the service key of a microservice is updated, only the association relationship needs to be modified. There is no need to modify the key information. Therefore, the update of the service key does not affect the use of the key information, and the calling platform will not be aware of the change in the service key of the microservice.
[0025] Understandably, the authentication module is usually set up on the gateway, which is responsible for uniformly receiving the calling instructions from the calling platform, parsing the calling instructions to obtain the key information and access path included in the calling instructions, authenticating the key information, and generating a scheduling request after successful authentication, which is then forwarded to the configuration module. The configuration module can be set up independently of the gateway, reducing the risk of information leakage due to gateway exposure.
[0026] In one application mode, a call instruction sent by the calling platform is obtained. The calling platform selects the access path of the microservice to be called according to the access permissions. The calling platform encodes the characters of the key information and the access path to generate the call instruction. The authentication module decodes the call instruction according to the character decoding rules, thereby parsing out the key information and access path included in the call instruction. The key information is authenticated, and after the authentication is successful, a scheduling request is generated and sent to the configuration module.
[0027] In another application method, the calling platform sends a calling instruction. The calling platform selects the access path of the microservice to be called according to the access permissions. The calling platform uses a preset encryption algorithm to encrypt the key information and access path. The authentication module uses a preset decryption algorithm that matches the preset encryption algorithm to decrypt the calling instruction, thereby parsing out the key information and access path included in the calling instruction. The key information is authenticated, and after the authentication is successful, a scheduling request is generated and sent to the configuration module.
[0028] It is understandable that there is an association between the key information and the service keys of the microservices configured on the calling platform, including the association between the calling platform corresponding to the key information and all pre-configured microservices. When the calling platform calls a microservice, it can select some or all of the microservices with access permissions, that is, select at least one microservice with access permissions, and determine the access path selected for this call.
[0029] S102: Obtain the service key of the target microservice in response to the scheduling request from the configuration module, and generate a call request based on the service key of the target microservice, where the target microservice is the microservice indicated by the access path.
[0030] Specifically, the service key of the target microservice indicated by the access path returned by the configuration module after responding to the scheduling request is obtained, and the service key of the target microservice is used to generate a call request.
[0031] It should be noted that after receiving the call request, the configuration module responds to the call request by providing the service key of the target microservice indicated by the access path. This process will be explained in detail in a later section.
[0032] In one application approach, the service key of the target microservice is obtained from the configuration module, and a call request carrying the service key of the target microservice is generated using the service key of the target microservice.
[0033] In another application approach, the service key of the target microservice fed back by the configuration module is obtained. An XOR operation is performed between the encrypted string and the service key of the target microservice to obtain the encrypted service key. A call request carrying the encrypted service key is then generated, thereby reducing the probability of the service key of the target microservice being leaked during transmission.
[0034] S103: Invoke the target microservice using an invocation request.
[0035] Specifically, a call request is sent to the target microservice, and the target microservice completes the call after responding to the call request. Therefore, when the calling platform calls the target microservice, different calling platforms do not interfere with each other. After the authentication module authenticates the key information, the configuration module returns the service key of the target microservice. Thus, the authentication module will only receive the service key of the target microservice, thereby reducing the probability of the authentication module leaking the service keys of all microservices.
[0036] Understandably, when a call request carries the service key of the target microservice, the target microservice can determine the confidence level of the call request, and the target microservice can also verify the service key after the call request is given to it.
[0037] In one application approach, the service key of the microservice is stored on the microservice. The call request is sent to the target microservice so that the target microservice can obtain the service key set on the target microservice for authentication and respond to the call request after successful authentication.
[0038] In another application, the service key of the microservice is stored in the configuration module. The call request is sent to the target microservice so that the target microservice can obtain the set service key from the configuration module for authentication and respond to the call request after successful authentication.
[0039] It is understood that in some implementation scenarios, the key information and service key specifically correspond to account information (Access Key, AK) and its corresponding account password (Secret Key, SK). Of course, in other implementation scenarios, the key information and service key can also be in other specific forms, and this application does not impose any specific restrictions on this.
[0040] The above scheme obtains the invocation command sent by the invocation platform, parses the invocation command to obtain the key information and access path included in the invocation command, authenticates the key information, and sends a scheduling request to the configuration module after successful authentication. Here, the invocation platform is pre-configured with access permissions for at least one of multiple microservices. Having the corresponding microservice access permission means having the access path of that microservice. Each microservice has its own service key so that when any microservice is invoked, the microservice can verify the service key. The key information of the invocation platform is associated with the service keys of the microservices configured on the invocation platform, and the association is stored in the configuration module so that the configuration module can accurately respond to the invocation request. The scheme obtains the service key of the target microservice indicated by the access path returned by the configuration module after responding to the scheduling request, generates an invocation request using the service key of the target microservice, and sends the invocation request to the target microservice so that the target microservice responds to the invocation request and completes the invocation. Therefore, when calling a target microservice from a different platform, the platforms do not interfere with each other. After the authentication module authenticates the key information, the configuration module returns the service key of the target microservice. Thus, the authentication module only receives the service key of the target microservice, thereby reducing the probability of the authentication module leaking the service keys of all microservices. Furthermore, after the call request is sent to the target microservice, the target microservice can also verify the service key, thereby improving the security of calling the microservice.
[0041] Please see Figure 2 , Figure 2 This is a flowchart illustrating another implementation of the microservice invocation method of this application. The corresponding terminal is the authentication module, and the invocation system also includes an internal scheduling module. The internal scheduling module includes an internal whitelist and a token bucket. The method includes:
[0042] S201: Obtain the call instruction sent by the calling platform, parse the key information and access path from the call instruction, authenticate the key information, and send a scheduling request to the configuration module after successful authentication. The calling platform has pre-configured access permissions for at least one of the multiple microservices. Each microservice has its own service key. The key information is associated with the service keys of the microservices configured by the calling platform, and the configuration module stores the association.
[0043] Specifically, Figure 3 This is a schematic diagram of an application scenario for one implementation method of the microservice invocation method of this application. The invocation platform sends an invocation instruction to the authentication module. The authentication module obtains the invocation instruction, parses the invocation instruction, and obtains the key information of the invocation platform and the access paths of all microservices that the invocation platform needs to invoke this time.
[0044] Furthermore, a scheduling request is generated based on the key information and access path, and the scheduling request is sent to the configuration module.
[0045] In one implementation scenario, a scheduling request carrying the key information and access path is generated using the key information and access path.
[0046] In another implementation scenario, scheduling information is generated and the key information and access path are encrypted. Using the scheduling information, the encrypted key information, and the access path, a scheduling request is generated.
[0047] It should be noted that the calling platform is pre-configured with access permissions for at least one of the multiple microservices. Having access permissions for the corresponding microservice means having access to that microservice. Each microservice has its own service key, so that when any microservice is called, the microservice can verify the service key. The key information of the calling platform is associated with the service keys of the microservices configured on the calling platform, and the association is stored in the configuration module so that the configuration module can accurately respond to the call request.
[0048] S202: Obtain the service key of the target microservice in response to the scheduling request from the configuration module, and generate a call request based on the service key of the target microservice, where the target microservice is the microservice indicated by the access path.
[0049] Specifically, the configuration module includes a storage unit that stores the service key of the latest version of each microservice. When the configuration module receives a scheduling request, it can retrieve the service key of the target microservice indicated by the access path from the storage unit based on the association and access path.
[0050] In one implementation scenario, the process of obtaining the service key of the target microservice fed back by the configuration module in response to the scheduling request, and generating a call request based on the service key of the target microservice, includes: obtaining the service key of the target microservice in the storage unit fed back by the configuration module in response to the scheduling request, and using it as the target service key; and generating a call request carrying the target service key based on the target service key.
[0051] Specifically, please refer to [the relevant document] again. Figure 3 The system retrieves the service key of the target microservice from the storage unit of the configuration module after the configuration module responds to the scheduling request. This ensures that the service key of the target microservice is the latest version at the time of feedback. The system then uses the service key fed back by the configuration module as the target service key and generates a call request carrying the target service key. This allows the target microservice to determine whether the call request is trustworthy based on whether it carries the target service key.
[0052] S203: Invoke the target microservice using the invocation request.
[0053] Specifically, the configuration module also includes a cache unit, which stores the service key of the previous version of the microservice whose service key has been modified. In other words, when the service key of any microservice is updated, the previous version will be temporarily stored in the cache unit.
[0054] In one implementation scenario, a call request is used to invoke a target microservice, including: sending a call request to the target microservice based on the access path, so that the target microservice can obtain the service secrets in the storage unit and cache unit for authentication, and respond to the call request after successful authentication.
[0055] Specifically, please refer to [the relevant document] again. Figure 3 It sends a call request to the target microservice according to the access path, thereby accurately sending the call request to the corresponding target microservice.
[0056] It is understandable that when the platform calls multiple microservices with access permissions, there are multiple access paths and target microservices indicated by each access path. Each target microservice generates a call request, and the call requests are sent according to the correspondence between the access path and the target microservice.
[0057] Furthermore, when the target microservice receives the call request, it retrieves both the new and old versions of the service key from the storage unit and the cache unit for authentication. The call request is only affected after either version of the service key passes authentication. This reduces the probability that the call request will not be responded to because the service key of the target microservice has been modified before the call request has been responded to, thereby improving the stability of the entire call process.
[0058] S204: In response to the target microservice including internal call requests, obtain the internal whitelist from the internal scheduling module.
[0059] Specifically, when the target microservice includes internal call requirements, an internal whitelist is obtained from the internal scheduling module. Internal call requirements indicate that the target microservice needs to call other microservices to obtain complete information. The internal whitelist pre-sets the microservices with internal call requirements, thereby reducing the probability of errors in inter-microservice calls. If the target microservice is not on the internal whitelist, its internal call requirements are prohibited.
[0060] Furthermore, when the target microservice is in the internal whitelist, it is determined whether the token bucket contains the target token required by the target microservice. If it does not contain it, proceed to step S205; if it does contain it, proceed to step S206.
[0061] S205: In response to the target microservice being in the internal whitelist and the token bucket not containing the target token required by the target microservice, generate the target token required by the target microservice and store the target token in the token bucket.
[0062] Specifically, when the target microservice is in the internal whitelist and the token bucket does not contain the target token required by the target microservice, the target token required by the target microservice is generated and stored in the token bucket so that it can be directly called later, thereby improving the calling efficiency.
[0063] Optionally, please refer to [the relevant document / reference]. Figure 3 Before generating the target token required by the target microservice and storing it in the token bucket, the internal call request carries the current service key of the target microservice.
[0064] Specifically, the internal call request carries the service key of the latest version of the target microservice. Before generating the target token, the service key carried by the internal call request is authenticated. Only after the authentication is successful will the target token required by the target microservice be generated, thereby improving the security of the internal call.
[0065] S206: In response to the target microservice being in the internal whitelist and the token bucket containing the target token required by the target microservice, obtain the target token from the token bucket.
[0066] Specifically, when the target microservice is in the internal whitelist and the token bucket contains the target token required by the target microservice, the target token required by the target microservice can be obtained from the token bucket.
[0067] S207: Send the target token to the target microservice so that the target microservice can use the target token to call the microservice corresponding to the internal call request.
[0068] Specifically, please refer to [the relevant document] again. Figure 3 The target token is sent to the target microservice, enabling the target microservice to use the token to invoke the microservice corresponding to the internal call request. The microservice corresponding to the internal call request verifies the target token and responds to the internal call request. Therefore, by implementing calls between microservices through an internal scheduling module, scheduling between microservices does not require them to obtain each other's service keys, effectively avoiding the sharing of service keys between microservices and reducing the probability of multiple microservice service keys being leaked from the microservice side.
[0069] Optionally, the microservice responding to the internal call request is updated to the target microservice. If the target microservice does not include the internal call request at this time, the call process ends. If the target microservice includes the internal call request at this time, the process returns to the step of obtaining the internal whitelist from the internal scheduling module in response to the target microservice including the internal call request.
[0070] Unlike the embodiments described above, the configuration module includes a storage unit and a cache unit. The storage unit stores the latest version of the service key for each microservice, while the cache unit stores the previous version of the service key for microservices whose service keys have been modified. The module retrieves the service key of the target microservice from the storage unit of the configuration module after responding to a scheduling request, ensuring that the returned service key is the latest version. When the target microservice receives a call request, it retrieves both the old and new versions of the service key from the storage and cache units for authentication. The call request is only invoked after either version of the service key passes authentication, thus reducing the probability of the call request not being responded to due to the target microservice's service key being modified before a response is received, improving the stability of the entire call process. Furthermore, when the target microservice includes internal call requirements, the internal scheduling module enables calls between microservices. Microservices do not need to obtain each other's service keys during scheduling, effectively avoiding mutual knowledge of service keys and reducing the probability of multiple microservice service keys being leaked from the microservice side.
[0071] Please see Figure 4 , Figure 4 This is a flowchart illustrating another implementation of the microservice invocation method of this application, where the corresponding terminal is the authentication module. The method includes:
[0072] S401: In response to the calling platform sending a calling instruction to the authentication module, and the authentication module parsing the key information and access path from the calling instruction, authenticating the key information, and obtaining the scheduling request issued by the authentication module after successful authentication, the calling platform has pre-configured access permissions for at least one of the multiple microservices. Each microservice has its own service key, and the key information is associated with the service keys of the microservices configured on the calling platform, and the configuration module stores the association.
[0073] Specifically, when the calling platform sends a calling instruction to the authentication module, and the authentication module parses the key information and access path from the calling instruction, authenticates the key information, and obtains the scheduling request issued by the authentication module after the authentication is passed, the relevant process of the authentication module can be referred to any of the above embodiments, and will not be repeated here.
[0074] It should be noted that the calling platform is pre-configured with access permissions for at least one of the multiple microservices. Having access permissions for the corresponding microservice means having access to that microservice. Each microservice has its own service key so that when any microservice is called, the microservice can verify the service key. The key information of the calling platform is associated with the service keys of the microservices configured on the calling platform, and the association is stored in the configuration module.
[0075] In one implementation scenario, the scheduling request carries the key information and access path of the scheduling platform. After obtaining the scheduling request, the key information and access path of the scheduling platform are obtained from the scheduling request.
[0076] In another implementation scenario, the key information and access path are encrypted and combined with the scheduling information to form a scheduling request. After obtaining the scheduling request, it is decrypted to obtain the scheduling information as well as the key information and access path of the scheduling platform.
[0077] S402: Based on the association and access path, obtain the service key of the target microservice and feed it back to the authentication module so that the authentication module can generate a call request based on the service key of the target microservice and use the call request to call the target microservice, where the target microservice is the microservice indicated by the access path.
[0078] Specifically, based on the association and access path, the target microservice for this call by the scheduling platform is determined, the service key of the target microservice is obtained, and the service key of the target microservice is fed back to the authentication module. Therefore, when the calling platform calls the target microservice, different calling platforms do not interfere with each other. After the authentication module authenticates the key information, the configuration module feeds back the service key of the target microservice. Thus, the authentication module will only receive the service key of the target microservice, thereby reducing the probability of the authentication module leaking the service keys of all microservices.
[0079] Furthermore, after the authentication module obtains the service key of the target microservice, the process of calling the target microservice is described in any of the above embodiments, and will not be repeated here.
[0080] In one application approach, the service key of a microservice is stored on the microservice itself. Based on the association and access path, the target microservice is identified, and its service key is retrieved from the target microservice.
[0081] In another application approach, the service key of the microservice is stored in the configuration module. Based on the association and access path, the target microservice is determined, and the service key of the target microservice is obtained from the configuration module.
[0082] In one implementation scenario, the configuration module includes a storage unit that stores the service key of the latest version of each microservice. Based on the association and access path, the module obtains the service key of the target microservice and feeds it back to the authentication module. This includes: determining the target microservice from the microservices configured by the calling platform based on the association and access path; obtaining the service key of the target microservice from the storage unit; and feeding the service key of the target microservice back to the authentication module.
[0083] Specifically, the target microservice indicated by the access path is determined based on the access path, and the microservice with access permissions pre-configured by the calling platform is determined based on the association relationship. When the target microservice belongs to the microservice with access permissions pre-configured by the calling platform, the target microservice is determined to be valid. The service key of the target microservice is obtained from the storage unit to ensure that the service key of the target microservice fed back is the latest version at the time of feedback, and the service key of the target microservice is fed back to the authentication module.
[0084] Furthermore, the configuration module also includes a cache unit, which stores the service key of the previous version of the microservice whose service key has been modified. The microservice invocation method used in this embodiment further includes: in response to any microservice's service key being exposed, designating the microservice with exposed service keys as the microservice to be corrected, transferring the service key of the microservice to be corrected from the storage unit to the cache unit, and updating the service key in the storage unit; and updating the association relationships of all invocation platforms corresponding to the microservice to be corrected configured in the configuration module based on the latest version of the service key of the microservice to be corrected.
[0085] Specifically, when the service key of any microservice has been exposed, the microservice whose service key has been exposed is designated as the microservice to be corrected. The service key of the microservice to be corrected is first transferred from the storage unit to the cache unit to achieve backup of the service key. The service key of the microservice to be corrected is then updated in the storage unit to save the latest version.
[0086] Furthermore, the calling platforms configured with the microservice to be corrected are identified. Based on the latest version of the service key of the service to be corrected, the association relationships of all calling platforms configured with the microservice to be corrected in the configuration module are updated to ensure the accuracy of the association relationships. Therefore, once the microservice is exposed, only the service key of the microservice needs to be updated. After the service key of the microservice is updated, only the association relationships need to be modified, without modifying the key information itself. Thus, the update of the service key does not affect the use of the key information, and the calling platform will not be aware of the change in the service key of the microservice.
[0087] Understandably, when the service key of a microservice is updated, two versions of the service key are stored in the storage unit and the cache unit respectively. The microservice can call the new and old versions of the service key for authentication, thereby reducing the probability that the service key of the target microservice will be modified before the call request is responded to, which will cause the call request to not be responded to, and improving the stability of the entire call process.
[0088] Optionally, in response to the exposure of the key information of any calling platform, the calling platform whose key information has been exposed is designated as the platform to be corrected, and the key information of the platform to be corrected is updated; based on the latest version of the key information of the platform to be corrected, the association relationship corresponding to the platform to be corrected in the configuration module is updated.
[0089] Specifically, when the key information of any calling platform has been exposed, the calling platform whose key information has been exposed is designated as the platform to be corrected. The key information of the platform to be corrected is hot-updated by republishing the key information, so that the key information can be quickly repaired, thereby avoiding the risk of continuous leakage of information on the calling platform.
[0090] Furthermore, the service keys of the microservices pre-configured on the platform to be corrected are determined. Based on the latest version of the key information of the platform to be corrected, the association between the key information corresponding to the platform to be corrected and the service keys of the microservices already configured on the calling platform is updated in the configuration module to ensure the accuracy of the association.
[0091] In this embodiment, after receiving a scheduling request, the configuration module determines the target microservice for this call by the scheduling platform based on the association and access path, obtains the service key of the target microservice, and feeds back the service key of the target microservice to the authentication module. Therefore, when a calling platform calls the target microservice, different calling platforms do not interfere with each other. After the authentication module authenticates the key information, the configuration module feeds back the service key of the target microservice. Thus, the authentication module only receives the service key of the target microservice, reducing the probability of the authentication module leaking the service keys of all microservices. Furthermore, when a microservice is exposed, only the service key of the microservice needs to be updated. After the service key is updated, only the association needs to be modified; there is no need to modify the key information. Therefore, the update of the service key does not affect the use of the key information, and the calling platform will not be aware of the change in the service key of the microservice. When a calling platform is exposed, the calling platform whose key information has been exposed is designated as the platform to be corrected. The key information of the platform to be corrected is hot-updated by republishing the key information, enabling rapid repair of the key information.
[0092] Please see Figure 5 , Figure 5 This is a schematic diagram of an embodiment of the electronic device of this application. The electronic device 50 includes a memory 501 and a processor 502 coupled to each other. The memory 501 stores program data (not shown in the figure), and the processor 502 calls the program data to implement the method in any of the above embodiments. For the relevant content, please refer to the detailed description of the above method embodiments, which will not be repeated here.
[0093] Please see Figure 6 , Figure 6This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 60 stores program data 600. When the program data 600 is executed by a processor, it implements the method in any of the above embodiments. For a detailed description of the relevant content, please refer to the detailed description of the above method embodiments, which will not be repeated here.
[0094] It should be noted that the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0095] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0096] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0097] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A microservice invocation method, characterized in that, The method, applied to a calling system including an authentication module and a configuration module, wherein the configuration module is set independently of the authentication module, includes: The system obtains a call instruction sent by the calling platform, parses the key information and access path from the call instruction, authenticates the key information, and sends a scheduling request to the configuration module after successful authentication. The calling platform pre-configures access permissions for at least one of multiple microservices, each microservice has its own service key, and the key information is associated with the service keys of the microservices configured on the calling platform. The configuration module stores this association. Obtain the service key of the target microservice fed back by the configuration module in response to the scheduling request, and generate a call request based on the service key of the target microservice; wherein, the target microservice is the microservice indicated by the access path; The target microservice is invoked using the aforementioned invocation request.
2. The method according to claim 1, characterized in that, The configuration module includes a storage unit, which stores the service key of the latest version of each microservice. The step of obtaining the service key of the target microservice fed back by the configuration module in response to the scheduling request, and generating a call request based on the service key of the target microservice, includes: Obtain the service key of the target microservice in the storage unit, which is fed back by the configuration module in response to the scheduling request, and use it as the target service key; Based on the target service key, a call request carrying the target service key is generated.
3. The method according to claim 2, characterized in that, The configuration module also includes a cache unit, which stores the service key of the previous version of the microservice with the service key modified. The step of invoking the target microservice using the invocation request includes: The call request is sent to the target microservice based on the access path, so that the target microservice can obtain the service key in the storage unit and the cache unit for authentication, and respond to the call request after successful authentication.
4. The method according to claim 1, characterized in that, The calling system also includes an internal scheduling module, which includes an internal whitelist and a token bucket; After invoking the target microservice using the invocation request, the process further includes: In response to the target microservice including internal call requirements, the internal whitelist is obtained from the internal scheduling module; In response to the fact that the target microservice is in the internal whitelist and the token bucket does not contain the target token required by the target microservice, the target token required by the target microservice is generated and the target token is stored in the token bucket; In response to the fact that the target microservice is in the internal whitelist and the token bucket includes the target token required by the target microservice, the target token is obtained from the token bucket; The target token is sent to the target microservice so that the target microservice can use the target token to invoke the microservice corresponding to the internal invocation request.
5. The method according to claim 4, characterized in that, The internal call request carries the current service key of the target microservice. Before generating the target token required for the target microservice and storing the target token in the token bucket, the process also includes: The service key carried in the internal call request is authenticated.
6. A microservice invocation method, characterized in that, The method, applied to a calling system including an authentication module and a configuration module, wherein the configuration module is set independently of the authentication module, includes: In response to the calling platform sending a calling instruction to the authentication module, and the authentication module parsing the key information and access path from the calling instruction, authenticating the key information, and obtaining the scheduling request issued by the authentication module upon successful authentication; wherein, the calling platform pre-configures access permissions for at least one of multiple microservices, each of the microservices has its own service key, the key information is associated with the service keys of the microservices configured by the calling platform, and the configuration module stores the association relationship; Based on the association and the access path, the service key of the target microservice is obtained, and the service key of the target microservice is fed back to the authentication module, so that the authentication module generates a call request based on the service key of the target microservice and uses the call request to call the target microservice; wherein, the target microservice is the microservice indicated by the access path.
7. The method according to claim 6, characterized in that, The configuration module includes a storage unit, which stores the service key of the latest version of each microservice. The step of obtaining the service key of the target microservice based on the association and the access path, and feeding back the service key of the target microservice to the authentication module, includes: Based on the association and the access path, the target microservice is determined from the microservices configured by the calling platform; The service key of the target microservice is obtained from the storage unit and fed back to the authentication module.
8. The method according to claim 7, characterized in that, The configuration module also includes a cache unit, which stores the service key of the previous version of the microservice with the service key modified. The method further includes: In response to the exposure of the service key of any of the microservices, the microservices whose service keys have been exposed are designated as microservices to be corrected. The service keys of the microservices to be corrected in the storage unit are transferred to the cache unit, and the service keys in the storage unit are updated. Based on the service key of the latest version of the microservice to be corrected, update the association relationship of all the calling platforms corresponding to the microservice to be corrected configured in the configuration module.
9. The method according to claim 6, characterized in that, The method further includes: In response to the fact that the key information of any of the calling platforms has been exposed, the calling platform whose key information has been exposed is designated as the platform to be corrected, and the key information is updated for the platform to be corrected. Based on the key information of the latest version of the platform to be corrected, update the association relationship corresponding to the platform to be corrected in the configuration module.
10. An electronic device, characterized in that, include: A memory and a processor are coupled to each other, wherein the memory stores program data, and the processor invokes the program data to perform the method as described in any one of claims 1-5 or 6-9.
11. A computer-readable storage medium storing program data thereon, characterized in that, When the program data is executed by the processor, it implements the method as described in any one of claims 1-5 or 6-9.
Citation Information
Patent Citations
Micro service unified authentication method and gateway
CN108901022A
Distributed micro-service authentication and business calling method and system and financial platform
CN116032544A
