Authentication management method and device, equipment, storage medium and product
By storing and resending the request parameters after the invalid token in the microservice gateway, the business request loss problem caused by token expiration is solved, and the user experience and operational continuity is improved.
Patent Information
- Application Number
- CN202411273119.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-06
AI Technical Summary
Under the microservice architecture, when the user stays on the page for a long time and does not operate, the token expires, causing the server to respond abnormally, resulting in the user's pending service request information lost when logging in again.
After the microservice gateway receives the invalid access token and refresh token, the request parameters of the original business request are stored and the parameters are resent after the user authentication is successful, allowing the browser to rebuild and resend the same business request, avoiding the The user re-entered the request parameters.
Ensure that users can continue their previous operations, improve user experience, avoid frequent user interactions, and prevent the loss of requested information after the token expires.
Smart Images

Figure CN119094214A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular, relates to an authentication management method, device, equipment, storage medium and product. Background Art
[0002] When using a browser, users often need to obtain authorization from the server and then use the token issued by the server to access service resources in the browser. In a microservice architecture, tokens are generally verified by the microservice gateway and are responsible for their lifecycle management. For access security, the microservice gateway manages the validity period of the token. The client can only legally access backend service resources with the token within the validity period of the token. After each legal access by the client, the microservice gateway will extend the validity period of the token. If the client uses an expired token to access the server, it will receive an exception response from the server indicating that the token has expired.
[0003] In some scenarios, users will stay on a page for a long time without performing any operation (such as a large-screen page). When the user performs business operations, the server will respond with an exception of token expiration, which reduces the user experience.
[0004] In the prior art, users usually apply to the microservice gateway to obtain access tokens and refresh tokens. In subsequent business requests, if the token is detected to be expired, the client will use the refresh token to request a new token from the gateway to maintain session continuity. However, if the refresh token is also invalid, the user needs to log in again, and the request information submitted by the user for the pending business will be lost. Summary of the invention
[0005] The embodiments of the present application provide an authentication management method, apparatus, device, storage medium and product to solve the problem that when a user accesses service resources in a browser and a refresh token expires, the request information submitted for the pending business will be lost when the user logs in again.
[0006] In a first aspect, an embodiment of the present application provides an authentication management method, which is applied to a microservice gateway, and the method includes:
[0007] Receiving a first service request carrying a first access token sent by a browser, wherein the first service request is used to request service data of a service to be processed;
[0008] When the state of the first access token is invalid, storing the request parameters of the first service request, and sending a first exception response to the browser;
[0009] receiving a refresh request carrying a first refresh token sent by the browser based on the first exception response, where the first refresh token is used to refresh the first access token;
[0010] When the state of the first refresh token is invalid, sending a second exception response to the browser;
[0011] receiving an authentication request carrying the first access token and sent by the browser based on the second abnormal response, wherein the authentication request is used to authenticate the user;
[0012] When the authentication request passes, the request parameters are sent to the browser, so that the browser uses the request parameters to send a second business request to the microservice gateway, where the second business request is used to request business data of the business to be processed.
[0013] In a first aspect, an embodiment of the present application provides an authentication management method, which is applied to a browser, and the method includes:
[0014] Sending a first business request carrying a first access token to the microservice gateway, where the first business request is used to request business data of the business to be processed;
[0015] Upon receiving a first abnormal response fed back by the microservice gateway based on the first business request, sending a refresh request carrying a first refresh token to the microservice gateway;
[0016] In the case of receiving a second abnormal response from the microservice gateway based on the refresh request feedback, sending an authentication request carrying a first access token to the microservice gateway, wherein the authentication request is used to request the microservice gateway to authenticate the user;
[0017] When the authentication request passes, receiving the request parameters sent by the microservice gateway, where the request parameters are the parameters of the first business request saved by the microservice gateway;
[0018] A second business request is sent to the microservice gateway using the request parameters, where the second business request is used to request business data of the business to be processed.
[0019] In a third aspect, an embodiment of the present application provides an authentication management device, which is applied to a microservice gateway, and the device includes:
[0020] A first receiving module, configured to receive a first service request carrying a first access token sent by a browser, wherein the first service request is used to request service data of a service to be processed;
[0021] a storage module, configured to store the request parameters of the first service request and send a first exception response to the browser when the state of the first access token is invalid;
[0022] A second receiving module, configured to receive a refresh request carrying a first refresh token sent by the browser based on the first abnormal response, where the first refresh token is used to refresh the first access token;
[0023] A first sending module, configured to send a second abnormal response to the browser when the state of the first refresh token is invalid;
[0024] A third receiving module is used to receive an authentication request carrying the first access token and sent by the browser based on the second abnormal response, wherein the authentication request is used to authenticate the user;
[0025] The second sending module is used to send the request parameters to the browser if the authentication request is passed, so that the browser uses the request parameters to send a second business request to the microservice gateway, and the second business request is used to request the business data of the business to be processed.
[0026] In a fourth aspect, an embodiment of the present application provides an authentication management device, applied to a browser, the device comprising:
[0027] A third sending module is used to send a first business request carrying a first access token to the microservice gateway, where the first business request is used to request business data of a business to be processed;
[0028] A fourth sending module is used to send a refresh request carrying a first refresh token to the microservice gateway when receiving a first abnormal response fed back by the microservice gateway based on the first business request;
[0029] A fifth sending module is used to send an authentication request carrying a first access token to the microservice gateway when receiving a second abnormal response from the microservice gateway based on the refresh request feedback, wherein the authentication request is used to request the microservice gateway to authenticate the user;
[0030] A fourth receiving module, used to receive the request parameters sent by the microservice gateway when the authentication request is passed, wherein the request parameters are the parameters of the first business request saved by the microservice gateway;
[0031] The sixth sending module is used to send a second business request to the microservice gateway using the request parameters, where the second business request is used to request business data of the business to be processed.
[0032] In a fifth aspect, an embodiment of the present application provides a terminal device, the device comprising: a processor and a memory storing computer program instructions;
[0033] When the processor executes the computer program instructions, the authentication management method of the first aspect or the second aspect is implemented.
[0034] In a sixth aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, an authentication management method as in the first aspect or the second aspect is implemented.
[0035] In a seventh aspect, an embodiment of the present application provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes an authentication management method such as the first aspect or the second aspect.
[0036] The authentication management method provided in the embodiment of the present application can retain the corresponding request parameters in the first business request when the microservice gateway receives the first business request sent by the browser if the first access token in the first business request is in an invalid state. When the first refresh token is also invalid and the re-authentication of the user is successful, the microservice gateway resends the request parameters back to the browser so that the browser can use the request parameters to rebuild the business request, that is, it can resend the second business request for the same pending business as requested by the first business request. It ensures that users can continue their previous operations and avoids the need for users to re-enter a large number of request parameters after the token expires. At the same time, it avoids frequent user interactions and improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0038] Figure 1 It is a schematic diagram of the interaction process of the authentication management method provided in the embodiment of the present application;
[0039] Figure 2 It is a structural diagram of the authentication management device provided in an embodiment of the present application;
[0040] Figure 3 is another structural diagram of the authentication management device provided in an embodiment of the present application;
[0041] Figure 4 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0043] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0044] In order to solve the problems of the prior art, the embodiments of the present application provide an authentication management method, apparatus, device, storage medium and product.
[0045] The following first introduces the authentication management method provided in the embodiment of the present application.
[0046] Figure 1 FIG. 1 is a schematic diagram showing an interactive process of an authentication management method provided by an embodiment of the present application. Figure 1 As shown, the method includes:
[0047] Step 101: The browser sends a first service request carrying a first access token to the microservice gateway, where the first service request is used to request service data of the service to be processed;
[0048] In this embodiment, the application scenario may be an online banking system, where users can access the system through a web browser to check account balances, transfers, etc. Or it may be an online shopping system, where users can access the system through a web browser to check orders, goods, etc.
[0049] The first access token is used to access the business data corresponding to the first business request in the microservice gateway. Taking the above online banking system as an example, the first business request may be to query the account balance, and the corresponding business data is the account balance; or the first business request may be to transfer money, and the corresponding business data is the payee and other data.
[0050] It should be noted that the information interaction between the browser and the microservice gateway needs to be forwarded through the front-end service. In other words, the browser needs to send the first business request to the front-end service, and the front-end service then forwards the first business request to the microservice gateway. Among them, the front-end service is used to provide the browser page so that the user can perform operations such as input.
[0051] Step 102: The microservice gateway receives a first service request carrying a first access token sent by a browser;
[0052] In this embodiment, the microservice gateway receives the first service request forwarded by the front-end service.
[0053] Step 103: When the state of the first access token is invalid, the microservice gateway stores the request parameters of the first business request and sends a first exception response to the browser;
[0054] In this embodiment, the microservice gateway stores a key-value pair of the first access token and a string, where the key is the first access token and the value is the string. The string is also stored in a key-value pair, where the key is the string and the value is the user information and validity period.
[0055] When the microservice gateway receives the first access token, the key-value pair corresponding to the first service gateway is queried, and the key-value pair is the string corresponding to the first access token. If there is no such key-value pair in the microservice gateway, the first access token has expired, that is, the status is invalid.
[0056] If the first access token is invalid, the request parameters of the first service request are stored, and an error code indicating that the first access token is invalid is sent to the browser.
[0057] Step 104: When the browser receives the first abnormal response fed back by the microservice gateway based on the first business request, the browser sends a refresh request carrying a first refresh token to the microservice gateway;
[0058] In this embodiment, the browser intercepts the first exception response and does not display the exception on the page. After the browser intercepts, it uses the pre-saved first refresh token as a parameter to send a refresh request to the microservice gateway, and calls the token refresh interface of the microservice gateway to obtain a new access token, so that the browser uses the new access token to resend the business request for the pending business amount.
[0059] Step 105: The microservice gateway receives a refresh request carrying a first refresh token sent by the browser based on the first exception response;
[0060] Step 106: When the state of the first refresh token is invalid, the microservice gateway sends a second exception response to the browser;
[0061] In this embodiment, if the status of the first refresh token is valid, the microservice gateway will renew the first refresh token, and then generate and return a new access token to the browser. After the browser receives the new access token, it will clear the local old access token (i.e., the first access token) and save the new access token. Then, the new access token will be used to initiate a business data request again.
[0062] Step 107: When the browser receives the second abnormal response from the microservice gateway based on the refresh request feedback, the browser sends an authentication request carrying the first access token to the microservice gateway;
[0063] In this embodiment, the browser intercepts the second abnormal response of the first refresh token expiration and jumps to the authentication page. The user enters the authentication information (user name, password) on the authentication page and initiates the authentication request again through the browser, wherein the authentication request contains the first access token. The authentication request is used by the microservice gateway to verify the user's identity.
[0064] Step 108: The microservice gateway receives the authentication request carrying the first access token sent by the browser based on the second exception response;
[0065] Step 109: When the authentication request passes, the microservice gateway sends the request parameters to the browser, so that the browser uses the request parameters to send a second service request to the microservice gateway;
[0066] Step 110: The browser sends a second service request to the microservice gateway using the request parameters;
[0067] In this embodiment, the microservice gateway verifies the authentication information. If the authentication fails, an error code indicating that the authentication failed is returned to the front end, allowing the user to resubmit the authentication information. If the authentication passes, the request parameters stored in step 103 are sent back to the browser.
[0068] After receiving the request parameters, the browser initiates a second service request again to obtain the service data of the service to be processed. Since the request parameters in the second service request are the same as those in the first service request, the user does not need to perform repeated operations on the browser again to continue to complete the same operation as the first service request, thereby improving the user experience.
[0069] As an example, when applied to an online banking system, the user's first service request is to check the balance. After the user initiates the balance query, if the first access token and the first refresh token are both invalid, the browser will actively send a second service request to obtain the balance information after the user re-authenticates, without the user having to go to the corresponding query page again and then manually click to query, thereby improving the user experience. Or when the user enters text for a related query, after the token expires, the query result can be directly obtained without entering the text again.
[0070] The authentication management method provided in the embodiment of the present application can retain the corresponding request parameters in the first business request when the microservice gateway receives the first business request sent by the browser if the first access token in the first business request is in an invalid state. When the first refresh token is also invalid and the re-authentication of the user is successful, the microservice gateway resends the request parameters back to the browser so that the browser can use the request parameters to rebuild the business request, that is, it can resend the second business request for the same pending business as requested by the first business request. It ensures that users can continue their previous operations and avoids the need for users to re-enter a large number of request parameters after the token expires. At the same time, it avoids frequent user interactions and improves the user experience.
[0071] The following first introduces the authentication management method applied to the microservice gateway provided by the embodiment of the present application.
[0072] In an embodiment of the present application, before receiving the first service request carrying the first access token sent by the browser, the method further includes:
[0073] Receiving a login request sent by the browser on a login page;
[0074] If the login request is verified successfully, generating the first access token and the first refresh token;
[0075] The first access token and the first refresh token are sent to the browser.
[0076] In this embodiment, after the microservice gateway receives the verified login information, it generates a first access token and sets the validity period of the first access token (for example, 30 minutes); generates a first refresh token and sets the validity period of the first refresh token. The first refresh token can be 2-10 times the validity period of the first access token. The first access token and the first refresh token are saved in redis in the form of keys, and the validity period of the keys is set as their validity periods, respectively, where redis is a key-value database for storing key-value pair data. The method of setting the validity period can be expressed in pseudo code as follows:
[0077] redisClient.set(token,User,time1);
[0078] redisClient.set(refresh_token,token,time2);
[0079] The pseudo code above means that token and refresh_token are saved in redis, and expiration times time1 and time2 are set for them.
[0080] return(token,refresh_token);
[0081] The above code indicates that after saving to redis, they will be returned to the front-end service. After the front-end service receives the token and refresh_token responded by the microservice gateway, it will forward them to the browser.
[0082] In this embodiment, a first access token and a first refresh token are generated by the microservice gateway and sent to the browser, so that the browser can request business data from the microservice gateway according to the first access token and the first refresh token.
[0083] In an embodiment of the present application, when the state of the first access token is invalid, storing the request parameters of the first service request includes:
[0084] When the state of the first access token is invalid, generating a character string for marking the first access token as invalid;
[0085] In the case where the lock corresponding to the first business request is obtained, determining a first request object for storing the request parameters, the lock being used to grant the microservice gateway permission to store the request parameters;
[0086] Associating and storing the request link and the request parameters in the first business request into the first request object;
[0087] The string and the first request object are associated and stored in the microservice gateway.
[0088] In this embodiment, the microservice gateway uses the first access token as a key to search for a string corresponding to the first access token from the key-value pair stored in step 103. If the corresponding string is not found, it means that the first access token has expired, that is, it is invalid. At this time, a string is generated to mark the first access token as invalid. The string can be composed of the prefix "expired_" and the token string. It should be noted that the string used to mark the first access token as invalid is different from the string stored in step 103.
[0089] A user can send multiple first business requests to the microservice gateway (asynchronous requests) from a front-end page at the same time. The URL address (i.e., request link) of each first business request corresponds to a different back-end microservice interface. In order to ensure the normal access of these asynchronous requests, it is necessary to save these asynchronous requests in an object request_obj (i.e., first request object) of Map data type, where its key is the URL of each request, and its value is the request parameter of each request. The request parameter is also a Map data structure, where its key is the parameter name, and its value is the parameter value of string array type. In order to ensure the normal access of asynchronous requests, asynchronous requests will concurrently operate the request_obj object, so it is necessary to lock the request_obj saved in redis to ensure the atomicity of the request_obj data operation. The lock here is a synchronization mechanism used to ensure that only one thread can perform a specific operation at the same time to prevent concurrency problems.
[0090] In addition, since all asynchronous requests are stored in a first request object, after the first request object is generated, subsequent asynchronous requests only need to obtain the first request object and store data in the first request object, without generating other request objects.
[0091] The business logic of the above process node can be expressed in pseudo code as follows:
[0092]
[0093]
[0094] In this embodiment, by saving the request parameters of the first service request when the first access token expires, the system can ensure that the service request will not be lost even when the access token expires temporarily, and can continue to process these requests after the access token is refreshed.
[0095] In an embodiment of the present application, when the authentication request is passed, sending the request parameter to the browser includes:
[0096] If the authentication request is successful, generate a second access token and a second refresh token;
[0097] Using the first access token to obtain the first request object, the request parameter is included in the first request object;
[0098] Convert the format of the first request object into a preset format to obtain a second request object;
[0099] The second access token, the second refresh token, and the second request object are sent to the browser.
[0100] In this embodiment, the microservice gateway verifies the authentication information. If the authentication fails, an error code indicating that the authentication failed is returned to the front end, and the user is asked to resubmit the authentication information. If the authentication passes, the request_obj object (i.e., the first request object) stored in redis is obtained through the first access token in the request, and converted into json format and returned to the front end together with the regenerated second access token and second refresh token. The request_obj object stored in redis is cleared asynchronously.
[0101] The business logic of this process node can be expressed in pseudo code as follows:
[0102]
[0103]
[0104] In this embodiment, not only can the user's authentication information be processed securely, but also the service request that was interrupted due to the token problem can be restored and continued after the authentication is successful. This helps to improve the user experience and ensure the continuity of the business process.
[0105] The following first introduces the authentication management method applied to the browser provided by the embodiment of the present application.
[0106] In an embodiment of the present application, before sending the first service request carrying the first access token to the microservice gateway, the method further includes:
[0107] Sending a login request to the microservice gateway;
[0108] Receive the first access token and the first refresh token fed back by the microservice gateway based on the login request.
[0109] In this embodiment, the user requests the login page from the front-end service through the browser, and the front-end service returns the HTML, CSS, and JS of the login page, and the JS contains the address information of the refresh interface of the first access token. The user submits the login information (for example: user name, password, etc.) on the login page, generates a login request, and then forwards it to the microservice gateway by the front-end service.
[0110] After the browser receives the first access token token and the first refresh token refresh_token forwarded by the front-end service, it saves them locally. The saving method can be expressed in pseudo code as follows:
[0111] localData.saveToken(token);
[0112] localData.saveRefreshToken(refresh_token);
[0113] The above code means that token and refresh_token are saved locally in the browser.
[0114] In this embodiment, the first access token and the first refresh token sent by the microservice gateway are received to request business data from the microservice gateway.
[0115] In an embodiment of the present application, when the authentication request passes, after receiving the request parameters sent by the microservice gateway, the method further includes:
[0116] The first access token and the first refresh token are deleted.
[0117] In this embodiment, after receiving the request parameters, the browser clears the first access token and the first refresh token stored locally.
[0118] In addition, the received request parameters (the second access token, the second refresh token, and the second request object) are then saved locally. The browser clearing and saving method can be expressed in pseudo code as follows:
[0119] localData.deleteToken();
[0120] localData.deleteRefreshToken();
[0121] localData.saveToken(token);
[0122] localData.saveRefreshToken(refresh_token);
[0123] localData.saveRequestObjJson(request_obj_json);
[0124] In this embodiment, by updating the first access token and the first refresh token stored in the browser, the latest access rights can be always stored in the browser.
[0125] In an embodiment of the present application, upon receiving the second abnormal response of the microservice gateway based on the refresh request feedback, sending an authentication request carrying a first access token to the microservice gateway includes:
[0126] When receiving a second abnormal response from the microservice gateway based on the refresh request feedback, redirecting the current page of the browser from the request page to the authentication page;
[0127] When receiving the authentication information input by the user through the authentication page, an authentication request carrying the first access token and the authentication information is sent to the microservice gateway.
[0128] In this embodiment, the browser intercepts the second abnormal response of the first refresh token expiration, saves the page address of the current first service locally, and then jumps to the authentication page. The pseudo code for saving the page address to the browser locally can be expressed as:
[0129] localData.savePageUrl(pageUrl);
[0130] The user enters authentication information (user name, password) on the authentication page and initiates an authentication request again through the browser. The browser will retrieve the first access token stored locally as a parameter in the authentication request.
[0131] In an embodiment of the present application, after redirecting the current page of the browser from the request page to the authentication page, the method further includes:
[0132] Saving the page address of the requested page;
[0133] In the case where the authentication request is passed, after receiving the request parameters sent by the microservice gateway, the method further includes:
[0134] A front-end resource request is sent to the page address, where the front-end resource request is used to obtain a request page for the first request service, and the request page is used to send the second service request to the microservice gateway.
[0135] In this embodiment, after receiving the front-end page (e.g., the page of service A), the browser retrieves the second request object stored locally, restores it to the request service parameters, and then initiates the back-end data request for the service to be processed again, i.e., the second service request. After completing the request, the second request object stored locally is cleared.
[0136] The business logic of this process node can be expressed in pseudo code as follows:
[0137]
[0138] In this embodiment, in this way, it can be ensured that only authenticated users can access business data, while maintaining a good user experience so that users will not lose the operation they are trying to perform during the authentication process.
[0139] like Figure 2 As shown, the embodiment of the present application also provides an authentication management device 200, which is applied to a microservice gateway, and the device includes:
[0140] A first receiving module 201 is used to receive a first service request carrying a first access token sent by a browser, wherein the first service request is used to request service data of a service to be processed;
[0141] The storage module 202 is used to store the request parameters of the first service request and send a first exception response to the browser when the state of the first access token is invalid;
[0142] A second receiving module 203 is used to receive a refresh request carrying a first refresh token sent by the browser based on the first abnormal response, where the first refresh token is used to refresh the first access token;
[0143] A first sending module 204, configured to send a second abnormal response to the browser when the state of the first refresh token is invalid;
[0144] A third receiving module 205 is used to receive an authentication request carrying the first access token and sent by the browser based on the second abnormal response, where the authentication request is used to authenticate the user;
[0145] The second sending module 206 is used to send the request parameters to the browser if the authentication request is passed, so that the browser uses the request parameters to send a second business request to the microservice gateway, and the second business request is used to request the business data of the business to be processed.
[0146] Optionally, the authentication management device 200 further includes:
[0147] A fifth receiving module, used to receive a login request sent by the browser on the login page;
[0148] A first generating module, configured to generate the first access token and the first refresh token if the login request is verified successfully;
[0149] A seventh sending module is used to send the first access token and the first refresh token to the browser.
[0150] Optionally, the storage module 202 includes:
[0151] A first generating submodule, configured to generate a character string for marking the first access token as invalid when the state of the first access token is invalid;
[0152] A first determination submodule is used to determine a first request object for storing the request parameters when a lock corresponding to the first business request is acquired, wherein the lock is used to grant the microservice gateway permission to store the request parameters;
[0153] A first storage submodule, used for associating and storing the request link and the request parameters in the first service request into the first request object;
[0154] The second storage submodule is used to associate the string with the first request object and store them in the microservice gateway.
[0155] Optionally, the second sending module 206 includes:
[0156] A second generation submodule, configured to generate a second access token and a second refresh token if the authentication request is passed;
[0157] A first acquisition submodule, configured to acquire the first request object using the first access token, wherein the request parameter is included in the first request object;
[0158] a conversion submodule, configured to convert the format of the first request object into a preset format to obtain a second request object;
[0159] The first sending submodule is used to send the second access token, the second refresh token and the second request object to the browser.
[0160] It should be noted that the authentication management device 200 is a device corresponding to the above-mentioned authentication management method applied to the microservice gateway. All implementation methods in the above-mentioned method embodiment are applicable to the embodiment of the device and can achieve the same technical effect.
[0161] like Figure 3As shown, the embodiment of the present application also provides an authentication management device 300, which is applied to a browser, and the device includes:
[0162] The third sending module 301 is used to send a first business request carrying a first access token to the microservice gateway, where the first business request is used to request business data of a business to be processed;
[0163] A fourth sending module 302 is configured to send a refresh request carrying a first refresh token to the microservice gateway upon receiving a first abnormal response fed back by the microservice gateway based on the first business request;
[0164] The fifth sending module 303 is used to send an authentication request carrying a first access token to the microservice gateway when receiving a second abnormal response fed back by the microservice gateway based on the refresh request, wherein the authentication request is used to request the microservice gateway to authenticate the user;
[0165] The fourth receiving module 304 is used to receive the request parameters sent by the microservice gateway when the authentication request is passed, and the request parameters are the parameters of the first business request saved by the microservice gateway;
[0166] The sixth sending module 305 is used to send a second business request to the microservice gateway using the request parameters, where the second business request is used to request business data of the business to be processed.
[0167] Optionally, the authentication management device 300 further includes:
[0168] An eighth sending module, used to send a login request to the microservice gateway;
[0169] The sixth receiving module is used to receive the first access token and the first refresh token fed back by the microservice gateway based on the login request.
[0170] Optionally, the authentication management device 300 is specifically used to:
[0171] The first access token and the first refresh token are deleted.
[0172] Optionally, the fifth sending module 303 includes:
[0173] A jump submodule, configured to jump the current page of the browser from the request page to the authentication page when receiving a second abnormal response from the microservice gateway based on the refresh request feedback;
[0174] The second sending submodule is used to send an authentication request carrying the first access token and the authentication information to the microservice gateway when receiving the authentication information entered by the user through the authentication page.
[0175] Optionally, the authentication management device 300 is specifically used to:
[0176] Saving the page address of the requested page; and
[0177] A front-end resource request is sent to the page address, where the front-end resource request is used to obtain a request page for the first request service, and the request page is used to send the second service request to the microservice gateway.
[0178] It should be noted that the authentication management device 300 is a device corresponding to the above-mentioned authentication management method applied to the browser. All implementation methods in the above-mentioned method embodiment are applicable to the embodiment of the device and can achieve the same technical effect.
[0179] Figure 4 A schematic diagram of the hardware structure of a terminal device provided in an embodiment of the present application is shown.
[0180] The terminal device may include a processor 401 and a memory 402 storing computer program instructions.
[0181] Specifically, the processor 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0182] The memory 402 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 402 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 402 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 402 is a non-volatile solid-state memory.
[0183] In certain embodiments, the memory 402 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage media device, an optical storage media device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0184] The processor 401 implements any one of the authentication management methods in the above embodiments by reading and executing computer program instructions stored in the memory 402 .
[0185] In one example, the terminal device may further include a communication interface 404 and a bus 410. Figure 4 As shown, the processor 401, the memory 402, and the communication interface 404 are connected via a bus 410 and communicate with each other.
[0186] The communication interface 404 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0187] Bus 410 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 410 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0188] In addition, in combination with the authentication management method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the authentication management methods in the above embodiment is implemented.
[0189] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0190] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0191] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0192] Aspects of the present disclosure are described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable authentication management device to produce a machine so that these instructions executed by the processor of the computer or other programmable authentication management device enable the implementation of the functions / actions specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0193] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. An authentication management method, It is characterized in that Applied to a microservice gateway, the method includes: Receiving a first service request carrying a first access token sent by a browser, wherein the first service request is used to request service data of a service to be processed; When the state of the first access token is invalid, storing the request parameters of the first service request, and sending a first exception response to the browser; receiving a refresh request carrying a first refresh token sent by the browser based on the first exception response, where the first refresh token is used to refresh the first access token; When the state of the first refresh token is invalid, sending a second exception response to the browser; receiving an authentication request carrying the first access token and sent by the browser based on the second abnormal response, wherein the authentication request is used to authenticate the user; When the authentication request passes, the request parameters are sent to the browser, so that the browser uses the request parameters to send a second business request to the microservice gateway, where the second business request is used to request business data of the business to be processed.
2. The authentication management method according to claim 1, It is characterized in that Before receiving the first service request carrying the first access token sent by the browser, the method further includes: Receiving a login request sent by the browser on a login page; If the login request is verified successfully, generating the first access token and the first refresh token; The first access token and the first refresh token are sent to the browser.
3. The authentication management method according to claim 1, It is characterized in that The storing the request parameters of the first service request when the state of the first access token is invalid includes: When the state of the first access token is invalid, generating a character string for marking the first access token as invalid; In the case where the lock corresponding to the first business request is obtained, determining a first request object for storing the request parameters, the lock being used to grant the microservice gateway permission to store the request parameters; Associating and storing the request link and the request parameters in the first business request into the first request object; The string and the first request object are associated and stored in the microservice gateway.
4. The authentication management method according to claim 3, It is characterized in that When the authentication request is passed, sending the request parameter to the browser includes: If the authentication request is successful, generate a second access token and a second refresh token; Using the first access token to obtain the first request object, the request parameter is included in the first request object; Convert the format of the first request object into a preset format to obtain a second request object; The second access token, the second refresh token, and the second request object are sent to the browser.
5. An authentication management method, It is characterized in that Applied to a browser, the method comprises: Sending a first business request carrying a first access token to the microservice gateway, where the first business request is used to request business data of the business to be processed; Upon receiving a first abnormal response fed back by the microservice gateway based on the first business request, sending a refresh request carrying a first refresh token to the microservice gateway; In the case of receiving a second abnormal response from the microservice gateway based on the refresh request feedback, sending an authentication request carrying a first access token to the microservice gateway, wherein the authentication request is used to request the microservice gateway to authenticate the user; When the authentication request passes, receiving the request parameters sent by the microservice gateway, where the request parameters are the parameters of the first business request saved by the microservice gateway; A second business request is sent to the microservice gateway using the request parameters, where the second business request is used to request business data of the business to be processed.
6. The authentication management method according to claim 5, It is characterized in that Before sending the first service request carrying the first access token to the microservice gateway, the method further includes: Sending a login request to the microservice gateway; Receive the first access token and the first refresh token fed back by the microservice gateway based on the login request.
7. The authentication management method according to claim 6, It is characterized in that In the case where the authentication request is passed, after receiving the request parameters sent by the microservice gateway, the method further includes: The first access token and the first refresh token are deleted.
8. The authentication management method according to claim 5, It is characterized in that The method of, in the case of receiving a second abnormal response from the microservice gateway based on the refresh request feedback, sending an authentication request carrying a first access token to the microservice gateway, comprises: When receiving a second abnormal response from the microservice gateway based on the refresh request feedback, redirecting the current page of the browser from the request page to the authentication page; When receiving the authentication information input by the user through the authentication page, an authentication request carrying the first access token and the authentication information is sent to the microservice gateway.
9. The authentication management method according to claim 8, It is characterized in that After redirecting the current page of the browser from the request page to the authentication page, the method further includes: Saving the page address of the requested page; In the case where the authentication request is passed, after receiving the request parameters sent by the microservice gateway, the method further includes: A front-end resource request is sent to the page address, where the front-end resource request is used to obtain a request page for the first request service, and the request page is used to send the second service request to the microservice gateway.
10. An authentication management device, It is characterized in that Applied to a microservice gateway, the device comprises: A first receiving module, configured to receive a first service request carrying a first access token sent by a browser, wherein the first service request is used to request service data of a service to be processed; a storage module, configured to store the request parameters of the first service request and send a first exception response to the browser when the state of the first access token is invalid; A second receiving module, configured to receive a refresh request carrying a first refresh token sent by the browser based on the first abnormal response, where the first refresh token is used to refresh the first access token; A first sending module, configured to send a second abnormal response to the browser when the state of the first refresh token is invalid; A third receiving module is used to receive an authentication request carrying the first access token and sent by the browser based on the second abnormal response, wherein the authentication request is used to authenticate the user; The second sending module is used to send the request parameters to the browser if the authentication request is passed, so that the browser uses the request parameters to send a second business request to the microservice gateway, and the second business request is used to request the business data of the business to be processed.
11. An authentication management device, It is characterized in that Applied to a browser, the device comprises: A third sending module is used to send a first business request carrying a first access token to the microservice gateway, where the first business request is used to request business data of a business to be processed; A fourth sending module is used to send a refresh request carrying a first refresh token to the microservice gateway when receiving a first abnormal response fed back by the microservice gateway based on the first business request; A fifth sending module is used to send an authentication request carrying a first access token to the microservice gateway when receiving a second abnormal response from the microservice gateway based on the refresh request feedback, wherein the authentication request is used to request the microservice gateway to authenticate the user; A fourth receiving module, used to receive the request parameters sent by the microservice gateway when the authentication request is passed, wherein the request parameters are the parameters of the first business request saved by the microservice gateway; The sixth sending module is used to send a second business request to the microservice gateway using the request parameters, where the second business request is used to request business data of the business to be processed.
12. A terminal device, It is characterized in that The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the authentication management method as described in any one of claims 1-9 is implemented.
13. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the authentication management method according to any one of claims 1 to 9 is implemented.
14. A computer program product, It is characterized in that The computer product comprises a computer program, and when the computer program is executed by a processor, the authentication management method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Authentication method and authentication device for user request
CN104980925A
Resource access control method and device, equipment and storage medium
CN112003852A
Security authentication method, system and device based on gateway Token and medium
CN115589295A
Network request cache retransmission method and device, equipment and storage medium
CN116723242A
Unified identity authentication method and device
CN118118227A
