Authentication keep-alive implementation method and device, electronic equipment and medium

By using a Hash table on the server to save and query the keep-alive status corresponding to the user's IP address, the problem that cross-browser cannot obtain the authenticated warranty status is solved, and the cross-browser authentication warranty function is realized, ensuring the availability of the authenticated status and stability.

CN119182698AInactive Publication Date: 2024-12-24BEIJING ANBOTONG TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411676092.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2024-12-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, authentication warranty is unavailable after cross-browser or browser cache is cleaned, and authentication warranty cannot be obtained across browsers.

Method used

By using a Hash table on the server to save the keep-alive status corresponding to the user's IP address, query and update the keep-alive status based on the user's IP address, and return the corresponding authentication result page or login page to ensure the cross-browser availability of the authenticated warranty status.

Benefits of technology

It realizes the function of obtaining authentication warranty status across browsers without relying on browser cookies, avoiding the impact of browser cache cleaning. Users can query the warranty status through IP addresses and present different pages according to the results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119182698A_ABST
    Figure CN119182698A_ABST
Patent Text Reader

Abstract

The invention relates to an authentication keep-alive implementation method and device, electronic equipment and a medium, and belongs to the technical field of Internet, and the method comprises the following steps: receiving an access request sent by a browser, and obtaining a user IP address based on the access request; a corresponding keep-alive state is inquired in a preset hash table based on the user IP address, a key value in the hash table is used for storing the IP address, and a value value in the hash table is used for storing the keep-alive state; returning an authentication result page to the browser under the condition of determining that the user IP address has a corresponding keep-alive state in a preset hash table; and returning an authentication login page to the browser under the condition of determining that the corresponding keep-alive state of the user IP address does not exist in the preset hash table. According to the method, the authentication keep-alive state is stored in the hash table on the server and can be inquired through the IP address of the user, and the authentication keep-alive state can be obtained in a cross-browser mode and is not affected by browser cache cleaning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a method, device, electronic device and medium for implementing authentication keep-alive. Background Art

[0002] The main functions of browser cookies include session management, identity authentication, personalization, cross-page data transfer, maintaining login status, storing user preferences, tracking browsing behavior, implementing shopping cart functions, and providing personalized content. Among them, saving login status means that when a user logs in on a website, the website will store the user's login information in a cookie. In this way, the next time the user visits the website, the website can determine whether the user has logged in by reading the login information in the cookie, thereby maintaining the user's login status.

[0003] In the prior art, authentication keep-alive is to use the authenticated cookie to periodically send keep-alive interaction messages between the server and the browser after the user is successfully authenticated, so as to confirm whether both parties are in the authentication keep-alive state.

[0004] The keep-alive method of periodically sending interactive messages through the authenticated cookie can only query and implement the authentication keep-alive status in the same browser. It cannot be used across browsers or after the browser cache is cleared. Summary of the invention

[0005] In view of this, it is necessary to provide a method, device, electronic device and medium for implementing authentication keep-alive to solve the problem that cookies cannot be used across browsers or after the browser cache is cleared.

[0006] In order to solve the above problem, the present invention provides a method for implementing authentication keep-alive, comprising: Upon receiving an access request sent by a browser, determining the user IP address carried in the access request; Based on the user IP address, query the corresponding keep-alive status in a preset Hash table, where the key value in the Hash table is used to save the IP address, and the value in the Hash table is used to save the keep-alive status; When it is determined that the user IP address has a corresponding keep-alive status in the preset hash table, returning an authentication result page to the browser; When it is determined that the user IP address does not have a corresponding keep-alive status in the preset Hash table, an authentication login page is returned to the browser.

[0007] In a possible implementation, after determining that the user IP address does not have a corresponding keep-alive state in a preset hash table and returning an authentication login page to the browser, the method further includes: The user IP address and the corresponding target keep-alive status are stored in a preset Hash table, where the target keep-alive status is determined based on the user's login status on the authentication login page.

[0008] In a possible implementation, the target keep-alive state is determined based on the user's login state on the authentication login page, including: When the user successfully logs in on the authentication login page, the target keep-alive state is the keep-alive state; When the user fails to log in to the authentication login page, the target keep-alive state is a non-keep-alive state. In a possible implementation, the browser includes: One or more of Google Chrome, Firefox, IE, 360 Browser and Sogou Browser.

[0009] In a possible implementation, the value in the Hash table also includes online time, and when determining that the user IP address has a corresponding keep-alive status in the preset Hash table, returning the authentication result page to the browser also includes: In the hash table, the online time in the value is updated according to the key value being the user's IP address.

[0010] In a possible implementation, the preset Hash table is cleaned up regularly.

[0011] In a possible implementation, the periodically clearing the preset Hash table includes: The preset Hash table is cleaned up regularly based on the online time.

[0012] On the other hand, the present invention also provides a device for implementing authentication keep-alive, including: An access data acquisition module is used to determine the user IP address carried in the access request when receiving the access request sent by the browser; A keep-alive status query module, used to query the corresponding keep-alive status in a preset Hash table based on the user IP address, the key value in the Hash table is used to save the IP address, and the value in the Hash table is used to save the keep-alive status; The authentication result page return module is used to return the authentication result page to the browser when it is determined that the user IP address has a corresponding keep-alive status in the preset Hash table; The authentication login page module is used to return the authentication login page to the browser when it is determined that the user IP address does not have a corresponding keep-alive status in the preset Hash table.

[0013] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the authentication keep-alive implementation method described in any one of the above implementations.

[0014] On the other hand, the present invention also provides a computer-readable storage medium for storing computer-readable programs or instructions, which, when executed by a processor, can implement the steps in an authentication preservation implementation method described in any of the above-mentioned implementation methods.

[0015] The beneficial effects of the present invention are as follows: the present invention provides a method for implementing authentication keep-alive, firstly obtains the access request of the browser, determines the user IP address according to the access request, queries the corresponding keep-alive status in the preset Hash table based on the user IP address, the key value in the Hash table is used to save the IP address, the value in the Hash table is used to save the keep-alive status, and puts the keep-alive status accessed by the user into the Hash table on the server, so as not to rely on the Cookie in the browser, and returns the authentication result page to the user when it is determined that the user IP address has the corresponding keep-alive status in the preset Hash table, and returns the authentication login page to the user when it is determined that the user IP address does not have the corresponding keep-alive status in the preset Hash table. The present invention saves the authentication keep-alive status in the Hash table on the server, which can be queried by the user's IP address, and can obtain the authentication keep-alive status across browsers, and is not affected by clearing the browser cache. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A flowchart of an embodiment of a method for implementing authentication keep-alive provided by the present invention; Figure 2 A schematic flow chart of an embodiment of a device for implementing authentication keep-alive provided by the present invention; Figure 3 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0017] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.

[0018] The present invention provides a method, device, electronic device and medium for implementing authentication keep-alive, which are respectively described below.

[0019] Figure 1 A flow chart of an embodiment of a method for implementing authentication keep-alive provided by the present invention is as follows: Figure 1 As shown, the implementation method of authentication keep-alive includes: S101, upon receiving an access request sent by a browser, determining a user IP address carried in the access request; S102: querying a corresponding keep-alive status in a preset hash table based on the user IP address, where the key value in the hash table is used to store the IP address, and the value in the hash table is used to store the keep-alive status; S103, when it is determined that the user IP address has a corresponding keep-alive status in the preset hash table, returning an authentication result page to the browser; S104: When it is determined that the user IP address does not have a corresponding keep-alive status in the preset hash table, return an authentication login page to the browser.

[0020] Compared with the prior art, the present embodiment provides a method for implementing authentication keep-alive, firstly obtaining the access request of the browser, determining the user IP address according to the access request, querying the corresponding keep-alive status in a preset Hash table based on the user IP address, the key value in the Hash table is used to save the IP address, the value in the Hash table is used to save the keep-alive status, and putting the keep-alive status accessed by the user into the Hash table on the server, so as not to rely on the Cookie in the browser, and returning the authentication result page to the user when it is determined that the user IP address has the corresponding keep-alive status in the preset Hash table, and returning the authentication login page to the user when it is determined that the user IP address does not have the corresponding keep-alive status in the preset Hash table. The present invention saves the authentication keep-alive status in the Hash table on the server, which can be queried by the user's IP address, and can obtain the authentication keep-alive status across browsers, and is not affected by clearing the browser cache.

[0021] In some embodiments of the present invention, after determining that the user IP address does not have a corresponding keep-alive state in a preset hash table and returning an authentication login page to the browser, the method further includes: The user IP address and the corresponding target keep-alive status are stored in a preset Hash table, where the target keep-alive status is determined based on the user's login status on the authentication login page.

[0022] In some embodiments of the present invention, the target keep-alive state is determined based on the user's login state on the authentication login page, including: When the user successfully logs in on the authentication login page, the target keep-alive state is the keep-alive state; When the user fails to log in to the authentication login page, the target keep-alive state is a non-keep-alive state. In some embodiments of the present invention, the browser includes: One or more of Google Chrome, Firefox, IE, 360 Browser and Sogou Browser.

[0023] In a specific embodiment of the present invention, an IP Hash table of authentication results is defined in the back-end server to save the keep-alive status and perform keep-alive query for the front-end user. The specific code is as follows: +unsigned int sim_auth_ret_ip_hash(be32 ip) +{ +return jhash_1word(ip, 0) % sim_auth_ret_hash_size; +} When the front-end user accesses the server through a browser, the front-end obtains the user's IP address and carries the IP address in the keep-alive request to query the server backend for the session status. The specific code is as follows: if ($_GET['act'] == 'get_session_status') { / / Set parameters, including user IP address $param = [ 'user_addr' =>$_SERVER['REMOTE_ADDR'], ]; $rspString = getResponse('user_auth_result', 'showone', $param); $retString = getAssign($rspString, 1); $responseType = $retString['type'] ?? ''; if (in_array($responseType, ['SIM authentication', 'SIM authentication', 'SMS authentication', 'Local authentication', 'Local authentication'])) { echo "{$retString['name']}^#{$retString['login_time']}^#{$retString['ip']}^#{$retString['online_time']}"; exit(); } else if (in_array($responseType, ['Unauthenticated', 'No authentication'])){ echo "{$retString['sim_status']}^#{$retString['sim_ret_str']}"; exit(); } } After receiving the front-end request, the server backend queries the authentication keep-alive status of the IP address according to the IP address carried in the request. If it is authenticated, it returns the authenticated keep-alive status; if it is not authenticated, it returns the unauthenticated keep-alive status. The specific code is as follows: struct sim_user_auth_ret_node* sim_auth_ret_find_by_ip(be32 ip) { struct sim_user_auth_ret_node *nn; struct hlist_node *pos, *next; struct sim_user_auth_htable *htable; u32 hash; if (!ip) { sim_debug("ip is empty"); return NULL; } hash = sim_auth_ret_ip_hash(ip); htable =&sim_user_auth_ret_ip_hlist[hash]; hlist_for_each_entry_safe(nn, next, pos,&htable->head, ip_hnode) { if (nn->ip == ip) { return nn; } } return NULL; } int sim_auth_ret_add(struct sim_auth_cbk_profile_xml *profile) { struct sim_user_auth_htable *htable, *htable_ip; struct sim_user_auth_ret_node *node; u32 hash, hash_ip; time_t now; hash = sim_auth_ret_hash(profile->phone_num); hash_ip = sim_auth_ret_ip_hash(profile->ip); htable =&sim_user_auth_ret_hlist[hash]; htable_ip =&sim_user_auth_ret_ip_hlist[hash_ip]; now = time(NULL); sim_debug("phone(%s) add auth ret. hash(%d)", profile->phone_num,hash); node = kzalloc(sizeof(struct sim_user_auth_ret_node), MOD_USER_OBJ); if (!node) { sim_debug("no memory"); return -1; } strvcpy(node->phone_num, profile->phone_num); node->ip = profile->ip; node->uplcyid = profile->uplcyid; strvcpy(node->transaction_id, profile->transaction_id); node->timestamp = profile->timestamp; node->alive_start = now; node->status = SIM_AUTH_STATUS_NO_RESPONSE; node->auth_status = SIM_AUTH_STATUS_SEND_REQ; hlist_add_head(&node->hnode,&htable->head); hlist_add_head(&node->ip_hnode,&htable_ip->head); return 0; } The front end returns different authentication result pages to the browser according to the different authentication keep-alive states returned by the back end. The specific code is as follows: / / Initiate an AJAX request to obtain the session status $.ajax({ url: `.. / .. / sms_auth_submit.php?act=get_session_status&t=${Math.random()}`, type: 'POST', data: { cur_lang, uplcyid}, async: false, timeout: 30000, success: function(data) { if (data) { const isPreview = location.href.includes('preview'); const $loginDiv = $('.login_div'); const $loginSuccessDiv = $('.login_success_div'); / / Check if we are in preview mode if (isPreview) { $loginDiv.show(); $loginSuccessDiv.hide(); return; } const resultParts = data.split('^#'); var authMethod = getAuthMethod(resultParts[4]); / / Process data according to authentication method switch (authMethod) { case '0': processSIMAuth(data); $('.btn-local-cancel').hide(); $('#mod_password').hide(); $('.btn-sim-and-sms-cancel').show(); break; case '1': processSMSAuth(data); $('.btn-local-cancel').hide(); $('#mod_password').hide(); $('.btn-sim-and-sms-cancel').show(); break; case '2': processLocalAuth(data); $('.btn-local-cancel').show(); $('#mod_password').show(); $('.btn-sim-and-sms-cancel').hide(); break; } } }, error: function(xhr, status, error) { console.error('Failed to retrieve session status:', status, error); / / Error message handling } }); } Due to the cross-browser keep-alive method, the backend uses the IP Hash table to store the authentication keep-alive status. The frontend keep-alive request carries the user's IP address. The backend queries the authentication keep-alive status based on the IP address in the keep-alive request and returns it to the frontend. After the frontend obtains the keep-alive result, it uploads different authentication keep-alive pages to the browser based on the authentication keep-alive result. If authenticated, the authenticated result page is displayed; if not authenticated, the authentication login page is displayed.

[0024] In some embodiments of the present invention, the value in the Hash table also includes online time, and the method of determining that the user IP address has a corresponding keep-alive status in the preset Hash table and returning the authentication result page to the browser also includes: In the hash table, the online time in the value is updated according to the key value being the user's IP address.

[0025] In some embodiments of the present invention, the preset Hash table is cleaned up regularly.

[0026] In some embodiments of the present invention, the periodic clearing of the preset Hash table includes: The preset Hash table is cleaned up regularly based on the online time.

[0027] After the present invention is cross-browser, users can obtain their own authentication and keep alive status; if the user is in the unauthenticated keep alive state, the authentication login page is pushed to the user; if the user is in the authenticated keep alive state, the authenticated login result page is pushed to the user. In addition, the user can obtain his own authentication result status (authenticated or unauthenticated) using any browser he likes.

[0028] In order to better implement an authentication keep-alive implementation method in an embodiment of the present invention, based on an authentication keep-alive implementation method, correspondingly, as follows Figure 2 As shown, the embodiment of the present invention further provides a device for implementing authentication keep-alive, and the device 200 for implementing authentication keep-alive includes: The access data acquisition module 201 is used to determine the user IP address carried in the access request when receiving the access request sent by the browser; A keep-alive status query module 202, used to query the corresponding keep-alive status in a preset Hash table based on the user IP address, where the key value in the Hash table is used to store the IP address, and the value in the Hash table is used to store the keep-alive status; The authentication result page return module 203 is used to return the authentication result page to the browser when it is determined that the user IP address has a corresponding keep-alive status in the preset hash table; The authentication login page module 204 is used to return the authentication login page to the browser when it is determined that the user IP address does not have a corresponding keep-alive status in the preset Hash table.

[0029] The authentication keep-alive implementation device 200 provided in the above embodiment can implement the technical solution described in the above embodiment of the authentication keep-alive implementation method. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above embodiment of the authentication keep-alive implementation method, which will not be repeated here.

[0030] like Figure 3 As shown, the present invention also provides an electronic device 300. The electronic device 300 includes a processor 301, a memory 302 and a display 303. Figure 3 Only some components of the electronic device 300 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0031] In some embodiments, the processor 301 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 302, such as an implementation method of authentication keep-alive in the present invention.

[0032] In some embodiments, the processor 301 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, the processor 301 may be local or remote. In some embodiments, the processor 301 may be implemented in a cloud platform. In some embodiments, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.

[0033] In some embodiments, the memory 302 may be an internal storage unit of the electronic device 300, such as a hard disk or memory of the electronic device 300. In other embodiments, the memory 302 may also be an external storage device of the electronic device 300, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 300.

[0034] Furthermore, the memory 302 may include both an internal storage unit of the electronic device 300 and an external storage device. The memory 302 is used to store application software installed in the electronic device 300 and various data.

[0035] In some embodiments, the display 303 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 303 is used to display information on the electronic device 300 and to display a visual user interface. The components 301-303 of the electronic device 300 communicate with each other via a system bus.

[0036] In one embodiment, when the processor 301 executes an authentication keep-alive implementation program in the memory 302, the following steps may be implemented: Upon receiving an access request sent by a browser, determining the user IP address carried in the access request; Based on the user IP address, query the corresponding keep-alive status in a preset Hash table, where the key value in the Hash table is used to save the IP address, and the value in the Hash table is used to save the keep-alive status; When it is determined that the user IP address has a corresponding keep-alive status in the preset hash table, returning an authentication result page to the browser; When it is determined that the user IP address does not have a corresponding keep-alive status in the preset Hash table, an authentication login page is returned to the browser.

[0037] It should be understood that: when the processor 301 executes an authentication keep-alive implementation program in the memory 302, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.

[0038] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 300 mentioned, and the electronic device 300 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 300 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0039] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0040] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A method for implementing authentication keep-alive, characterized in that: include: Upon receiving an access request sent by a browser, determining the user IP address carried in the access request; Based on the user IP address, query the corresponding keep-alive status in a preset Hash table, where the key value in the Hash table is used to save the IP address, and the value in the Hash table is used to save the keep-alive status; When it is determined that the user IP address has a corresponding keep-alive status in the preset hash table, returning an authentication result page to the browser; When it is determined that the user IP address does not have a corresponding keep-alive status in the preset Hash table, an authentication login page is returned to the browser.

2. The method for implementing authentication keep-alive according to claim 1, characterized in that: After determining that the user IP address does not have a corresponding keep-alive state in the preset hash table and returning the authentication login page to the browser, the method further includes: The user IP address and the corresponding target keep-alive status are stored in a preset Hash table, where the target keep-alive status is determined based on the user's login status on the authentication login page.

3. The method for implementing authentication keep-alive according to claim 2, characterized in that: The target keep-alive state is determined based on the user's login state on the authentication login page, including: When the user successfully logs in on the authentication login page, the target keep-alive state is the keep-alive state; When the user fails to log in to the authentication login page, the target keep-alive state is a non-keep-alive state.

4. The method for implementing authentication keep-alive according to claim 1, characterized in that: The browser comprises: One or more of Google Chrome, Firefox, IE, 360 Browser and Sogou Browser.

5. The method for implementing authentication keep-alive according to claim 1, characterized in that: The value in the Hash table also includes the online time. When determining that the user IP address has a corresponding keep-alive status in the preset Hash table, returning the authentication result page to the browser also includes: In the hash table, the online time in the value is updated according to the key value being the user's IP address.

6. The method for implementing authentication keep-alive according to claim 5, characterized in that: Also includes: The preset Hash table is cleaned up regularly.

7. The method for implementing authentication keep-alive according to claim 6, characterized in that: The periodically cleaning up the preset Hash table includes: The preset Hash table is cleaned up regularly based on the online time.

8. A device for implementing authentication keep-alive, characterized in that: include: An access data acquisition module is used to determine the user IP address carried in the access request when receiving the access request sent by the browser; A keep-alive status query module, used to query the corresponding keep-alive status in a preset Hash table based on the user IP address, the key value in the Hash table is used to save the IP address, and the value in the Hash table is used to save the keep-alive status; The authentication result page return module is used to return the authentication result page to the browser when it is determined that the user IP address has a corresponding keep-alive status in the preset Hash table; The authentication login page module is used to return the authentication login page to the browser when it is determined that the user IP address does not have a corresponding keep-alive status in the preset Hash table.

9. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the method for implementing authentication keep-alive as described in any one of claims 1 to 7 above.

10. A computer-readable storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the method for implementing authentication keep-alive as described in any one of claims 1 to 7 above.

Citation Information

Patent Citations

  • Authentication method and apparatus

    CN105577618A

  • Identity verification method and device, computer equipment and computer readable storage medium

    CN112417393A

  • Authentication method and device and related equipment

    CN115150109A

  • Login method and device, computer equipment and storage medium

    CN115442131A

  • Method and device for simulating CAS authentication login and pressure test and electronic equipment

    CN116346504A