Microservice gateway unified authentication method, device, microservice gateway and storage medium
By accessing the authentication interface of the microservice application in the microservice gateway and using distributed cache to store authentication information, the problem of authentication difference and security in the microservice system is solved, single device login and client logout are realized, and the system is improved. authentication flexibility and security.
Patent Information
- Application Number
- CN202211013864.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-08-23
AI Technical Summary
In complex microservice business systems, the authentication methods of each microservice application are very different. It is difficult to meet all business service authentication needs in an independent authentication service, and the existing solution cannot support single device login and client logout. operation, introducing additional development costs and security risks.
By accessing the authentication interface of each microservice application in the microservice gateway, using distributed cache to store authentication token related information, supporting the differentiated authentication interface of business microservice applications, realizing single device login and client logout logic, using authentication Define synchronous authentication requests and parse tokens, and update the token expiration time to support logout operations.
Without introducing additional development costs, it meets the authentication requirements of multiple business services, supports single device login and client logout, improves system security, and avoids security risks.
Smart Images

Figure CN115396180B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of software technology, and more specifically, to a microservice gateway unified authentication method, device, microservice gateway and storage medium. Background Art
[0002] As the boundary of the system, the microservice gateway can uniformly control the traffic in and out of the system. The ingress gateway is a frequently used gateway type and is deployed between the load balancing server and the application server.
[0003] The unified authentication scheme for microservice gateways currently commonly used in the industry is: 1) The client sends authentication requests uniformly through the microservice gateway, and the microservice gateway forwards the authentication request to an independent authentication service deployed on the application service. The authentication service executes the client authentication logic by accessing the user database. If the authentication is successful, it returns the generated JWT authentication token to the client. 2) When the client sends a business interface access request uniformly through the microservice gateway, it carries the JWT authentication token in the request header. The microservice gateway verifies the validity of the JWT authentication token through the JWT authentication token parsing configuration pre-defined by the operation and maintenance personnel (consistent with the JWT authentication token generation logic in the authentication service). If the verification is successful, the payload key value in the JWT authentication token is parsed according to the configuration, added to the request header, and the request is forwarded to the specified gateway downstream microservice application. The above payload key value is usually used to store business information (such as user ID) for use when the business microservice application executes business logic.
[0004] However, the current unified authentication scheme for microservice gateways has the following main problems: In a complex microservice business system, the authentication methods of various business microservice applications are often very different. This is reflected in the different data sources for storing authentication information and the different authentication information required to be provided by authentication requests. Therefore, it is difficult to implement an authentication interface that meets all business service authentication requirements in an independent authentication service. Even if it is implemented, it will involve the reconstruction of the original authentication logic of the business microservice application, introducing additional development costs. Summary of the invention
[0005] In view of this, in order to solve the above problems, the present disclosure provides a microservice gateway unified authentication method, device, microservice gateway and storage medium, and the technical solution is as follows:
[0006] A unified authentication method for a microservice gateway, the method being applied to a microservice gateway, the method comprising:
[0007] Receive a synchronized authentication definition, wherein the authentication definition includes business microservice application authentication interface information, authentication token response body parsing mode, and authentication token verification definition;
[0008] If it is determined based on the business microservice application authentication interface information that an authentication request from the first client is received, the authentication request is sent to the corresponding first microservice application, and an authentication token is obtained by parsing the response body returned by the first microservice application based on the authentication token response body parsing mode; the authentication token is parsed based on the authentication token verification definition to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in a distributed cache;
[0009] If it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received, a target authentication token is obtained from the business interface request based on the authentication token verification definition, and the target authentication token is parsed; the distributed cache is queried with the parsed result of the target authentication token, and when authentication token related information of the target authentication token is queried in the distributed cache, the business information in the parsed result is added to the HTTP header of the business interface request; the business interface request with the added business information is sent to the corresponding second microservice application, and the business interface request response returned by the second microservice application is sent to the second client.
[0010] Optionally, the receiving the synchronized authentication definition includes:
[0011] When the microservice gateway is started or the authentication definition is updated, the synchronized authentication definition is received.
[0012] Optionally, storing the authentication token related information of the authentication token in a distributed cache includes:
[0013] Acquire first cache data and second cache data from authentication token related information of the authentication token, and store the first cache data and the second cache data in the distributed cache;
[0014] Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token;
[0015] Correspondingly, querying the distributed cache with the parsing result of the target authentication token includes:
[0016] The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as a cache key.
[0017] Optionally, the method further includes:
[0018] If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
[0019] Optionally, the method further includes:
[0020] If it is determined that a logout request from a second client is received, obtain the application name of the second microservice application and the target authentication token from the logout request, use the Base64-encoded string concatenation value of the application name of the second microservice application and the target authentication token as a cache key, and delete the cache key from the distributed cache; and return a logout response to the second client.
[0021] A unified authentication device for a microservice gateway, the device comprising:
[0022] A client authentication module, for receiving a synchronized authentication definition, the authentication definition including business microservice application authentication interface information, authentication token response body parsing mode and authentication token verification definition; if it is determined based on the business microservice application authentication interface information that an authentication request of a first client is received, the authentication request is sent to a corresponding first microservice application, and an authentication token is obtained by parsing the response body returned by the first microservice application based on the authentication token response body parsing mode; the authentication token is parsed based on the authentication token verification definition to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in a distributed cache;
[0023] A client business processing module is used to, if it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received, obtain a target authentication token from the business interface request based on the authentication token verification definition, and parse the target authentication token; query the distributed cache with the parsed result of the target authentication token, and when the authentication token related information of the target authentication token is queried in the distributed cache, add the business information in the parsed result to the HTTP header of the business interface request; send the business interface request with the added business information to the corresponding second microservice application, and send the business interface request response returned by the second microservice application to the second client.
[0024] Optionally, the client authentication module for storing the authentication token related information of the authentication token in a distributed cache is specifically used to:
[0025] Acquire first cache data and second cache data from authentication token related information of the authentication token, and store the first cache data and the second cache data in the distributed cache;
[0026] Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token;
[0027] Correspondingly, the client service processing module for querying the distributed cache with the parsing result of the target authentication token is specifically used for:
[0028] The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as a cache key.
[0029] Optionally, the client authentication module is further used to:
[0030] If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
[0031] A microservice gateway, the microservice gateway comprising: at least one memory and at least one processor; the memory stores an application program, the processor calls the application program stored in the memory, and the application program is used to implement a unified authentication method for the microservice gateway.
[0032] A storage medium stores computer program code, which implements the unified authentication method for microservice gateways when executed.
[0033] Compared with the prior art, the beneficial effects achieved by the present disclosure are:
[0034] The present invention provides a unified authentication method, device, microservice gateway and storage medium for microservice gateways. The unified authentication method for microservice gateways is applied to a microservice gateway, and receives a synchronized authentication definition, which includes business microservice application authentication interface information, an authentication token response body parsing mode and an authentication token verification definition. If it is determined based on the business microservice application authentication interface information that an authentication request from a first client is received, the authentication request is sent to the first microservice application, and an authentication token is obtained by parsing the response body returned by the first microservice application based on the authentication token response body parsing mode. The authentication token is parsed based on the authentication token verification definition to obtain authentication token related information of the authentication token, and stored in a distributed cache. If it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received, a target authentication token is obtained from the business interface request based on the authentication token verification definition, and the target authentication token is parsed. The distributed cache is queried with the parsing result of the target authentication token, and when the authentication token related information of the target authentication token is queried in the distributed cache, the business information in the parsing result is added to the HTTP header in the business interface request. The business interface request after the business information is added is sent to the corresponding second microservice application, and the business interface request response returned by the second microservice application is sent to the second client.
[0035] The present invention directly connects the microservice gateway to the authentication interface of each microservice application and uniformly performs client authentication on the microservice gateway. This solves the problem of meeting multiple business service authentication requirements at the entrance of the loaded microservice business system without introducing additional development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0037] Figure 1This is a flowchart of the unified authentication solution for microservice gateways currently used in the industry;
[0038] Figure 2 A method flow chart of a unified authentication method for a microservice gateway provided in an embodiment of the present disclosure;
[0039] Figure 3 A schematic diagram of a process for configuring authentication definitions for operation and maintenance personnel provided in an embodiment of the present disclosure;
[0040] Figure 4 A schematic diagram of a process of requesting authentication microservice application by a client provided in an embodiment of the present disclosure;
[0041] Figure 5 A schematic diagram of a process for updating authentication token related information in a distributed cache provided by an embodiment of the present disclosure;
[0042] Figure 6 A schematic diagram of a process for a client to request access to a microservice business interface provided in an embodiment of the present disclosure;
[0043] Figure 7 A schematic diagram of a process of requesting login by a client provided in an embodiment of the present disclosure;
[0044] Figure 8 A schematic diagram of the process of a unified authentication solution for a microservice gateway provided in an embodiment of the present disclosure;
[0045] Fig. 9 A schematic diagram of the structure of a unified authentication device for a microservice gateway provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0046] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0047] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0048] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0049] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0050] In the microservice distributed architecture, the microservice gateway is an architectural pattern that integrates the common functions of some services and deploys them independently as a separate layer to solve some service governance issues. As the boundary of the system, the microservice gateway can uniformly control the traffic in and out of the system. As a frequently used type of gateway, the ingress gateway is deployed between the load balancing server and the application server, and has the following main functions:
[0051] 1) Provide a unified access address to the client. The microservice gateway can dynamically route user requests to different business services and perform some necessary protocol conversion. By shielding the deployment addresses and protocol details of these services from the client, it greatly facilitates the client's calls;
[0052] 2) Some service governance strategies can be implemented based on the microservice gateway, such as service fusing, degradation, flow control and diversion, etc.;
[0053] 3) Implement blacklists and whitelists, such as blacklists and whitelists for device ID, user IP, user ID, etc.
[0054] 4) Implement unified client authentication in the microservice gateway to reduce the workload of client development.
[0055] JWT (JSON Web Token) is an open standard that defines a compact and self-contained method for securely transmitting information encoded as a JSON object between two parties. The JWT authentication token consists of three parts: header, payload, and signature. The header describes the metadata of the JWT authentication token, including the signature algorithm and token type; the payload is used to store the actual data that needs to be transmitted; the signature part is a signature of the first two parts to prevent data tampering. Because the JWT authentication token is stateless, allows cross-domain access, and is more suitable for mobile applications, it is currently the most popular authentication token solution for implementing client authentication based on microservice gateways.
[0056] See also Figure 1 , Figure 1This is a flow chart of the unified authentication solution for microservice gateways currently commonly used in the industry, which includes the authentication process and the authentication token verification process.
[0057] Continue to see Figure 1 The client sends the authentication request uniformly through the microservice gateway (that is, the client requests authentication in the authentication process), and the microservice gateway forwards the authentication request to the independent gateway authentication service deployed on the application service (that is, the microservice gateway sends the client authentication in the authentication process). The gateway authentication service executes the client authentication logic by accessing the user database. If the authentication is successful, it returns the generated JWT authentication token to the client (that is, the gateway authentication service generates the authentication token and the microservice gateway responds to the authentication request in the authentication process).
[0058] Continue to see Figure 1 The authentication token verification process in. When the client sends a business interface access request uniformly through the microservice gateway, the JWT authentication token is carried in the request header (that is, in the authentication token verification process, the client requests the microservice gateway to access the business interface (carrying the authentication token)); the microservice gateway verifies the validity of the JWT authentication token through the JWT authentication token parsing configuration pre-defined by the operation and maintenance personnel (consistent with the generation logic of the JWT authentication token in the authentication service) (that is, the microservice gateway verifies the authentication token in the authentication token verification process); if the verification is successful, the microservice gateway parses the payload key value in the JWT authentication token according to the configuration, adds it to the request header, and forwards the request to the specified gateway downstream microservice application. The above payload key value is usually used to store business information (such as user ID) for use when the microservice application executes business logic (that is, in the authentication token verification process, the microservice gateway passes the business information in the authentication token to microservice application A through the header, microservice application A responds to the request, and the microservice gateway responds to the request).
[0059] However, the current unified authentication scheme for microservice gateways has the following problems:
[0060] 1) In a complex microservice business system, the authentication methods of various microservice applications are often very different. This is reflected in the different data sources for storing authentication information and the different authentication information required by authentication requests. Therefore, it is difficult to implement an authentication interface that meets the authentication requirements of all business services in an independent authentication service. Even if it is implemented, it will involve the reconstruction of the original authentication logic of the microservice application, introducing additional development costs.
[0061] 2) Due to the self-contained nature of the JWT authentication token, the expiration time of the token is already included in the string of the token itself. The expiration time of the token cannot be updated without modifying the JWT authentication token string. Therefore, the microservice gateway cannot implement the logout operation of the logged-in client. Once the JWT authentication token obtained by the client authentication is generated, it cannot be forcibly invalidated within the validity period of the token. If the token is leaked, it may cause serious security issues.
[0062] 3) For some business systems with high security requirements, it is necessary to support single-device login features, that is, for the same account, only one device can be logged in at the same time. If you log in on other devices at the same time, the login status of this device will be invalid. However, the existing solution cannot meet the single-device login requirements. One account can be used on multiple devices at the same time, causing security risks.
[0063] Therefore, it seems very necessary to implement unified authentication of microservice gateways, support differentiated authentication interfaces for accessing different business systems, support the implementation of client logout logic, and support single-device login features.
[0064] In order to solve the above problems, the present invention proposes a unified authentication solution for a microservice gateway, which supports access to differentiated authentication interfaces of different business systems, supports the implementation of client logout logic, and supports single-device login features.
[0065] It should be noted that the authentication token in the embodiment of the present invention is a JWT authentication token.
[0066] See also Figure 2 , Figure 2 A method flow chart of a unified authentication method for a microservice gateway provided in an embodiment of the present disclosure, wherein the unified authentication method for a microservice gateway is applied to a microservice gateway, and the method comprises the following steps:
[0067] S10, receiving the synchronized authentication definition, where the authentication definition includes business microservice application authentication interface information, authentication token response body parsing mode, and authentication token verification definition.
[0068] The disclosed embodiment can deploy a gateway authentication management service in the configuration center, and the gateway authentication management service is used for the operation and maintenance personnel to configure the authentication definition during the operation and maintenance stage, and the authentication definition includes the business microservice application authentication interface information, the authentication token response body parsing mode and the authentication token verification definition. When the microservice gateway is started or the authentication definition is updated, the gateway authentication management service will synchronize the authentication definition to the microservice gateway for the microservice gateway to use when processing client authentication.
[0069] See also Figure 3 , Figure 3A schematic diagram of the process of configuring authentication definitions for operation and maintenance personnel provided in the embodiment of the present disclosure. Figure 3 During the operation and maintenance phase, the operation and maintenance personnel access the gateway authentication management front-end page, click the New Authentication Definition button, first fill in the business microservice application authentication interface information, then fill in the authentication token response body parsing mode, and finally fill in the authentication token verification definition, and click the Save button to call the back-end service, that is, the gateway authentication management service. The gateway authentication management service will save the newly created authentication definition and synchronize the authentication definition to the microservice gateway. There are two synchronization methods: loading when the microservice gateway starts and updating when the microservice gateway is running.
[0070] Among them, the configuration items of the business microservice application authentication interface information include: application name, interface HTTP method, and gateway routing path of the interface; the configuration items of the authentication token response body parsing mode include: response body format (JSON, XML, plain text), response body parsing mode (JSONPath, XPath, regular expression); the configuration items of the authentication token verification definition include: application name, HTTP header name of the authentication token in the request, a list of business interfaces that need to be accessed through authentication (interface HTTP method, gateway routing path of the interface), JWT authentication token key, a list of business information payload key names in the JWT authentication token that need to be parsed and passed to downstream services, whether the single device login feature needs to be supported, and the JWT authentication token payload key name representing the user ID.
[0071] S20: If it is determined based on the business microservice application authentication interface information that an authentication request from the first client is received, the authentication request is sent to the corresponding first microservice application, and the authentication token is parsed from the response body returned by the first microservice application based on the authentication token response body parsing mode to obtain the authentication token; based on the authentication token verification definition, the authentication token is parsed to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in the distributed cache.
[0072] In the disclosed embodiment, the microservice application exposes the business interface to the outside world through the microservice gateway. On the one hand, it processes the authentication request from the client, executes the authentication logic according to the business definition, generates the authentication token and returns it through the response; on the other hand, it processes the business interface request that has passed the authentication check of the microservice gateway, executes the normal business logic and returns the response.
[0073] See also Figure 4 , Figure 4 This is a flow chart of the client request authentication microservice application provided in the embodiment of the present disclosure. Figure 4 Before requesting access to the authentication-protected microservice business interface, the client (ie, the first client) needs to send an authentication request to the microservice gateway to request authentication of the microservice application (ie, the first microservice application).
[0074] After receiving the client's request, the microservice gateway determines whether the current request is an authentication request based on the business microservice application authentication interface information in the locally synchronized authentication definition. If it is an authentication request, it forwards the authentication request to the relevant first microservice application (i.e. Figure 4 The first microservice application executes the authentication logic, generates an authentication token and includes it in the response body (i.e. Figure 4 The microservice application generates an authentication token response body), then the microservice gateway parses the authentication token in the response body according to the authentication token response body parsing mode in the authentication definition, and then the microservice gateway parses the authentication token itself according to the authentication token verification definition in the authentication definition, creates or updates the authentication token related information in the distributed cache, and returns a response to the authentication request to the first client.
[0075] In the specific implementation process, in step S20, "storing the authentication token related information of the authentication token into the distributed cache" can adopt the following steps:
[0076] acquiring first cache data and second cache data from authentication token related information of the authentication token, and storing the first cache data and second cache data in a distributed cache;
[0077] Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token.
[0078] In the embodiment of the present disclosure, cache data of the following data structures may be newly created or updated in the distributed cache:
[0079] First cache data - cache key: string concatenation of application name and user ID (Identity document); cache value: Base64 encoding of authentication token; cache expiration time: expiration time of authentication token.
[0080] Second cache data - cache key: the concatenated value of the Base64-encoded string of the application name and the authentication token; cache value: the current timestamp; cache expiration time: the expiration time of the authentication token.
[0081] It should be noted that the distributed cache in the disclosed embodiment is used to store authentication token related information, which is updated by the microservice gateway during client authentication and logout operations for use in verifying the validity of the client authentication token.
[0082] On this basis, in order to realize the login feature of supporting a single device, the embodiment of the present disclosure may further include the following steps:
[0083] If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
[0084] In an embodiment of the present disclosure, if the authentication token verification definition in the locally synchronized authentication definition specifies that a single-device login feature needs to be supported, the microservice gateway may first generate a cache key for the first cache data before operating the distributed cache, and use the generated cache key to query the corresponding first cache data in the distributed cache; if the generated cache key already exists in the distributed cache, it means that the first cache data already exists in the distributed cache; and then it is necessary to string concatenate the application name with the cache value of the first cache data already existing in the distributed cache to obtain the cache key of the second cache data, and use the concatenated cache key to query the corresponding second cache data in the distributed cache; if the concatenated cache key already exists in the distributed cache, it means that the second cache data already exists in the distributed cache; further, it is necessary to update the cache value of the first cache data in the distributed cache, delete the second cache data in the distributed cache, and generate new second cache data to realize the single-device login feature.
[0085] For example, a user (assuming the user ID is user1) logs in to the target application (assuming app1) for the first time on device 1 (assuming a website) and generates an authentication token token1. At this time, the following two cache data are newly created in the distributed cache:
[0086] First cache data——app1-user1:base64_token1
[0087] The second cached data - app1-base64_token1: the current timestamp of the first time.
[0088] Subsequently, the user logs in to the target application (i.e., app1) for the second time on device 2 (assuming it is a mobile application) at the second time and generates an authentication token token2. At this time, a cache key "app1-user1" is first generated, and the cache key "app1-user1" is used to query the distributed cache, and it is found that the first cache data "app1-user1:base64_token1" already exists in the distributed cache; then, the application name "app1" of the target application is concatenated with the cache value "base64_token1" of the first cache data in the distributed cache to obtain the cache key "app1-base64_token1", and the cache key "app1-base64_token1" is used to query the distributed cache, and it is found that the second cache data "app1-base64_token1: the current timestamp of the first time" already exists in the distributed cache. Therefore,
[0089] Update the cache value "base64_token1" of the first cache data to "base64_token2". At this time, the first cache data in the distributed cache is updated from "app1-user1:base64_token1" to "app1-user1:base64_token2".
[0090] Delete the second cache data "app1-base64_token1: current timestamp of the first time" in the distributed cache, and generate new second cache data "app1-base64_token2: current timestamp of the second time". At this time, the second cache data in the distributed cache is updated from "app1-base64_token1: current timestamp of the first time" to "app1-base64_token2: current timestamp of the second time".
[0091] See also Figure 5 , Figure 5 A flow chart of updating authentication token-related information in a distributed cache provided by an embodiment of the present disclosure. Figure 5 , the microservice gateway parses the authentication token to determine whether it is necessary to support the single-device login feature; if not, it creates or updates the first cache data and the second cache data (i.e. Figure 5 Create or update a cache item, and create a cache item); if yes, concatenate the application name of the first microservice application and the user ID of the first client to obtain a cache key A (i.e. Figure 5 The application name and the user ID are concatenated to obtain a key A), and the corresponding first cache data is queried in the distributed cache with the key A; and then the cache key A (i.e. Figure 5Whether the first cached data already exists in the distributed cache, if so, the application name of the first microservice application and the cache value of cache key A are concatenated to obtain cache key B (i.e. Figure 5 The application name and the cache value of key A are concatenated to obtain key B), and the corresponding second cache data is queried in the distributed cache with cache key B; if cache key B exists in the distributed cache, it means that the second cache data already exists in the distributed cache, and cache key B is deleted from the distributed cache (i.e. Figure 5 In the distributed cache, key B is deleted to delete the corresponding second cache data, and then the cache value of the first cache data in the distributed cache is deleted, and the second cache data in the distributed cache is newly created. It should be noted that if cache key A does not exist in the distributed cache, the first cache data and the second cache data are directly created or updated.
[0092] S30: If it is determined based on the business microservice application authentication interface information that a business interface request from the second client is received, obtain the target authentication token from the business interface request based on the authentication token verification definition, and parse the target authentication token; query the distributed cache with the parsed result of the target authentication token, and if the authentication token related information of the target authentication token is found in the distributed cache, add the business information in the parsed result to the HTTP header of the business interface request; send the business interface request with the added business information to the corresponding second microservice application, and send the business interface request response returned by the second microservice application to the second client.
[0093] In the disclosed embodiment, after performing the above authentication operation, the microservice gateway will respond to the client's authentication request.
[0094] See also Figure 6 , Figure 6 This is a flow chart of a client requesting to access a microservice business interface provided by an embodiment of the present disclosure. Figure 6 , when the client (i.e., the second client, which can be the same client as the first client) requests access to the authentication-protected microservice business interface through the gateway, it needs to carry the authentication token (i.e., the target authentication token) obtained in the above step in the request. After receiving the request, the microservice gateway first determines whether the current request is an authentication request based on the business microservice application authentication interface information in the locally synchronized authentication definition. If not, the current request is a business interface request, and it determines whether the current request needs to be authenticated; if so, the microservice gateway obtains the target authentication token from the business interface request according to the authentication token verification definition in the locally synchronized authentication definition, and parses the target authentication token (i.e. Figure 6According to the configuration, obtain the authentication token from the request, parse the authentication token), query the distributed cache to query the authentication token related information of the target authentication token, and determine whether the authentication token related information of the target authentication token is queried (i.e. Figure 6 If the token cache data exists in the query, the microservice gateway adds business information to the HTTP header of the business interface request (i.e. Figure 6 The business information in the token is passed in the microservice gateway), and the business interface request with the business information added is sent to the microservice application (i.e., the second microservice application), and the business interface request is processed by the second microservice application; the microservice gateway obtains the business interface request response returned by the second microservice application and sends it to the second client (i.e., Figure 6 The microservice application responds to the request, and the microservice gateway returns the response request to the client. This is a normal response request).
[0095] It should be noted that if the microservice gateway determines that the current request is an authentication request, the process is as follows Figure 4 , I will not go into details here; if it is determined that the current request does not need to be authenticated, the current request is directly sent to the microservice application, and the microservice application processes the business interface request and responds to the request. The microservice gateway returns the response request to the client, which is a normal response request; if it is determined that the token cache data does not exist, an invalid token response is returned to the client.
[0096] In the specific implementation process, on the basis of the microservice gateway creating or updating the first cache data and the second cache data in the distributed cache, the "querying the distributed cache with the parsing result of the target authentication token" in step S30 can adopt the following steps:
[0097] The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as the cache key.
[0098] In the disclosed embodiment, the microservice application queries the distributed cache using the concatenated value of the application name and the Base64-encoded string of the authentication token as the cache key; if the cache key does not exist, the microservice gateway directly returns an invalid token response to the second client; if the cache key exists, the microservice gateway forwards the business interface request to the downstream second microservice application.
[0099] In some embodiments, in order to implement the microservice gateway to process the client's logout request, the embodiment of the present disclosure may further include the following steps:
[0100] If it is determined that a logout request from the second client is received, obtain the application name and target authentication token of the second microservice application from the logout request, use the Base64-encoded string concatenation value of the application name of the second microservice application and the target authentication token as the cache key, and delete the cache key from the distributed cache; return a logout response to the second client.
[0101] See also Figure 7 , Figure 7 This is a schematic diagram of the process of requesting login by a client provided in an embodiment of the present disclosure. Figure 7 When the client (i.e., the second client) requests to log out of the specified business microservice application through the microservice gateway, it needs to carry the application name and authentication token (i.e., the target authentication token) in the request (i.e., the logout request) header. After receiving the request, the microservice gateway obtains the application name and the target authentication token (i.e., the second microservice application) from the logout request. Figure 7 The application name and authentication token are obtained from the request) The application name of the second microservice application and the Base64-encoded string concatenation value of the target authentication token are used as the cache key, and the cache key is deleted from the distributed cache (i.e. Figure 7 Update the authentication token related information in the distributed cache), and return a logout response to the second client after obtaining the response request returned by the distributed cache (i.e. Figure 7 The microservices gateway returns a response to the client's logout request).
[0102] See also Figure 8 , Figure 8 The schematic diagram of the unified authentication scheme for the microservice gateway provided by the embodiment of the present disclosure includes an authentication process, an authentication token verification process, and a logout process. The specific implementation of the authentication process, the authentication token verification process, and the logout process can be found in the above description, which will not be repeated here.
[0103] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0104] The unified authentication method for microservice gateways provided in the embodiments of the present disclosure effectively solves the problems existing in the existing unified authentication scheme for microservice gateways. Compared with the current industry scheme, the advantages are as follows:
[0105] 1) By directly connecting the microservice gateway to the authentication interface of each microservice application and performing client authentication in a unified manner at the gateway, the problem of meeting multiple business service authentication requirements at the entrance of a complex microservice business system is solved without introducing additional development costs.
[0106] 2) Support the client's logout operation and force the issued authentication token to expire to ensure system security and avoid security issues.
[0107] 3) Support single-device login operation to meet the system's requirements for strong security.
[0108] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0109] Although operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.
[0110] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0111] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0112] Based on the unified authentication method for microservice gateway provided in the above embodiment, the embodiment of the present disclosure provides a device for executing the unified authentication method for microservice gateway, and the structural diagram of the device is shown in FIG. Fig. 9 As shown, including:
[0113] The client authentication module 10 is used to receive the synchronized authentication definition, which includes the business microservice application authentication interface information, the authentication token response body parsing mode and the authentication token verification definition; if it is determined based on the business microservice application authentication interface information that the authentication request of the first client is received, the authentication request is sent to the corresponding first microservice application, and the authentication token is parsed from the response body returned by the first microservice application based on the authentication token response body parsing mode to obtain the authentication token; the authentication token is parsed based on the authentication token verification definition to obtain the authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in the distributed cache;
[0114] The client business processing module 20 is used to obtain a target authentication token from the business interface request based on the authentication token verification definition and parse the target authentication token if it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received; query the distributed cache with the parsed result of the target authentication token, and when the authentication token-related information of the target authentication token is queried in the distributed cache, add the business information in the parsed result to the HTTP header of the business interface request; send the business interface request with the added business information to the corresponding second microservice application, and send the business interface request response returned by the second microservice application to the second client.
[0115] Optionally, the client authentication module 10 for receiving the synchronized authentication definition is specifically configured to:
[0116] When the microservice gateway is started or the authentication definition is updated, the synchronized authentication definition is received.
[0117] Optionally, the client authentication module 10 for storing authentication token related information of the authentication token in the distributed cache is specifically used for:
[0118] acquiring first cache data and second cache data from authentication token related information of the authentication token, and storing the first cache data and second cache data in a distributed cache;
[0119] Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token;
[0120] Correspondingly, the client service processing module 20 for querying the distributed cache with the parsing result of the target authentication token is specifically used for:
[0121] The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as the cache key.
[0122] Optionally, the client authentication module 10 is further used to:
[0123] If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
[0124] Optionally, the client service processing module 20 is further configured to:
[0125] If it is determined that a logout request from the second client is received, obtain the application name and target authentication token of the second microservice application from the logout request, use the Base64-encoded string concatenation value of the application name of the second microservice application and the target authentication token as the cache key, and delete the cache key from the distributed cache; return a logout response to the second client.
[0126] It should be noted that the detailed functions of each module in the embodiment of the present disclosure can be found in the corresponding public part of the above-mentioned user distributed authentication method embodiment, and will not be repeated here.
[0127] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0128] Based on the unified authentication method for a microservice gateway provided in the above embodiments, an embodiment of the present disclosure further provides a microservice gateway, which includes at least one memory and at least one processor; the memory stores an application, the processor calls the application stored in the memory, and the application is used to implement the unified authentication method for a microservice gateway.
[0129] Based on the unified authentication method for microservice gateways provided in the above embodiments, the embodiments of the present disclosure further provide a storage medium, characterized in that the storage medium stores computer program code, and the unified authentication method for microservice gateways is implemented when the computer program code is executed.
[0130] In the context of the present disclosure, a storage medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A storage medium may be a machine-readable signal medium or a machine-readable storage medium. Storage media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0131] It should be noted that the storage medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any storage medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0132] The above-mentioned storage medium may be included in the above-mentioned microservice gateway; or it may exist independently without being assembled into the microservice gateway.
[0133] According to one or more embodiments of the present disclosure, a unified authentication method for a microservice gateway is provided. The method is applied to a microservice gateway, and includes:
[0134] Receive the synchronized authentication definition, which includes the business microservice application authentication interface information, the authentication token response body parsing mode, and the authentication token verification definition;
[0135] If it is determined based on the business microservice application authentication interface information that an authentication request from the first client is received, the authentication request is sent to the corresponding first microservice application, and the authentication token is parsed from the response body returned by the first microservice application based on the authentication token response body parsing mode to obtain the authentication token; the authentication token is parsed based on the authentication token verification definition to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in the distributed cache;
[0136] If it is determined based on the business microservice application authentication interface information that a business interface request from the second client is received, the target authentication token is obtained from the business interface request based on the authentication token verification definition, and the target authentication token is parsed; the distributed cache is queried with the parsed result of the target authentication token, and when the authentication token related information of the target authentication token is queried in the distributed cache, the business information in the parsed result is added to the HTTP header of the business interface request; the business interface request with the added business information is sent to the corresponding second microservice application, and the business interface request response returned by the second microservice application is sent to the second client.
[0137] According to one or more embodiments of the present disclosure, a unified authentication method for a microservice gateway is provided, which receives a synchronized authentication definition and includes:
[0138] When the microservice gateway is started or the authentication definition is updated, the synchronized authentication definition is received.
[0139] According to one or more embodiments of the present disclosure, a unified authentication method for a microservice gateway is provided, which stores authentication token-related information of an authentication token in a distributed cache, including:
[0140] acquiring first cache data and second cache data from authentication token related information of the authentication token, and storing the first cache data and second cache data in a distributed cache;
[0141] Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token;
[0142] Accordingly, the distributed cache is queried with the parsed result of the target authentication token, including:
[0143] The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as the cache key.
[0144] According to one or more embodiments of the present disclosure, a microservice gateway unified authentication method is provided, further comprising:
[0145] If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
[0146] According to one or more embodiments of the present disclosure, a microservice gateway unified authentication method is provided, further comprising:
[0147] If it is determined that a logout request from the second client is received, obtain the application name and target authentication token of the second microservice application from the logout request, use the Base64-encoded string concatenation value of the application name of the second microservice application and the target authentication token as the cache key, and delete the cache key from the distributed cache; return a logout response to the second client.
[0148] According to one or more embodiments of the present disclosure, a microservice gateway unified authentication device is provided, the device comprising:
[0149] A client authentication module is used to receive a synchronized authentication definition, the authentication definition including business microservice application authentication interface information, authentication token response body parsing mode and authentication token verification definition; if it is determined based on the business microservice application authentication interface information that an authentication request of a first client is received, the authentication request is sent to the corresponding first microservice application, and based on the authentication token response body parsing mode, an authentication token is parsed from the response body returned by the first microservice application to obtain the authentication token; based on the authentication token verification definition, the authentication token is parsed to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in a distributed cache;
[0150] The client business processing module is used to obtain a target authentication token from the business interface request based on the authentication token verification definition and parse the target authentication token if it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received; query the distributed cache with the parsed result of the target authentication token, and when the authentication token related information of the target authentication token is queried in the distributed cache, add the business information in the parsed result to the HTTP header of the business interface request; send the business interface request with the added business information to the corresponding second microservice application, and send the business interface request response returned by the second microservice application to the second client.
[0151] According to one or more embodiments of the present disclosure, a microservice gateway unified authentication device is provided, which is used to store authentication token related information of an authentication token to a client authentication module in a distributed cache, specifically for:
[0152] acquiring first cache data and second cache data from authentication token related information of the authentication token, and storing the first cache data and second cache data in a distributed cache;
[0153] Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token;
[0154] Correspondingly, the client business processing module for querying the distributed cache with the parsing result of the target authentication token is specifically used for:
[0155] The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as the cache key.
[0156] According to one or more embodiments of the present disclosure, a microservice gateway unified authentication device and a client authentication module are provided, which are also used for:
[0157] If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
[0158] According to one or more embodiments of the present disclosure, a microservice gateway is provided, which includes: at least one memory and at least one processor; the memory stores an application program, the processor calls the application program stored in the memory, and the application program is used to implement a unified authentication method for the microservice gateway.
[0159] According to one or more embodiments of the present disclosure, a storage medium is provided, wherein the storage medium stores computer program code, and the computer program code implements a user distributed authentication method when executed.
[0160] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0161] Although several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination.
[0162] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
Claims
1. A unified authentication method for a microservice gateway, characterized in that: The method is applied to a microservice gateway, and the method includes: Receive a synchronized authentication definition, wherein the authentication definition includes business microservice application authentication interface information, authentication token response body parsing mode, and authentication token verification definition; If it is determined based on the business microservice application authentication interface information that an authentication request from the first client is received, the authentication request is sent to the corresponding first microservice application, and an authentication token is obtained by parsing the response body returned by the first microservice application based on the authentication token response body parsing mode; the authentication token is parsed based on the authentication token verification definition to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in a distributed cache; If it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received, a target authentication token is obtained from the business interface request based on the authentication token verification definition, and the target authentication token is parsed; the distributed cache is queried with the parsed result of the target authentication token, and when authentication token related information of the target authentication token is queried in the distributed cache, the business information in the parsed result is added to the HTTP header of the business interface request; the business interface request with the added business information is sent to the corresponding second microservice application, and the business interface request response returned by the second microservice application is sent to the second client.
2. The method according to claim 1, characterized in that The receiving synchronized authentication definition comprises: When the microservice gateway is started or the authentication definition is updated, the synchronized authentication definition is received.
3. The method according to claim 1, characterized in that The storing the authentication token related information of the authentication token into a distributed cache comprises: Acquire first cache data and second cache data from authentication token related information of the authentication token, and store the first cache data and the second cache data in the distributed cache; Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token; Correspondingly, querying the distributed cache with the parsing result of the target authentication token includes: The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as a cache key.
4. The method according to claim 3, characterized in that The method further comprises: If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
5. The method according to claim 3, characterized in that: The method further comprises: If it is determined that a logout request from a second client is received, obtain the application name of the second microservice application and the target authentication token from the logout request, use the Base64-encoded string concatenation value of the application name of the second microservice application and the target authentication token as a cache key, and delete the cache key from the distributed cache; and return a logout response to the second client.
6. A unified authentication device for a microservice gateway, characterized in that: The device comprises: A client authentication module, for receiving a synchronized authentication definition, the authentication definition including business microservice application authentication interface information, authentication token response body parsing mode and authentication token verification definition; if it is determined based on the business microservice application authentication interface information that an authentication request of a first client is received, the authentication request is sent to a corresponding first microservice application, and an authentication token is obtained by parsing the response body returned by the first microservice application based on the authentication token response body parsing mode; the authentication token is parsed based on the authentication token verification definition to obtain authentication token related information of the authentication token, and the authentication token related information of the authentication token is stored in a distributed cache; A client business processing module is used to, if it is determined based on the business microservice application authentication interface information that a business interface request from a second client is received, obtain a target authentication token from the business interface request based on the authentication token verification definition, and parse the target authentication token; query the distributed cache with the parsed result of the target authentication token, and when the authentication token related information of the target authentication token is queried in the distributed cache, add the business information in the parsed result to the HTTP header of the business interface request; send the business interface request with the added business information to the corresponding second microservice application, and send the business interface request response returned by the second microservice application to the second client.
7. The device according to claim 6, characterized in that The client authentication module is used to store the authentication token related information of the authentication token in the distributed cache, specifically used to: Acquire first cache data and second cache data from authentication token related information of the authentication token, and store the first cache data and the second cache data in the distributed cache; Among them, the cache key of the first cache data is the string concatenation value of the application name of the first microservice application and the user ID of the first client, the cache value is the Base64 encoding of the authentication token, and the cache expiration time is the expiration time of the authentication token; the cache key of the second cache data is the string concatenation value of the application name of the first microservice application and the Base64 encoding of the authentication token, the cache value is the current timestamp, and the cache expiration time is the expiration time of the authentication token; Correspondingly, the client service processing module for querying the distributed cache with the parsing result of the target authentication token is specifically used for: The second cache data in the distributed cache is queried using the concatenated value of the application name of the second microservice application and the Base64-encoded string of the target authentication token as a cache key.
8. The device according to claim 7, characterized in that The client authentication module is further used for: If the authentication token verification definition is configured to support a single-device login feature, and the first cache data and the second cache data already exist in the distributed cache, the first cache data is updated, the second cache data is deleted, and new second cache data is generated and stored in the distributed cache.
9. A microservice gateway, characterized in that: The microservice gateway includes: at least one memory and at least one processor; the memory stores an application, the processor calls the application stored in the memory, and the application is used to implement the unified authentication method for the microservice gateway described in any one of claims 1-5.
10. A storage medium, characterized in that: The storage medium stores a computer program code, and when the computer program code is executed, the unified authentication method for the microservice gateway according to any one of claims 1 to 5 is implemented.
