User login method, device and equipment, readable storage medium and program product
The login process of the third-party system is uniformly managed through the gateway server, and the cache token is used to achieve flexible docking between the business system and the third-party system, solving the problem of low docking flexibility in the existing technology, improving convenience and user login efficiency.
Patent Information
- Application Number
- CN202411127937.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-15
AI Technical Summary
In the prior art, the business system needs to be connected to a third-party system, which leads to low flexibility and the inability to effectively improve the convenience and efficiency of the docking.
Receive service requests through the gateway server, obtain the third-party user account, query the cached token, and send a login request to the user management server. After successful, store the token and route it to the application server to achieve unified login, and Reuse tokens within a specified time to reduce the need for reacquisition.
It improves the flexibility and convenience of business systems connecting with third-party systems, simplifies the login process, improves user login efficiency, and avoids the need for third-party systems to develop login functions separately.
Smart Images

Figure CN118972134A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a user login method, device, equipment, readable storage medium and program product. Background Art
[0002] With the development of computer technology and Internet technology, more and more business systems can be connected with third-party systems and provide services to third-party systems. Third-party system users can send service requests to the gateway server, which will be routed to the corresponding application server in the business system. After the application server executes the service request and obtains response data, the gateway server can return the response data to the third-party system.
[0003] When a third-party system user sends a service request to request the business system to provide a service, he needs to log in and can only obtain response data when logged in. However, in related technologies, in order to achieve docking with the business system, the third-party system needs to develop a login function for the business system, resulting in low flexibility in the process of docking the business system with the third-party system. Summary of the invention
[0004] Based on this, it is necessary to provide a user login method, device, equipment, computer-readable storage medium and computer program product that can improve the flexibility of business systems connecting to third-party systems in response to the above technical problems.
[0005] In a first aspect, the present application provides a user login method, comprising:
[0006] In response to receiving the service request, obtaining a third-party user account carried in the service request;
[0007] Query the token corresponding to the third-party user account from the cache;
[0008] When the token is not found in the cache, sending a login request to the user management server to instruct the user management server to perform a login operation for the third-party user account;
[0009] Receiving a token returned by the user management server when the login is successful, and associating the returned token with the third-party user account and storing them in the cache;
[0010] In case the returned token is stored successfully, the service request is routed to the corresponding application server.
[0011] In one embodiment, the method further comprises:
[0012] When the token is successfully queried from the cache, refreshing the cache and reading the queried token from the cache;
[0013] Verifying the login status of the third-party user account according to the read token to obtain a first verification result;
[0014] When the first verification result indicates that the verification is successful, the service request is routed to the corresponding application server.
[0015] In one embodiment, verifying the login status of the third-party user account according to the read token to obtain a first verification result includes:
[0016] Parsing the queried token to obtain a parsing result;
[0017] When the parsing result indicates that the parsing of the read token is successful, it is determined that the third-party user account is in a valid login state, and a first verification result indicating successful verification is obtained.
[0018] In one embodiment, verifying the login status of the third-party user account according to the read token to obtain a first verification result includes:
[0019] Obtaining a login cache duration preconfigured in the gateway server, wherein the preconfigured login cache duration is less than a login cache duration preconfigured in the business system;
[0020] Get the current cache duration of the token read;
[0021] When the current cache duration is less than the preconfigured login cache duration, it is determined that the third-party user account is in a valid login state, and a first verification result indicating successful verification is obtained.
[0022] In one embodiment, the method further comprises:
[0023] When the first verification result indicates that the verification fails, deleting the read token from the cache;
[0024] Send a login request to the user management server;
[0025] The login request carries the third-party user account, and is used to instruct the user management server to perform a login operation for the third-party user account.
[0026] In one embodiment, when the returned token is successfully stored, routing the service request to the corresponding application server includes:
[0027] In the case where the returned token is successfully stored, verifying the service request to obtain a second verification result;
[0028] If the second verification result indicates that the verification is successful, routing the service request to the corresponding application server;
[0029] Receive response data returned by the application server, encrypt the response data and then send it to the requester of the service request.
[0030] In one embodiment, in one embodiment, in response to receiving the service request, obtaining the third-party user account carried in the service request includes:
[0031] In response to receiving the service request, determining a login configuration state of the gateway server for the third-party system;
[0032] When the login configuration state is in an open state, obtaining a third-party user account carried in the service request;
[0033] The method further comprises:
[0034] When the login configuration state is in a closed state, detecting whether the service request carries a token;
[0035] When the token is not detected, a prompt message indicating that the request failed is returned to the requester of the service request.
[0036] In a second aspect, the present application also provides a user login device, comprising:
[0037] A request response module, configured to, in response to receiving a service request, obtain a third-party user account carried in the service request;
[0038] A token query module, used to query the token corresponding to the third-party user account from the cache;
[0039] A login request sending module, configured to send a login request to a user management server when the token is not found in the cache, so as to instruct the user management server to perform a login operation for the third-party user account;
[0040] A token storage module, used for receiving a token returned by the user management server when the login is successful, and storing the returned token in the cache in association with the third-party user account;
[0041] The request routing module is used to route the service request to the corresponding application server when the returned token is successfully stored.
[0042] In one of the embodiments, the device also includes a login status verification module, which is used to: when the token is successfully queried from the cache, refresh the cache and read the queried token from the cache; verify the login status of the third-party user account according to the read token to obtain a first verification result; when the first verification result indicates that the verification is successful, route the service request to the corresponding application server.
[0043] In one of the embodiments, the login status verification module is further used to: parse the queried token to obtain a parsing result; when the parsing result indicates that the read token is parsed successfully, determine that the third-party user account is in a valid login state, and obtain a first verification result indicating a successful verification.
[0044] In one of the embodiments, the login status verification module is also used to: obtain the login cache duration preconfigured in the gateway server, the preconfigured login cache duration is less than the login cache duration preconfigured in the business system; obtain the current cache duration of the token read; when the current cache duration is less than the preconfigured login cache duration, determine that the third-party user account is in a valid login state, and obtain a first verification result indicating that the verification is successful.
[0045] In one of the embodiments, the login status verification module is also used to: when the first verification result indicates that the verification failed, delete the read token from the cache; send a login request to the user management server; the login request carries the third-party user account, and is used to instruct the user management server to perform a login operation for the third-party user account.
[0046] In one of the embodiments, the request routing module is also used to: when the returned token is stored successfully, verify the service request to obtain a second verification result; when the second verification result indicates that the verification is successful, route the service request to the corresponding application server; receive response data returned by the application server, encrypt the response data and send it to the requester of the service request.
[0047] In one of the embodiments, the request response module is also used to: in response to receiving a service request, determine the login configuration status of the gateway server for the third-party system; when the login configuration status is in an on state, obtain the third-party user account carried in the service request; when the login configuration status is in a off state, detect whether the service request carries a token; when no token is detected, return a prompt message of request failure to the requester of the service request.
[0048] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned user login method when executing the computer program.
[0049] In a fourth aspect, the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned user login method are implemented.
[0050] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned user login method when executed by a processor.
[0051] In the above-mentioned user login method, apparatus, computer equipment, computer-readable storage medium and computer program product, the gateway server can, in response to receiving a service request, obtain the third-party user account carried in the service request, query the token corresponding to the third-party user account from the cache, and when the token is not queried from the cache, send a login request to the user management server to instruct the user management server to perform a login operation for the third-party user account, so that the gateway server can uniformly implement the login of the third-party system, without the need for the third-party system to develop and implement the login function separately, thereby improving the flexibility and convenience of the business system docking with the third-party system. Further, the gateway server can also receive the token returned by the user management server when the login is successful, associate the returned token with the third-party user account and store it in the cache. When the returned token is successfully stored, the service request is routed to the corresponding application server, so that the gateway server can maintain the login cache. Within a specified time range, the same account can reuse the cached token without having to re-acquire it, further improving the flexibility and convenience of the business system docking with the third-party system, and at the same time improving the user login efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0053] FIG1 is an application environment diagram of a user login method in one embodiment;
[0054] FIG2 is a schematic diagram of a flow chart of a user login method in one embodiment;
[0055] FIG3 is a flow chart of a login status verification step in one embodiment;
[0056] FIG4 is a schematic diagram of a process for routing a service request in one embodiment;
[0057] Figure 5 A schematic diagram of a flow chart of a user login method in another embodiment;
[0058] Figure 6 A flowchart of a user login method in another embodiment;
[0059] Figure 7 is a structural block diagram of a user login device in one embodiment;
[0060] FIG8 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. It should be noted that in the embodiments of the present application, certain software, groups, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0062] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations. The acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with relevant provisions of national laws and regulations.
[0063] The user login method provided in the embodiment of the present application can be applied in the application environment shown in FIG1 . Among them, the terminal 102 communicates with the gateway server 104 through the network, and the gateway server 104 communicates with the user management server 106 and the application server 108 through the network. The gateway server can respond to the service request sent by the terminal, obtain the third-party user account carried in the service request, query the token corresponding to the third-party user account from the cache, and when the token is not queried from the cache, send a login request to the user management server to instruct the user management server to perform a login operation for the third-party user account. The gateway server can further receive the token returned by the user management server when the login is successful, associate the returned token with the third-party user account and store it in the cache, and when the returned token is successfully stored, route the service request to the corresponding application server.
[0064] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The gateway server 104, the user management server 106, and the application server 108 may be independent physical servers, or server clusters or distributed systems consisting of multiple physical servers, or cloud servers that provide cloud computing services.
[0065] In an exemplary embodiment, as shown in FIG. 2 , a user login method is provided, which is described by taking the method applied to the gateway server 104 in FIG. 1 as an example, and includes the following steps 202 to 210. Among them:
[0066] Step 202: in response to receiving the service request, obtain a third-party user account carried in the service request.
[0067] The service request is a request for requesting the business system to provide a service. In different application scenarios, the service requested by the service request may be different services, and this application does not limit this. The third-party user account is a user account assigned to the third-party system by the business system.
[0068] Specifically, when the terminal needs to request a service from an application server in the business system, it can send a service request to the application server. The service request only needs to carry the third-party user account assigned by the business system. The service request will first be sent to the gateway server. After receiving the service request, the gateway server will parse the service request and obtain the third-party user account from the service request.
[0069] For example, the gateway server can be spring cloud gateway, which is a Spring Boot-based
[0070] 2.X designed API gateway. It provides rich gateway functions such as routing, filtering, current limiting, and circuit breaking, and supports clustering, high availability, and flexible configuration. Spring Boot is a new framework provided by the Pivotal team. Its design purpose is to simplify the initialization and development process of new Spring applications.
[0071] Step 204: query the cache for a token corresponding to the third-party user account.
[0072] The token is a string of characters generated by the server, which can be used as an authentication token for client requests. After logging in, the server generates a token, which can be used to make subsequent requests without having to log in again with the username and password each time. If the token is incorrect or there is no token, the request fails.
[0073] Specifically, if the user of the third-party system is currently logged in, the token corresponding to the third-party user account of the third-party system will be stored in the cache of the gateway server. Therefore, after receiving the service request, the gateway server can query the cache whether there is a token corresponding to the third-party user account. If the token corresponding to the third-party user account can be found, the service request can be directly routed to the corresponding application server without logging in again.
[0074] Step 206: When no token is found in the cache, a login request is sent to the user management server to instruct the user management server to perform a login operation for the third-party user account.
[0075] Specifically, if the gateway server fails to retrieve the token corresponding to the third-party user account from the cache, it means that the third-party system has not been logged in or the cached token has expired. At this time, the gateway server can generate a login request based on the third-party user account, carry the third-party account in the login request, and the gateway server further sends the login request to the user management server.
[0076] The user management server is a server used to manage users of the business system. The user management server stores the user account and login password of each user in the business system. After receiving a login request, the user management server can parse the login request and obtain the third-party user account carried therein. Then, the corresponding login password can be queried based on the third-party user account. Then, the login operation can be performed based on the third-party user account and login password. If the login is successful, the user management server can generate a token and return the token to the gateway server.
[0077] Exemplarily, the user management server can randomly generate a string as a token. In some other embodiments, the user management server can perform a hash calculation on the third-party user account and use the calculated hash value as the token. This application does not limit the method for generating the token.
[0078] Step 208: Receive a token returned by the user management server when the login is successful, and associate the returned token with the third-party user account and store it in a cache.
[0079] Specifically, after receiving the token returned by the user management server, the gateway server may associate the token with the third-party user account carried in the service request and store it in the cache.
[0080] For example, when a service request carrying the third-party user account is received again, the token corresponding to the third-party user account can be queried from the cache, thereby eliminating the need to log in using the third-party user account and password again, and the service request can be directly routed to the corresponding application server.
[0081] Step 210: If the returned token is successfully stored, the service request is routed to the corresponding application server.
[0082] Specifically, when the gateway server successfully stores the returned token, it can route the service request to the corresponding application server. After receiving the service request, the application server can execute the service request to obtain response data and return the response data to the gateway server, so that the gateway server can return the response data to the terminal.
[0083] Exemplarily, when the returned token is successfully stored, the gateway server may also verify the service request, and the verification method may be pre-configured. Optionally, the gateway server may perform at least one of the following verifications on the service request: authority resource verification, content type verification, request header verification, etc.
[0084] In the above user login method, the gateway server can respond to receiving a service request, obtain the third-party user account carried in the service request, query the token corresponding to the third-party user account from the cache, and when the token is not queried from the cache, send a login request to the user management server to instruct the user management server to perform a login operation for the third-party user account, so that the gateway server can uniformly implement the login of the third-party system, without the need for the third-party system to develop and implement the login function separately, thereby improving the flexibility and convenience of the business system connecting to the third-party system. Further, the gateway server can also receive the token returned by the user management server when the login is successful, and store the returned token in the cache in association with the third-party user account. When the returned token is successfully stored, the service request is routed to the corresponding application server, so that the gateway server can maintain the login cache. Within a specified time range, the same account can reuse the cached token without having to re-acquire it, further improving the flexibility and convenience of the business system connecting to the third-party system, and at the same time improving the user login efficiency.
[0085] It is understandable that in actual applications, when the gateway server queries the token corresponding to the third-party user account from the cache, there may be a situation where the token is queried. In this case, the cached token can be used directly without logging in again. Based on this, in one of the exemplary embodiments, as shown in FIG3 , the user login method of the present application also includes a login status verification step, which specifically includes:
[0086] Step 302: When a token is successfully queried from the cache, the cache is refreshed and the queried token is read from the cache.
[0087] Specifically, when a third-party user account has already logged in, when the gateway server queries the token corresponding to the third-party user account from the cache, it can successfully query the token corresponding to the third-party user account. When the token corresponding to the third-party user account is successfully queried from the cache, the gateway server can refresh the cache and read the token corresponding to the third-party user account from the cache.
[0088] Step 304: Verify the login status of the third-party user account according to the read token to obtain a first verification result.
[0089] Among them, verifying the login status of the third-party user account refers to verifying the validity of the login status of the third-party user account to enhance the security and robustness of the login process.
[0090] Specifically, after reading the token corresponding to the third-party user account, the gateway server can verify the login status of the third-party user account based on the token to obtain a first verification result. The first verification result may be a verification result indicating a successful verification, indicating that the login status of the third-party user account is valid, or the first verification result may be a verification result indicating a failed verification, indicating that the third-party user account is not in a logged-in state, or the login status is an invalid login status.
[0091] In this application, the gateway service performs unified login and maintains the login cache, and there is no need for a third-party system to be developed separately. The process details of the unified login process, that is, the verification items for verifying the login status of the third-party user account, can be highly customized, for example:
[0092] In an exemplary embodiment, verifying the login status of the third-party user account according to the read token to obtain a first verification result includes:
[0093] The queried token is parsed to obtain a parsing result; when the parsing result indicates that the parsing of the read token is successful, it is determined that the third-party user account is in a valid login state, and a first verification result indicating a successful verification is obtained.
[0094] In this embodiment, it is also possible to additionally check whether the cached token can be parsed normally. If the token can be parsed successfully, the third-party user account is in a valid login state, so that a first verification result indicating successful verification can be obtained. If the token parsing fails, the token in the cache can be deleted and the login can be re-enrolled, thereby enhancing the robustness of the login process.
[0095] In an exemplary embodiment, verifying the login status of the third-party user account according to the read token to obtain a first verification result includes:
[0096] Obtain the preconfigured login cache duration in the gateway server, which is smaller than the preconfigured login cache duration in the business system; obtain the current cache duration of the read token; when the current cache duration is smaller than the preconfigured login cache duration, determine that the third-party user account is in a valid login state, and obtain a first verification result indicating successful verification.
[0097] The login cache duration is used to characterize the duration of the validity of the login status. Within this duration, the token can be used directly without logging in. If this duration is exceeded, the token expires and you need to log in again. The login cache duration can be configured as needed. This login cache duration is slightly shorter than the login cache duration of the business system to avoid the problem that the business system token is invalid but the gateway server has not been re-logged in.
[0098] Specifically, the gateway server can compare the preconfigured login cache duration with the current cache duration of the token corresponding to the read third-party user account. If the current cache duration of the token corresponding to the read third-party user account is less than the preconfigured login cache duration in the gateway server, it can be determined that the third-party user account is in a valid login state, and a first verification result indicating a successful verification is obtained.
[0099] It is understandable that if the current cache duration of the token corresponding to the third-party user account read is greater than the login cache duration preconfigured in the gateway server, it can be determined that the login status of the third-party user account is invalid, and a verification result indicating verification failure is obtained.
[0100] Step 306: When the first verification result indicates that the verification is successful, the service request is routed to the corresponding application server.
[0101] Specifically, when the first verification result indicates that the verification is successful, the gateway server can determine that the login status of the third-party user account is valid at this time, and there is no need to log in again, and the service request can be further routed to the corresponding application server.
[0102] In the above embodiment, since the login status of the third-party user account can be verified based on the read token to obtain a first verification result, when the first verification result indicates that the verification is successful, the service request is routed to the corresponding application server, which can enhance the security and robustness of the login process.
[0103] In an exemplary embodiment, the user login method of the present application further includes:
[0104] When the first verification result indicates that the verification fails, the read token is deleted from the cache; a login request is sent to the user management server; the login request carries a third-party user account, which is used to instruct the user management server to perform a login operation for the third-party user account.
[0105] Specifically, the first verification result indicates that the verification failed, indicating that the third-party user account is not in a logged-in state, or the logged-in state is an invalid login state. Optionally, when the parsing result obtained by parsing the queried token indicates that the parsing of the read token failed, the first verification result indicating the verification failed is obtained. Optionally, when the current cache duration of the read token is greater than the login cache duration preconfigured in the gateway server, the first verification result indicating the verification failed is obtained.
[0106] Specifically, when the first verification result obtained by the gateway server indicates that the verification has failed, the gateway server may delete the read token from the cache, and carry the third-party account in the login request, and the gateway server further sends the login request to the user management server. After receiving the login request, the user management server may parse the login request, obtain the third-party user account carried therein, and then query the corresponding login password based on the third-party user account, and then perform the login operation based on the third-party user account and login password. Exemplarily, in the case of successful login, the user management server may regenerate the token and return the regenerated token to the gateway server, and the gateway server may cache the regenerated token.
[0107] In the above embodiment, when the first verification result indicates that the verification has failed, the cache can be deleted, which can save storage space on the one hand and save token query efficiency on the other hand. Furthermore, since a login request can be sent to the user management server, the login process can be uniformly implemented by the gateway server, avoiding the independent development of a third-party system, thereby improving the flexibility of the user login process.
[0108] In an exemplary embodiment, as shown in FIG4 , when the returned token is successfully stored, routing the service request to the corresponding application server includes:
[0109] Step 402: When the returned token is successfully stored, the service request is verified to obtain a second verification result.
[0110] Specifically, when the gateway server successfully stores the returned token, it can also verify the service request sent by the terminal to obtain a second verification result, which can be a verification result indicating successful verification or a verification result indicating successful verification.
[0111] Among them, the verification method for verifying the service request can be set as needed. Optionally, the gateway server can perform at least one verification of the service request, such as authority resource verification, content type verification, and request header verification.
[0112] Step 404: When the second verification result indicates that the verification is successful, the service request is routed to the corresponding application server.
[0113] Step 406: Receive the response data returned by the application server, encrypt the response data and send it to the requester of the service request.
[0114] Specifically, when the second verification result indicates that the verification is successful, the gateway server can route the service request to the corresponding application server. After the application server executes the service request and obtains response data, the response data is returned to the application server. The application server can encrypt the response data and send it to the requester of the service request.
[0115] In this embodiment, since the service request can be verified and the response data can be encrypted, the security in the service request processing process can be improved.
[0116] In an exemplary embodiment, Figure 5 As shown, a user login method is provided, which is described by taking the method applied to the gateway server 104 in FIG. 1 as an example, and includes the following steps:
[0117] Step 502: In response to receiving the service request, determine the login configuration status of the gateway server for the third-party system.
[0118] Step 504: When the login configuration state is in the on state, obtain the third-party user account carried in the service request.
[0119] The login configuration state refers to the state of the unified login configured by the gateway server for third-party system users. The login configuration state includes two states: open and closed. In the open state, unified login is performed through the gateway server. In the closed state, login can be performed in the conventional way.
[0120] Specifically, considering that some third-party systems have developed login functions when connecting to business systems, in order to ensure that these third-party systems can be connected normally, the gateway server can configure whether to enable unified login for third-party system users, so that for these third-party systems that have developed login functions, login can be performed according to the normal login process. For third-party systems that have not developed login functions, the gateway server can perform unified login, so that they can be well compatible with these third-party systems that have developed login functions, further improving the flexibility of the user login process.
[0121] In this embodiment, after receiving the service request, the gateway server can first determine the login configuration status for the third-party system. If the login configuration status is in the on state, the third-party user account can be logged in uniformly to obtain the third-party user account carried in the service request and perform a token query from the cache.
[0122] In some other embodiments, for third-party systems that have developed login functions, the gateway server can also log in uniformly as needed, and it is only necessary to configure the login configuration state for the third-party system to be turned on.
[0123] Step 506: query the cache for a token corresponding to the third-party user account.
[0124] Step 508: When no token is found in the cache, a login request is sent to the user management server to instruct the user management server to perform a login operation for the third-party user account.
[0125] Step 510, receiving a token returned by the user management server when the login is successful, and associating the returned token with the third-party user account and storing it in a cache.
[0126] Step 512: If the returned token is successfully stored, the service request is routed to the corresponding application server.
[0127] Step 514: When the login configuration state is in the closed state, check whether the service request carries a token.
[0128] Step 516: When the token is not detected, a prompt message indicating that the request failed is returned to the requester of the service request.
[0129] Specifically, if the login configuration status is in the closed state, the third-party system user logs in through the conventional login method and needs to carry a token in the service request, so that the gateway server can detect whether the received service request carries a token. If it carries a token, the token can be verified and the service request can be verified. After the verification is successful, the service request is routed. If the token is not detected, a prompt message indicating that the request failed is returned to the requester of the service request.
[0130] In this embodiment, the gateway server can configure whether to enable unified login for third-party system users, further improving the flexibility and convenience of the business system connecting to the third-party system.
[0131] In a specific exemplary embodiment, Figure 6 As shown, a user login method is provided. This embodiment shows a specific implementation method for unified login of third-party system users when no token is found. Figure 6After the user sends the service request to the gateway server, the gateway server can store the request body of the service request in the cache, and then initiate a login request to the user management server with the third-party user account of the third-party system user. The user management server receives the login request and performs login authentication based on the third-party user account in the login request. After successful authentication, a token is generated and returned to the gateway server. After receiving the token, the gateway server can verify whether the token can be parsed normally. If not, the cache is deleted and the login is re-logged in to enhance the robustness of the login process. If it can be parsed normally, the gateway server further performs permission resource verification. If the permission resource verification is successful, the request header can be further filled, and then the content type and request header fields can be verified. After these are verified successfully, the request body can be decrypted, and the service request can be routed to the application server. After the application server executes the service request, it returns the response data to the gateway server. The gateway server encrypts the response data and returns it to the user. It can be understood that in specific applications, Figure 6 Each verification item and encryption operation of the gateway server can be customized, thus realizing a highly customized unified login solution for third-party system users.
[0132] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0133] Based on the same inventive concept, the embodiment of the present application also provides a user login device for implementing the user login method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more user login device embodiments provided below can refer to the limitations on the user login method above, and will not be repeated here.
[0134] In an exemplary embodiment, Figure 7 As shown, a user login device 700 is provided, comprising:
[0135] The request response module 702 is used to obtain the third-party user account carried in the service request in response to receiving the service request;
[0136] The token query module 704 is used to query the token corresponding to the third-party user account from the cache;
[0137] A login request sending module 706, configured to send a login request to a user management server when no token is found in the cache, so as to instruct the user management server to perform a login operation for a third-party user account;
[0138] The token storage module 708 is used to receive the token returned by the user management server when the login is successful, and associate the returned token with the third-party user account and store it in the cache;
[0139] The request routing module 710 is used to route the service request to the corresponding application server when the returned token is successfully stored.
[0140] The above-mentioned user login device, in response to receiving a service request, obtains the third-party user account carried in the service request, queries the token corresponding to the third-party user account from the cache, and when the token is not found from the cache, sends a login request to the user management server to instruct the user management server to perform a login operation for the third-party user account, so that the gateway server can uniformly implement the login of the third-party system, without the need for the third-party system to develop and implement the login function separately, thereby improving the flexibility and convenience of the business system connecting to the third-party system. It can further receive the token returned by the user management server when the login is successful, and store the returned token in the cache in association with the third-party user account. When the returned token is successfully stored, the service request is routed to the corresponding application server, so that the gateway server can maintain the login cache. Within a specified time range, the same account can reuse the cached token without having to re-acquire it, further improving the flexibility and convenience of the business system connecting to the third-party system, and at the same time improving the user login efficiency.
[0141] In an exemplary embodiment, the user login device of the present application also includes a login status verification module, which is used to: when a token is successfully queried from the cache, refresh the cache and read the queried token from the cache; verify the login status of the third-party user account according to the read token to obtain a first verification result; when the first verification result indicates that the verification is successful, route the service request to the corresponding application server.
[0142] In an exemplary embodiment, the login status verification module is also used to: parse the queried token to obtain a parsing result; when the parsing result indicates that the read token is parsed successfully, determine that the third-party user account is in a valid login state, and obtain a first verification result indicating that the verification is successful.
[0143] In an exemplary embodiment, the login status verification module is also used to: obtain the login cache time length preconfigured in the gateway server, the preconfigured login cache time length is less than the login cache time length preconfigured in the business system; obtain the current cache time length of the read token; when the current cache time length is less than the preconfigured login cache time length, determine that the third-party user account is in a valid login state, and obtain a first verification result indicating that the verification is successful.
[0144] In an exemplary embodiment, the login status verification module is also used to: when the first verification result indicates that the verification has failed, delete the read token from the cache; send a login request to the user management server; the login request carries a third-party user account, used to instruct the user management server to perform a login operation for the third-party user account.
[0145] In an exemplary embodiment, the request routing module is also used to: verify the service request and obtain a second verification result when the returned token is stored successfully; route the service request to the corresponding application server when the second verification result indicates that the verification is successful; receive response data returned by the application server, encrypt the response data and send it to the requester of the service request.
[0146] In an exemplary embodiment, the request response module is also used to: in response to receiving a service request, determine the login configuration status of the gateway server for the third-party system; when the login configuration status is in an on state, obtain the third-party user account carried in the service request; when the login configuration status is in a off state, detect whether a token is carried in the service request; when no token is detected, return a prompt message indicating that the request failed to the requester of the service request.
[0147] Each module in the above user login device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0148] In an exemplary embodiment, a computer device is provided, which may be a gateway server, and its internal structure diagram may be shown in FIG8. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device can be used to store data such as tokens and third-party user accounts. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the user login method provided in the embodiment of the present application is implemented.
[0149] Those skilled in the art will understand that the structure shown in FIG. 8 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0150] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned user login method when executing the computer program.
[0151] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the user login method described above are implemented.
[0152] In an exemplary embodiment, a computer program product is provided, including a computer program, which implements the steps of the above-mentioned user login method when executed by a processor.
[0153] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0154] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0155] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A user login method, characterized in that: Applied to a gateway server, the method comprises: In response to receiving the service request, obtaining a third-party user account carried in the service request; Query the token corresponding to the third-party user account from the cache; When the token is not found in the cache, sending a login request to the user management server to instruct the user management server to perform a login operation for the third-party user account; Receiving a token returned by the user management server when the login is successful, and associating the returned token with the third-party user account and storing them in the cache; In case the returned token is stored successfully, the service request is routed to the corresponding application server.
2. The method according to claim 1, characterized in that The method further comprises: When the token is successfully queried from the cache, refreshing the cache and reading the queried token from the cache; Verifying the login status of the third-party user account according to the token read to obtain a first verification result; When the first verification result indicates that the verification is successful, the service request is routed to the corresponding application server.
3. The method according to claim 2, characterized in that The step of verifying the login status of the third-party user account according to the read token to obtain a first verification result includes: Parsing the queried token to obtain a parsing result; When the parsing result indicates that the parsing of the read token is successful, it is determined that the third-party user account is in a valid login state, and a first verification result indicating a successful verification is obtained.
4. The method according to claim 2, characterized in that: The step of verifying the login status of the third-party user account according to the read token to obtain a first verification result includes: Obtaining a login cache duration preconfigured in the gateway server, wherein the preconfigured login cache duration is less than a login cache duration preconfigured in the business system; Get the current cache duration of the token read; When the current cache duration is less than the preconfigured login cache duration, it is determined that the third-party user account is in a valid login state, and a first verification result indicating successful verification is obtained.
5. The method according to claim 2, characterized in that: The method further comprises: When the first verification result indicates that the verification fails, deleting the read token from the cache; Send a login request to the user management server; The login request carries the third-party user account, and is used to instruct the user management server to perform a login operation for the third-party user account.
6. The method according to claim 1, characterized in that When the returned token is successfully stored, routing the service request to the corresponding application server includes: In the case where the returned token is successfully stored, verifying the service request to obtain a second verification result; If the second verification result indicates that the verification is successful, routing the service request to the corresponding application server; Receive response data returned by the application server, encrypt the response data and then send it to the requester of the service request.
7. The method according to any one of claims 1 to 6, characterized in that: The step of obtaining, in response to receiving the service request, a third-party user account carried in the service request includes: In response to receiving the service request, determining a login configuration state of the gateway server for the third-party system; When the login configuration state is in an open state, obtaining a third-party user account carried in the service request; The method further comprises: When the login configuration state is in a closed state, detecting whether the service request carries a token; When the token is not detected, a prompt message indicating that the request failed is returned to the requester of the service request.
8. A user login device, characterized in that: The device comprises: A request response module, configured to, in response to receiving a service request, obtain a third-party user account carried in the service request; A token query module, used to query the token corresponding to the third-party user account from the cache; A login request sending module, configured to send a login request to a user management server when the token is not found in the cache, so as to instruct the user management server to perform a login operation for the third-party user account; A token storage module, used for receiving a token returned by the user management server when the login is successful, and storing the returned token in the cache in association with the third-party user account; The request routing module is used to route the service request to the corresponding application server when the returned token is successfully stored.
9. The device according to claim 8, characterized in that The device further comprises a login status verification module, which is used to: when the token is successfully queried from the cache, refresh the cache and read the queried token from the cache; Verifying the login status of the third-party user account according to the read token to obtain a first verification result; When the first verification result indicates that the verification is successful, the service request is routed to the corresponding application server.
10. The device according to claim 9, characterized in that The login status verification module is also used to: parse the queried token to obtain a parsing result; when the parsing result indicates that the read token is parsed successfully, determine that the third-party user account is in a valid login state, and obtain a first verification result indicating a successful verification.
11. The device according to claim 9, characterized in that The login status verification module is further used to: obtain the login cache time length preconfigured in the gateway server, the preconfigured login cache time length is less than the login cache time length preconfigured in the business system; obtain the current cache time length of the token read; When the current cache duration is less than the preconfigured login cache duration, it is determined that the third-party user account is in a valid login state, and a first verification result indicating successful verification is obtained.
12. The device according to claim 9, characterized in that The login status verification module is further configured to: when the first verification result indicates that the verification fails, delete the read token from the cache; Send a login request to the user management server; The login request carries the third-party user account, and is used to instruct the user management server to perform a login operation for the third-party user account.
13. The device according to claim 8, characterized in that The request routing module is further used to: verify the service request in case that the returned token is successfully stored, and obtain a second verification result; If the second verification result indicates that the verification is successful, routing the service request to the corresponding application server; Receive response data returned by the application server, encrypt the response data and then send it to the requester of the service request.
14. The device according to any one of claims 8 to 13, characterized in that: The request response module is further used to: in response to receiving a service request, determine the login configuration state of the gateway server for the third-party system; when the login configuration state is in an open state, obtain the third-party user account carried in the service request; When the login configuration state is in a closed state, detecting whether the service request carries a token; When the token is not detected, a prompt message indicating that the request failed is returned to the requester of the service request.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Third party account login control method and user center platform
CN105871838A
Intelligent equipment business data obtaining method, device and system
CN106878353A
System login method and integrated login system
CN111147453A
Resource calling method, resource calling device, client and business server
CN111371811A
Device id-based login state sharing method and device
WO2020155492A1
