User authentication method and terminal supporting multiple environments

By obtaining and managing unified login cookies for multiple environments in the browser, the complexity of login information management of multi-environment websites is solved, and convenient login and logout functions are achieved.

CN119544263APending Publication Date: 2025-02-28FUJIAN TQ DIGITAL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411482575.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The prior art is difficult to effectively manage login information of multi-environment websites, resulting in the complexity of login conflicts and logout functions.

Method used

A user authentication method that supports multiple environments is adopted to obtain a unified login cookie for multiple environments in the browser, and login records containing the current login information and environment information in the cookie. This method supports the storage of multiple login records and distinguishes them by environmental information.

Benefits of technology

It realizes convenient management of login information on multi-environment websites, avoids login conflicts, and simplifies the logout function. You only need to delete the unified login cookie to achieve logout on the entire platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544263A_ABST
    Figure CN119544263A_ABST
Patent Text Reader

Abstract

According to the user authentication method supporting the multiple environments and the terminal, after a user logs in successfully, a uniform login cookie corresponding to the multiple environments of a target website in a browser is obtained, and a login record containing current login information and environment information is recorded in the login cookie; the login cookie supports the storage of a plurality of login records; according to a login information judgment request initiated by a website function, reading the login cookie, and based on the environment information, returning login information corresponding to the current website environment; receiving a login exit request of the user, and deleting the login cookie; according to the method and the device, the login records of different environments of the target website are stored by uniformly logging in the cookie in multiple environments supporting storage of multiple pieces of data, the login information of all environment sites can be deleted at any environment site, the function of deleting the login cookie of other sites does not need to be configured in the site, and the method and the device are simpler, more efficient and convenient to maintain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of user authentication, and in particular to a user authentication method and terminal supporting multiple environments. Background Art

[0002] Currently, many websites use cookies to store browser login information and determine whether the user is logged in. As demand develops, many websites have deployed multiple environments. In order to avoid login conflicts, general websites use different cookie names to distinguish cookies in different environments. However, as the number of deployment countries increases, the number of cookie names also increases, making management difficult. In addition, when a user clicks to exit at any site, the exit function of the entire platform needs to be implemented, which requires each site to add the exit function of cookies of other environment sites, which is both complicated and cumbersome to maintain. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide a user authentication method and terminal supporting multiple environments, so as to realize convenient management of website multi-environment login information.

[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: A user authentication method supporting multiple environments, comprising the steps of: S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; S2. Read the login cookie according to the login information determination request initiated by the website function, and return the login information corresponding to the current site environment based on the environment information; S3. Receive the user's logout request and delete the login cookie.

[0005] In order to solve the above technical problems, another technical solution adopted by the present invention is: A user authentication terminal supporting multiple environments includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; S2. Read the login cookie according to the login information determination request initiated by the website function, and return the login information corresponding to the current site environment based on the environment information; S3. Receive the user's logout request and delete the login cookie.

[0006] The beneficial effects of the present invention are: a user authentication method and terminal supporting multiple environments of the present invention supports a unified login cookie for multiple environments to store multiple data, stores login records for different environments of a target website, and distinguishes them by environmental information, which facilitates management while avoiding login conflicts in different login environments. When logging out is required, only the unified login cookie needs to be deleted, that is, the login information of all environmental sites can be deleted at any environmental site, and there is no need to configure the deletion function of the login cookies of other sites in the site, which is more concise, efficient and easy to maintain. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] Figure 1 A flowchart of a user authentication method supporting multiple environments; Figure 2 A structural diagram of a user authentication terminal supporting multiple environments; Description of labels: 1. A user authentication terminal supporting multiple environments; 2. A processor; 3. A memory. DETAILED DESCRIPTION

[0008] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0009] Please refer to Figure 1 , a user authentication method supporting multiple environments, comprising the steps of: S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; S2. Read the login cookie according to the login information determination request initiated by the website function, and return the login information corresponding to the current site environment based on the environment information; S3. Receive the user's logout request and delete the login cookie.

[0010] From the above description, it can be seen that the beneficial effects of the present invention are: a user authentication method that supports multiple environments of the present invention supports login cookies for multiple data storages, stores login records for different environments of the target website, and distinguishes them by environmental information. While avoiding login conflicts in different login environments, it is easy to manage. When you need to log out, you only need to delete the unified login cookie, that is, the deletion of login information of all environmental sites can be achieved in any environmental site, and there is no need to configure the deletion function of login cookies of other sites in the site. It is more concise, efficient and easy to maintain.

[0011] Furthermore, step S1 is specifically as follows: S11. After the user successfully logs in, determine whether there is a unified login cookie for multiple environments of the target website in the browser. If so, proceed to step S12; otherwise, proceed to step S13; S12, obtaining the login cookie, and recording a login record in the login cookie; S13: Create a new login cookie and record a login record in the login cookie.

[0012] From the above description, it can be seen that after the user logs in successfully, it is determined whether a unified login cookie for multiple environments already exists, that is, whether the user has logged in to other environment sites before. If so, there is no need to create a new login cookie. Only the environment information and login information of the current site need to be added to the existing login cookie to distinguish logins to sites in different environments. If the user has not logged in to other environment sites before, a new login cookie is directly created, and the environment information and login information are also recorded to distinguish them from subsequent logins in other environment sites.

[0013] Furthermore, the login cookie stores the login record in the form of a dictionary; Step S13 is specifically as follows: Create a dictionary and store the login record in the dictionary; Serializing the dictionary, and recording the serialized dictionary into the login cookie; Step S12 is specifically as follows: Obtain the login cookie, deserialize the information recorded in the login cookie to obtain the dictionary, and store the login record in the dictionary; The login record uses the environment information as a key and the login information as a value.

[0014] As can be seen from the above description, the login cookie stores the login record in the form of a dictionary, taking the environment information and the login information as one login record, and the dictionary structure can support the storage of multiple login records. After storage, the dictionary needs to be serialized to be stored in the login cookie.

[0015] Furthermore, the target website is configured with different environment keys for different environment information; When recording the login information in the login cookie, encrypting the login information by the environment key associated with the environment information of the current environment, and storing the encrypted information in the login cookie; When obtaining the login information from the login cookie, the login information needs to be decrypted according to the environment key associated with the environment information of the current environment.

[0016] From the above description, it can be seen that different environment keys are configured for different environment information, and the login information of different environment sites has been encrypted respectively to ensure the isolation and security of login information between different environments.

[0017] Furthermore, before step S1, the following steps are also included: S0. Obtain the login information input by the user, and verify the correctness of the login information, and enter step S1 after the verification passes.

[0018] From the above description, it can be seen that the premise of recording login records is that the user passes the correctness verification of the login information.

[0019] Please refer to Figure 2 , a user authentication terminal supporting multiple environments, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; S2. Read the login cookie according to the login information determination request initiated by the website function, and return the login information corresponding to the current site environment based on the environment information; S3. Receive the user's logout request and delete the login cookie.

[0020] From the above description, it can be seen that the beneficial effects of the present invention are: a user authentication terminal of the present invention that supports multiple environments supports login cookies for multiple data storages, stores login records for different environments of the target website, and distinguishes them by environmental information. While avoiding login conflicts in different login environments, it is easy to manage. When you need to log out, you only need to delete the unified login cookie, that is, the deletion of login information of all environmental sites can be achieved at any environmental site, and there is no need to configure the deletion function of login cookies of other sites in the site. It is more concise, efficient and easy to maintain.

[0021] Furthermore, step S1 is specifically as follows: S11. After the user successfully logs in, determine whether there is a unified login cookie for multiple environments of the target website in the browser. If so, proceed to step S12; otherwise, proceed to step S13; S12, obtaining the login cookie, and recording a login record in the login cookie; S13: Create a new login cookie and record a login record in the login cookie.

[0022] From the above description, it can be seen that after the user logs in successfully, it is determined whether a unified login cookie for multiple environments already exists, that is, whether the user has logged in to other environment sites before. If so, there is no need to create a new login cookie. Only the environment information and login information of the current site need to be added to the existing login cookie to distinguish logins to sites in different environments. If the user has not logged in to other environment sites before, a new login cookie is directly created, and the environment information and login information are also recorded to distinguish them from subsequent logins in other environment sites.

[0023] Furthermore, the login cookie stores the login record in the form of a dictionary; Step S13 is specifically as follows: Create a dictionary and store the login record in the dictionary; Serializing the dictionary, and recording the serialized dictionary into the login cookie; Step S12 is specifically as follows: Obtain the login cookie, deserialize the information recorded in the login cookie to obtain the dictionary, and store the login record in the dictionary; The login record uses the environment information as a key and the login information as a value.

[0024] As can be seen from the above description, the login cookie stores the login record in the form of a dictionary, taking the environment information and the login information as one login record, and the dictionary structure can support the storage of multiple login records. After storage, the dictionary needs to be serialized to be stored in the login cookie.

[0025] Furthermore, the target website is configured with different environment keys for different environment information; When recording the login information in the login cookie, encrypting the login information by the environment key associated with the environment information of the current environment, and storing the encrypted information in the login cookie; When obtaining the login information from the login cookie, the login information needs to be decrypted according to the environment key associated with the environment information of the current environment.

[0026] From the above description, it can be seen that different environment keys are configured for different environment information, and the login information of different environment sites has been encrypted respectively to ensure the isolation and security of login information between different environments.

[0027] Furthermore, before step S1, the following steps are also included: S0. Obtain the login information input by the user, and verify the correctness of the login information, and enter step S1 after the verification passes.

[0028] From the above description, it can be seen that the premise of recording login records is that the user passes the correctness verification of the login information.

[0029] The present invention provides a user authentication method and terminal supporting multiple environments, which are suitable for convenient management of multiple environment login information of websites with multiple environment requirements.

[0030] Please refer to Figure 1 , Embodiment 1 of the present invention is: A user authentication method supporting multiple environments, comprising the steps of: S0. Obtain the login information input by the user, and verify the correctness of the login information, and enter step S1 after the verification passes.

[0031] In this embodiment, the program first determines the account number and password entered by the user. If the input is incorrect, a login failure message is returned; if the input is correct, the subsequent steps are entered.

[0032] S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; Step S1 is specifically as follows: S11. After the user successfully logs in, determine whether there is a unified login cookie for multiple environments of the target website in the browser. If so, proceed to step S12; otherwise, proceed to step S13; S12, obtaining the login cookie, and recording a login record in the login cookie; S13: Create a new login cookie and record a login record in the login cookie.

[0033] In this embodiment, if the account and password entered by the user are correct, a login cookie unified in multiple environments is obtained. For example, when a user logs in, he first enters the account (such as "yewei") and password (such as "123456"). The system will verify whether the account and password match the records in the database. If incorrect, a login failure message is returned; if correct, a login cookie named "mylogin" is obtained.

[0034] In this embodiment, the login cookie stores the login record in the form of a dictionary; Step S13 is specifically as follows: Create a dictionary and store the login record in the dictionary; Serializing the dictionary, and recording the serialized dictionary into the login cookie; Step S12 is specifically as follows: Obtain the login cookie, deserialize the information recorded in the login cookie to obtain the dictionary, and store the login record in the dictionary; The login record uses the environment information as a key and the login information as a value.

[0035] In this embodiment, when the login cookie stores the login record in the form of a dictionary, when the login cookie is obtained, if the login cookie does not exist, a dictionary type is created; if it exists, it is deserialized into a dictionary.

[0036] Next, the program stores it in a dictionary using the environment identifier as the key and the encrypted login information as the value.

[0037] Specifically, in this embodiment, the code str:= ctx.Cookie("mylogin") is executed to check whether the login cookie exists. If the login cookie does not exist, a new dictionary is created and the code m:=new(map[string]string) is executed; if the login cookie exists, its content is deserialized into a dictionary and the code json.Unmarshal(str,&m) is executed. Then, the login information user is generated, which includes the user number and user name. Subsequently, the environment identifier (assuming the current environment identifier is "cn") is used as the key, and the encrypted login information is stored as the value, that is, the code m["cn"]=user is executed.

[0038] Finally, the dictionary is serialized into a string and stored back in the login cookie. Execute the code newStr:=json.Marshal(&m), and store it back in the login cookie, and execute the code ctx.SetCookie("mylogin",newStr).

[0039] In other equivalent embodiments, the login cookie is not limited to storing the login information and environment information in the form of a dictionary, and other alternative data structures may be used.

[0040] S2. According to the login information judgment request initiated by the website function, the login cookie is read, and based on the environment information, the login information corresponding to the current site environment is returned.

[0041] In this embodiment, when the website needs to determine the user's login status, the program will read a unified login cookie. If the login cookie does not exist, the login fails; if it does, it is deserialized into a dictionary. Next, the program reads the current environment identifier and looks up the value of the corresponding environment identifier in the dictionary to obtain the login information. If the value does not exist, the login fails; if it does, it is decrypted using the key in the current environment to obtain the login information, thereby determining whether the login is successful.

[0042] For example, when judging the user login status, the program first checks whether a unified login cookie named "mylogin" exists, and executes the code str:=ctx.cookie("mylogin"). If str is empty, that is, the login cookie does not exist, then the login failure information is directly returned. If str is not empty, that is, the login cookie exists, the program deserializes str into a dictionary, executes the code json.Unmarshal(str,&m), and obtains the identifier of the current environment to get "cn", and then executes the code m["cn"] to find the login information User of this environment. If User does not exist, the program will return a login failure prompt; if it exists, the user number and name are extracted to confirm the user's login status, and finally the login success information is returned, allowing the user to access protected resources.

[0043] Similarly, other environment identifiers can also store and obtain their own login user information in a unified cookie named "mylogin".

[0044] S3. Receive the user's logout request and delete the login cookie.

[0045] When the user clicks to log out, the program will delete the login cookie, thereby realizing the logout function for the entire platform.

[0046] When the user clicks to log out, the program deletes the unified login cookie named "mylogin" and executes the code ctx.DelCookie("mylogin"), thereby realizing the logout of the entire platform.

[0047] Embodiment 2 of the present invention is: A user authentication method supporting multiple environments, which differs from the first embodiment in that the target website is configured with different environment keys for different environment information; When the login information in the login cookie is recorded, the login information is encrypted by the environment key associated with the environment information of the current environment, and is stored in the login cookie after encryption.

[0048] In this embodiment, when the login information is stored in the login cookie, the login information user is generated, which includes the user number and user name. The program obtains the encryption key key of the current environment through the configuration file (the key for each deployment environment is different), encrypts the login information, and executes the code des.Encrypt(key,user) to obtain the encrypted string enUser. Subsequently, the environment identifier (assuming the current environment identifier is "cn") is used as the key, and the encrypted login information is stored as the value, that is, the code m["cn"]=enUser is executed. The dictionary is serialized into a string, the code newStr:=json.Marshal(&m) is executed, and it is stored back in the login cookie, and the code ctx.SetCookie("mylogin",newStr) is executed.

[0049] When obtaining the login information from the login cookie, the login information needs to be decrypted according to the environment key associated with the environment information of the current environment.

[0050] In this embodiment, when judging the user login status, the program first checks whether the login cookie named "mylogin" exists, and executes the code str:=ctx.Cookie("mylogin"). If str is empty, that is, the cookie does not exist, then the login failure information is directly returned. If str is not empty, that is, the cookie exists, the program deserializes str into a dictionary, executes the code json.Unmarshal(str,&m), and obtains the identifier of the current environment to obtain "cn", and then executes the code m["cn"] to find the encrypted login information enUser of this environment. If enUser does not exist, the program will return a prompt that the login failed; if it exists, the program uses the key key of the current environment to decrypt it, and executes the code des.Dncrypt(key,enUser). If the decryption is successful, the user number and name are extracted to confirm the user's login status, and finally the login success information is returned, allowing the user to access the protected resources.

[0051] Please refer to Figure 2 , Embodiment 3 of the present invention is: A user authentication terminal 1 supporting multiple environments includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, the steps of a user authentication method supporting multiple environments in the above embodiment 1 or 2 are implemented.

[0052] To sum up, the present invention provides a user authentication method and terminal that supports multiple environments, supports login cookies for multiple data storage, stores login records for different environments of the target website, and distinguishes them by environmental information. While avoiding login conflicts in different login environments, it is easy to manage. When you need to log out, you only need to delete the unified login cookie, that is, the login information of all environmental sites can be deleted at any environmental site, and there is no need to configure the deletion function of the login cookies of other sites in the site. It is more concise, efficient and easy to maintain.

[0053] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A user authentication method supporting multiple environments, characterized in that: Includes steps: S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; S2. Read the login cookie according to the login information determination request initiated by the website function, and return the login information corresponding to the current site environment based on the environment information; S3. Receive the user's logout request and delete the login cookie.

2. A user authentication method supporting multiple environments according to claim 1, characterized in that: Step S1 is specifically as follows: S11. After the user successfully logs in, determine whether there is a unified login cookie for multiple environments of the target website in the browser. If so, proceed to step S12; otherwise, proceed to step S13; S12, obtaining the login cookie, and recording a login record in the login cookie; S13: Create a new login cookie and record a login record in the login cookie.

3. A user authentication method supporting multiple environments according to claim 2, characterized in that: The login cookie stores the login record in the form of a dictionary; Step S13 is specifically as follows: Create a dictionary and store the login record in the dictionary; Serializing the dictionary, and recording the serialized dictionary into the login cookie; Step S12 is specifically as follows: Obtain the login cookie, deserialize the information recorded in the login cookie to obtain the dictionary, and store the login record in the dictionary; The login record uses the environment information as a key and the login information as a value.

4. A user authentication method supporting multiple environments according to claim 1, characterized in that: The target website is configured with different environment keys for different environment information; When recording the login information in the login cookie, encrypting the login information by the environment key associated with the environment information of the current environment, and storing the encrypted information in the login cookie; When obtaining the login information from the login cookie, the login information needs to be decrypted according to the environment key associated with the environment information of the current environment.

5. A user authentication method supporting multiple environments according to claim 1, characterized in that: Before step S1, the method further includes the following steps: S0. Obtain the login information input by the user, and verify the correctness of the login information, and enter step S1 after the verification passes.

6. A user authentication terminal supporting multiple environments, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. After the user successfully logs in, obtain the unified login cookie corresponding to the target website in multiple environments in the browser, and record a login record including the current login information and environment information in the login cookie; The login cookie supports the storage of multiple login records; S2. Read the login cookie according to the login information determination request initiated by the website function, and return the login information corresponding to the current site environment based on the environment information; S3. Receive the user's logout request and delete the login cookie.

7. A user authentication terminal supporting multiple environments according to claim 7, characterized in that: Step S1 is specifically as follows: S11. After the user successfully logs in, determine whether there is a unified login cookie for multiple environments of the target website in the browser. If so, proceed to step S12; otherwise, proceed to step S13; S12, obtaining the login cookie, and recording a login record in the login cookie; S13: Create a new login cookie and record a login record in the login cookie.

8. A user authentication terminal supporting multiple environments according to claim 7, characterized in that: The login cookie stores the login record in the form of a dictionary; Step S13 is specifically as follows: Create a dictionary and store the login record in the dictionary; Serializing the dictionary, and recording the serialized dictionary into the login cookie; Step S12 is specifically as follows: Obtain the login cookie, deserialize the information recorded in the login cookie to obtain the dictionary, and store the login record in the dictionary; The login record uses the environment information as a key and the login information as a value.

9. The user authentication terminal supporting multiple environments according to claim 6, characterized in that: The target website is configured with different environment keys for different environment information; When recording the login information in the login cookie, encrypting the login information by the environment key associated with the environment information of the current environment, and storing the encrypted information in the login cookie; When obtaining the login information from the login cookie, the login information needs to be decrypted according to the environment key associated with the environment information of the current environment.

10. The user authentication terminal supporting multiple environments according to claim 1, characterized in that: Before step S1, the method further includes the following steps: S0. Obtain the login information input by the user, and verify the correctness of the login information, and enter step S1 after the verification passes.