Cookie isolation methods, devices, equipment, media and program products
By dynamically generating target subdomain identifiers in remote application web proxy technology, the problem of browser cookies overlapping under the same domain is solved, which improves the flexibility and determinism of applications and ensures the isolation and management efficiency of cookies.
Patent Information
- Application Number
- CN202611474147.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-21
- Publication Date
- 2026-11-17
AI Technical Summary
In remote application web proxy technology, the browser's same-origin policy cannot automatically distinguish between different application origins, causing cookies to overlap and interfere with each other under the same domain, affecting the security and flexibility of the application.
By receiving access requests from client devices, the system dynamically generates target subdomain identifiers based on the address information in the requests, thereby achieving cookie isolation, avoiding the need for pre-configuration of subdomains, and enhancing the flexibility and determinism of applications.
Cookie isolation between different applications is achieved, reducing the difficulty of subdomain management, improving the flexibility of applications and the determinism of subdomains, and ensuring that multiple access sessions can share cookies.
Smart Images

Figure CN123122974A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a cookie isolation method, apparatus, device, medium, and program product. Background Technology
[0002] With the rapid development of enterprise digital transformation and cloud-native technologies, remote application web proxy technology has become a core infrastructure for cross-environment resource access. It adopts a unified proxy entry deployment model to securely publish internal network resources such as remote desktops and remote applications to external networks, and is widely used in scenarios such as remote office work, remote development and testing, and cloud application delivery.
[0003] In the aforementioned application scenarios, remote application web proxy technology faces the need to handle a large number of users simultaneously opening multiple remote application tabs in the same browser. Because these applications all use the same proxy domain during the proxy forwarding process, the browser's same-origin policy cannot automatically distinguish between different application origins, leading to cross-contamination and overlapping of cookies from different applications within the same domain. Therefore, providing a cookie isolation method to ensure the isolation of cookies from different applications within the same domain is a pressing issue that needs to be addressed. Summary of the Invention
[0004] This application provides a cookie isolation method, apparatus, device, medium, and program product for isolating cookies of various applications under the same domain.
[0005] In a first aspect, embodiments of this application provide a cookie isolation method applied to a server, the method comprising:
[0006] Receive an access request sent by a client device, wherein the access request contains the address information of the first application;
[0007] Based on the above address information, a target subdomain identifier is generated so that the client device can isolate the cookies generated during the business session between the client device and the first application based on the target subdomain identifier.
[0008] The technical solution provided in this application offers at least the following advantages: It begins by receiving an access request from a client device, and this request carries the address information of the first application. The first application is dynamically introduced into the Cookie isolation process at the moment of the request using its own address information, without relying on any pre-registration or binding of subdomains by the server side for the first application. This allows any first application, as long as it can be described by its address information, to immediately participate in subsequent Cookie isolation processing upon the arrival of the access request. Next, the server generates a target subdomain identifier based on this address information. Since the target subdomain identifier is directly derived from the address information of the first application in the access request, the first application does not need to apply for and configure exclusive subdomains one by one before deployment. Any newly added first application can immediately obtain the corresponding target subdomain identifier upon the arrival of the access request, thereby avoiding… This eliminates the need to pre-configure subdomains for applications, greatly increasing application flexibility and significantly reducing the difficulty of subdomain management. Furthermore, since the target subdomain identifier is deterministically generated from the same address information, when the client device isolates cookies generated during business sessions between the client device and the first application based on this target subdomain identifier, the same first application always corresponds to the same target subdomain identifier in different access sessions. Cookies generated during business sessions are stably attributed to this target subdomain identifier. Thus, cookies are isolated between different first applications due to their different target subdomain identifiers, while multiple access sessions of the same first application can share cookies because they correspond to the same target subdomain identifier, thereby maintaining the determinism of the application's subdomains and enabling multiple access sessions of the application to share cookies.
[0009] One possible implementation, after generating the target subdomain identifier based on the address information, includes the following:
[0010] If the above access request is sent by the client device when accessing the first application through the second application, and if there is no subdomain identifier in the above access request, or if there is a subdomain identifier of the second application in the above access request and the subdomain identifier of the second application is different from the target subdomain identifier, then the access address of the first application is determined based on the target subdomain identifier.
[0011] A business session is established between the client device and the first application based on the access address, so that the client device writes the cookies generated during the business session into the cookie storage area corresponding to the target subdomain identifier.
[0012] One possible implementation, whereby the target subdomain identifier is generated based on the aforementioned address information, includes:
[0013] Determine whether the address information of the first application contains the loopback address;
[0014] If the address information of the first application does not contain the loopback address, then a checksum calculation is performed on the address information of the first application to obtain the checksum.
[0015] The above checksum is converted into a string, and a preset number of characters are extracted from the string to serve as the identifier for the target subdomain.
[0016] Another possible implementation, after determining whether the address information of the first application contains the loopback address, includes the following:
[0017] If the address information of the first application contains the loopback address, then the target subdomain identifier is determined based on the port number of the loopback address.
[0018] Another possible implementation, after determining the access address of the first application based on the aforementioned target subdomain identifier, includes the following method:
[0019] Send a temporary redirect response to the aforementioned client device. The temporary redirect response contains target address information, which contains the session token of the aforementioned first application. The temporary redirect response is used to instruct the aforementioned client device to establish a business session between the aforementioned first application and the aforementioned client device.
[0020] Upon receiving an initialization page request from the aforementioned client device, a page document containing a client script is sent to the aforementioned client device, such that the aforementioned client device writes the session token of the aforementioned first application into the aforementioned cookie storage area based on the aforementioned client script.
[0021] Another possible implementation, whereby establishing a business session between the client and the first application based on the access address includes:
[0022] Receive a service session request sent by the aforementioned client device, which includes the session token of the aforementioned first application and the access address of the aforementioned first application;
[0023] Based on the aforementioned business session request, a business session is established between the aforementioned client device and the aforementioned first application.
[0024] Another possible implementation, which establishes a business session between the client device and the first application based on the aforementioned business session request, includes:
[0025] Parse the host header field of the above business session request to obtain the access address of the first application.
[0026] Extract the session token from the aforementioned business session request and verify the session token.
[0027] If the session token verification is successful, query the mapping table for address information that has a mapping relationship with the access address of the first application mentioned above;
[0028] The aforementioned business session request is forwarded to the target address indicated by the address information that has a mapping relationship with the access address of the aforementioned first application.
[0029] Upon receiving feedback information from the aforementioned target address, a service session is established between the aforementioned client device and the aforementioned first application.
[0030] Another possible implementation involves sending the page document to the aforementioned client device, including:
[0031] A page document containing a client script is sent to the aforementioned client device so that when the client device executes the client script, it reads the session token of the first application based on the aforementioned target address information and writes the session token of the first application into the aforementioned cookie storage area.
[0032] Another possible implementation involves determining the access address of the first application based on the target subdomain identifier, including:
[0033] Obtain the host identifier of the host where the first application is located, and the domain name of the proxy server;
[0034] The access address of the first application is constructed based on the target subdomain identifier, the host identifier, and the domain name of the proxy server.
[0035] Secondly, embodiments of this application provide a cookie isolation device, including:
[0036] The receiving module is used to receive access requests sent by the client device, wherein the access requests contain the address information of the first application;
[0037] The generation module is used to generate a target subdomain identifier based on the above address information, so that the client device can isolate the cookies generated during the business session between the client device and the first application based on the target subdomain identifier.
[0038] Another possible implementation, a cookie isolation device provided in this application, further includes:
[0039] The first determining module is configured to, when the access request is sent by the client device when accessing the first application through the second application, determine the access address of the first application based on the target subdomain identifier if the access request does not contain a subdomain identifier, or if the access request contains a subdomain identifier of the second application and the subdomain identifier of the second application is different from the target subdomain identifier.
[0040] The module is used to establish a business session between the client device and the first application based on the access address, so that the client device writes the cookies generated during the business session into the cookie storage area corresponding to the target subdomain identifier.
[0041] Another possible implementation, where the above-mentioned generation module is specifically used for:
[0042] Determine whether the address information of the first application contains the loopback address;
[0043] If the address information of the first application does not contain the loopback address, then a checksum calculation is performed on the address information of the first application to obtain the checksum.
[0044] The above checksum is converted into a string, and a preset number of characters are extracted from the string to serve as the identifier for the target subdomain.
[0045] Another possible implementation, the cookie isolation device provided in this application includes:
[0046] The second determining module is used to determine the target subdomain identifier based on the port number of the loopback address when the address information of the first application contains the loopback address.
[0047] One possible implementation, the cookie isolation device provided in this application includes:
[0048] The first sending module is used to send a temporary redirection response to the client device. The temporary redirection response contains target address information, the target address information contains the session token of the first application, and the temporary redirection response is used to instruct the client device to establish a business session between the first application and the client device.
[0049] The second sending module is configured to send a page document to the client device upon receiving an initialization page request from the client device. The page document contains a client script, which enables the client device to write the session token of the first application into the cookie storage area based on the client script.
[0050] Another possible implementation, the above-mentioned module is specifically used for:
[0051] Receive a service session request sent by the aforementioned client device, which includes the session token of the aforementioned first application and the access address of the aforementioned first application;
[0052] Based on the aforementioned business session request, a business session is established between the aforementioned client device and the aforementioned first application.
[0053] Another possible implementation, the above-mentioned module is specifically used for:
[0054] Parse the host header field of the above business session request to obtain the access address of the first application.
[0055] Extract the session token from the aforementioned business session request and verify the session token.
[0056] If the session token verification is successful, query the mapping table for address information that has a mapping relationship with the access address of the first application mentioned above;
[0057] The aforementioned business session request is forwarded to the target address indicated by the address information that has a mapping relationship with the access address of the aforementioned first application.
[0058] Upon receiving feedback information from the aforementioned target address, a service session is established between the aforementioned client device and the aforementioned first application.
[0059] Another possible implementation, the second sending module described above is specifically used for:
[0060] A page document containing a client script is sent to the aforementioned client device so that when the client device executes the client script, it reads the session token of the first application based on the aforementioned target address information and writes the session token of the first application into the aforementioned cookie storage area.
[0061] Another possible implementation, in which the first determining module is specifically used for:
[0062] Obtain the host identifier of the host where the first application is located, and the domain name of the proxy server;
[0063] The access address of the first application is constructed based on the target subdomain identifier, the host identifier, and the domain name of the proxy server.
[0064] Thirdly, this application provides an electronic device comprising: a processor and a memory; the memory stores a program or instructions executable on the processor, wherein the program or instructions, when executed by the processor, implement the method of the first aspect described above.
[0065] Fourthly, this application provides a readable storage medium on which a program or instructions are stored, which, when executed by a computer, implement the method of the first aspect described above.
[0066] Fifthly, this application provides a computer program product stored in a storage medium, which, when executed by a computer, implements the method described in the first aspect.
[0067] In a sixth aspect, embodiments of this application provide a chip including a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the method described in the first aspect.
[0068] The beneficial effects of the second to sixth aspects mentioned above are described in the corresponding description of the first aspect and will not be repeated here. Attached Figure Description
[0069] Figure 1 A schematic diagram of a network architecture for an application of a cookie isolation method provided in this application embodiment;
[0070] Figure 2 A flowchart illustrating a cookie isolation method provided in an embodiment of this application;
[0071] Figure 3 A flowchart illustrating another cookie isolation method provided in an embodiment of this application;
[0072] Figure 4 A flowchart illustrating yet another cookie isolation method provided in an embodiment of this application;
[0073] Figure 5 A flowchart illustrating yet another cookie isolation method provided in an embodiment of this application;
[0074] Figure 6 A flowchart illustrating yet another cookie isolation method provided in an embodiment of this application;
[0075] Figure 7 A flowchart illustrating yet another cookie isolation method provided in an embodiment of this application;
[0076] Figure 8 A flowchart illustrating yet another cookie isolation method provided in an embodiment of this application;
[0077] Figure 9 This is a schematic diagram of the structure of a cookie isolation device provided in an embodiment of this application;
[0078] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0079] The cookie isolation method, apparatus, device, medium, and program products provided in this application will now be described in detail with reference to the accompanying drawings.
[0080] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0081] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0082] The terms "at least one," "at least one of," etc., used in the specification and claims of this application refer to any one, any two, or a combination of two or more of the included items. For example, at least one of a, b, and c can mean: "a," "b," "c," "a and b," "a and c," "b and c," and "a, b, and c," where a, b, and c can be single or multiple. Similarly, "at least two" refers to two or more items, and its meaning is similar to that of "at least one."
[0083] In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0084] The cookie isolation method, apparatus, device, medium, and program product provided in this application embodiment can be applied to cross-application access scenarios.
[0085] Remote application web proxy technology faces the need to handle a large number of users simultaneously opening multiple remote application tabs in the same browser. Because these applications all use the same proxy domain during the proxy forwarding process, the browser's same-origin policy cannot automatically distinguish between different application origins, leading to cross-contamination and overlapping of cookies from different applications within the same domain. Therefore, providing a cookie isolation method to ensure that cookies from different applications are isolated within the same domain is a pressing issue that needs to be addressed.
[0086] To address the aforementioned technical problems, this application provides a cookie isolation method, apparatus, device, medium, and program product. It begins by receiving an access request from a client device, with the request carrying the address information of a first application. This means the first application is dynamically introduced into the cookie isolation process at the moment of the request using its own address information, without relying on any pre-registration or binding of subdomains for the first application on the server side. This allows any first application that can be described by its address information to immediately participate in subsequent cookie isolation processing upon the arrival of the access request. Next, the server generates a target subdomain identifier based on this address information. Since the target subdomain identifier is directly derived from the address information of the first application in the access request, the first application does not need to apply for and configure dedicated subdomains one by one before deployment. Any newly added first application can immediately obtain the corresponding identifier upon the arrival of the access request. The target subdomain identifier avoids the need to pre-configure subdomains for the application, greatly increasing application flexibility and significantly reducing the difficulty of subdomain management. Furthermore, since the target subdomain identifier is deterministically generated from the same address information, when the client device isolates cookies generated during business sessions between the client device and the first application based on this target subdomain identifier, the same first application always corresponds to the same target subdomain identifier in different access sessions. Cookies generated during business sessions are stably attributed to this target subdomain identifier. Thus, cookies are isolated between different first applications due to their different target subdomain identifiers, while multiple access sessions of the same first application can share cookies because they correspond to the same target subdomain identifier, thereby maintaining the determinism of the application's subdomains and enabling multiple access sessions of the application to share cookies.
[0087] The cookie isolation method, apparatus, device, medium, and program products provided in this application will be described in detail below with reference to the accompanying drawings.
[0088] Figure 1 This illustration shows a network architecture for an application of a cookie isolation method provided in an embodiment of this application. For example... Figure 1As shown, the network architecture includes a server 101 and a client device 102. The server 101 and the client device 102 are interconnected.
[0089] In some embodiments, server 101 may be a server, a computer, or a processor or processing unit within a server or computer. The server may be a single server or a server cluster consisting of multiple servers. It should be noted that the specific device form of server 101 is not limited in the embodiments of this application. Figure 1 The example shown is server 101 as a single server.
[0090] In some embodiments, the client device 102 may be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, personal computer (PC), ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc., and the embodiments of this application do not specifically limit it. Figure 1 The example shown is a mobile phone as the client device 102.
[0091] In some embodiments, server 101 receives an access request sent by client device 102, the access request containing address information of a first application; server 101 generates a target subdomain identifier based on the address information, so that client device 102 isolates cookies generated during business sessions between client device 102 and the first application based on the target subdomain identifier.
[0092] It should be noted that the network architecture described in the embodiments of this application is for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and does not constitute a limitation on the technical solutions provided in the embodiments of this application. As network architectures evolve, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0093] See Figure 2 This is a flowchart illustrating a cookie isolation method provided in an embodiment of this application. It is applied to a server, such as... Figure 2 As shown, the cookie isolation method provided in this application embodiment specifically includes the following steps 201 to 202.
[0094] Step 201: The server receives an access request sent by the client device, the access request containing the address information of the first application.
[0095] In some embodiments, an access request represents a Hypertext Transfer Protocol request initiated by a client device to a server for requesting access to a first application. The access request carries the address information of the first application as a target parameter, that is, the access request records the location of the first application that the client device expects to access.
[0096] In some embodiments, a client device represents a device running a browser or other web access program capable of generating and storing cookies. During the access to various applications, the client device writes the generated cookies to the cookie storage area of the corresponding subdomain according to the accessed subdomain.
[0097] In some embodiments, the first application represents a web application deployed on the server itself or deployed on other hosts. There are multiple first applications, and each of the multiple first applications corresponds to different address information.
[0098] In some embodiments, the address information represents the Uniform Resource Locator or a combination of host address and port number of the first application. For example, the address information of the first application can be a combination of host address and port number such as 192.168.1.100:9090, or a combination including loopback address and port number, such as 127.0.0.1:8080.
[0099] In some embodiments, the server receives an access request sent by a client device, including: the client device sending an access request to the server when a user clicks a link pointing to a first application on a page of a second application, wherein the target parameter of the access request records the address information of the first application; or, the client device sending an access request to the server when a user directly enters the address information of the first application through a bookmark or address bar, wherein the access request also carries the address information of the first application.
[0100] In some embodiments, after receiving an access request from a client device, the server also extracts target parameters from the access request to obtain the address information of the first application, so as to perform the calculation of the target subdomain identifier based on the address information.
[0101] Step 202: The server generates a target subdomain identifier based on the above address information, so that the client device can isolate the cookies generated during the business session between the client device and the first application based on the target subdomain identifier.
[0102] In some embodiments, the server determines whether the address information of the first application contains a loopback address (i.e., the local address); if it does, the port number string of the local address is directly used as the target subdomain identifier (e.g., if the port is 8080, it is identified as 8080); if it does not, a cyclic redundancy check (CRC) is performed on the complete address information of the first application to calculate the checksum, the checksum is converted into a string in a preset base (e.g., base-36), and a preset number (e.g., 4 characters) of characters are extracted from the string as the target subdomain identifier (e.g., 9a2a).
[0103] In some embodiments, the target subdomain identifier is a subdomain prefix string generated based on the address information of the target application according to a fixed conversion rule. It is essentially a deterministic subdomain and has the same effect as a deterministic subdomain, that is, the same target application address always corresponds to a unique subdomain identifier, the mapping relationship is constant and reproducible, and the cookie storage range corresponding to the browser can be stably defined.
[0104] In some embodiments, the local address represents the IP address of the machine where the proxy server is located; Cyclic Redundancy Check represents an algorithm used to perform data calculations on complete address information and generate a fixed-bit checksum.
[0105] In some embodiments, combined with Figure 2 ,like Figure 3 As shown, after step 202, the Cookie isolation method provided in this application further includes the following steps 301 to 302.
[0106] Step 301: When the above access request is sent by the client device to access the first application through the second application, if the access request does not contain a subdomain identifier, or if the access request contains a subdomain identifier of the second application and the subdomain identifier of the second application is different from the target subdomain identifier, then the server determines the access address of the first application based on the target subdomain identifier.
[0107] In some embodiments, the server receives an access request sent by a browser running on a client device when it accesses a first application (such as an intranet target business system) through a second application (such as a unified portal system) by clicking or redirecting, and extracts the address information of the first application (e.g., 192.168.1.100:9090) from the Uniform Resource Locator (URL) or header of the access request.
[0108] In some embodiments, the first application represents the target business application system that the client device currently needs to access; the second application represents the source application or portal system where the client device is located when it initiates the access request; and the address information represents the actual deployment location of the first application in the internal network, including the Internet Protocol (IP) address and port number.
[0109] In some embodiments, the server parses the current URL of the access request. If it finds that there is no subdomain identifier, or that there is a subdomain identifier but after comparison it is found that the subdomain identifier belongs to the second application and is different from the generated target subdomain identifier, the server determines the generated target subdomain identifier as the access address of the first application, and uses it as a credential for subsequent routing.
[0110] In some embodiments, the access address represents a pronoun representing the target subdomain identifier, which is used as an identifier for proxy routing and subdomain mapping during subsequent business session establishment.
[0111] Step 302: The server establishes a business session between the client device and the first application based on the access address, so that the client device writes the cookies generated during the business session into the cookie storage area corresponding to the target subdomain identifier.
[0112] In some embodiments, the server sends a temporary redirect response (such as a Hypertext Transfer Protocol 302 status code) to the client device based on the access address. The target address information of this response adopts a subdomain structure composed of a target subdomain identifier and carries a session token. Upon receiving an initial page request, the server sends a page document containing client scripts so that the client can write the session token through the Cookie attribute of the Document Object Model. Subsequently, the server receives a business session request carrying the session token and a host header field containing the access address. After verifying the token, the server queries the mapping table and forwards the request to the real address of the first application, thereby establishing a business session and writing the generated cookie to the cookie storage area corresponding to the target subdomain identifier.
[0113] In some embodiments, a temporary redirect response represents a response message from the server instructing the client device to jump to a target address containing a deterministic subdomain structure and a session token; the document object model represents the tree-structured interface built by the browser after parsing the page document; and the cookie storage area represents the local state storage space in the browser that is strictly bound to a specific subdomain.
[0114] The Cookie isolation method provided in this application begins by receiving an access request sent by a client device. This access request carries the address information of a first application. The first application is dynamically introduced into the Cookie isolation process at the moment of the request using its own address information, without relying on any pre-registration or binding of subdomains for the first application on the server side. This allows any first application that can be described by its address information to immediately participate in subsequent Cookie isolation processing upon the arrival of the access request. Next, the server generates a target subdomain identifier based on this address information. Since the target subdomain identifier is directly derived from the address information of the first application in the access request, the first application does not need to apply for and configure dedicated subdomains one by one before deployment. Any newly added first application can immediately obtain the corresponding target subdomain identifier upon the arrival of the access request, thereby avoiding... Pre-configuring subdomains for applications greatly increases application flexibility and significantly reduces the difficulty of subdomain management. Furthermore, since the target subdomain identifier is deterministically generated from the same address information, when the client device isolates cookies generated during business sessions between the client device and the first application based on this target subdomain identifier, the same first application always corresponds to the same target subdomain identifier in different access sessions. Cookies generated during business sessions are stably attributed to this target subdomain identifier. Thus, cookies are isolated between different first applications due to their different target subdomain identifiers, while multiple access sessions of the same first application can share cookies because they correspond to the same target subdomain identifier, thereby maintaining the determinism of the application's subdomains and enabling multiple access sessions of the application to share cookies.
[0115] In some embodiments, combined with Figure 2 ,like Figure 4 As shown, step 202 can be implemented through steps 202a to 202c.
[0116] Step 202a: The server determines whether the address information of the first application contains the loopback address.
[0117] In some embodiments, the server parses the received address information of the first application, extracts the Internet Protocol (IP) address, and determines whether the IP address matches the server's own IP address (i.e., local address). For example, if the address information of the first application is 192.168.1.10:8080, and the server's own IP address is 192.168.1.10, then it is determined that the address contains the local address.
[0118] In some embodiments, the loopback address represents the network communication address of the server device itself that performs the cookie isolation method described above.
[0119] Step 202b: If the address information of the first application does not contain the loopback address, the server performs a cyclic redundancy check calculation on the address information of the first application to obtain a checksum.
[0120] In some embodiments, if the address information of the first application does not include the loopback address (indicating that the first application is deployed on other backend servers), the server extracts the complete address information of the first application (including the complete IP address and port number), performs a Cyclic Redundancy Check (CRC) calculation on the complete address information, and generates a corresponding data checksum. For example, if the address information is 10.0.0.5:9090, the server performs a CRC calculation on this string to obtain a decimal checksum value.
[0121] Step 202c: The server converts the above checksum into a string and extracts a preset number of characters from the string as the identifier of the target subdomain.
[0122] In some embodiments, the server converts the calculated checksum into a string, extracts a preset number of characters from the string, and uses the extracted characters as the target subdomain identifier. For example, the decimal checksum is converted into a string represented in base-36, and the last or first four characters of the string (such as 9a2a) are extracted as the target subdomain identifier specific to the first application.
[0123] In some embodiments, the string represents the character sequence mapped from the numerical checksum after base conversion; the preset quantity represents the fixed character length required for the final generated target subdomain identifier.
[0124] In this way, by performing local IP determination and differential verification calculation on the first application address information, a unique and fixed-length target subdomain identifier can be quickly generated for applications with different deployment forms, providing an accurate subdomain prefix basis for the subsequent construction of an independent cookie storage area.
[0125] In some embodiments, combined with Figure 4 ,like Figure 5 As shown, after step 202a above, the Cookie isolation method provided in this application further includes the following step 401.
[0126] Step 401: If the address information of the first application contains the loopback address, the server determines the target subdomain identifier based on the port number of the loopback address.
[0127] In some embodiments, if the server determines that the address information of the first application contains the loopback address (i.e., the first application is deployed on the server's local machine), the server directly extracts the port number string from the address information and uses the port number string as the target subdomain identifier. For example, if the address information of the first application is 127.0.0.1:8080, and the server determines that it contains the local machine address, then it directly uses the port number "8080" as the target subdomain identifier.
[0128] In some embodiments, the port number represents the communication logical port number corresponding to a specific network service or application on the server.
[0129] In this way, by directly reusing the port number as the target subdomain identifier when the application is deployed on the local machine, unnecessary redundant verification calculations are avoided, and the generation efficiency of the local application subdomain identifier is improved.
[0130] In some embodiments, combined with Figure 3 ,like Figure 6 As shown, after step 301 above, the Cookie isolation method provided in this application further includes the following steps 501 and 502.
[0131] Step 501: The server sends a temporary redirection response to the aforementioned client device. The temporary redirection response contains target address information, which in turn contains the session token of the aforementioned first application. The temporary redirection response is used to instruct the aforementioned client device to establish a business session between the aforementioned first application and the aforementioned client device.
[0132] In some embodiments, after determining the access address (i.e., the target subdomain identifier) of the first application, the server generates a temporary redirect response (such as a 302 status code response) using Hypertext Transfer Protocol (HTTP). The server constructs the generated target subdomain identifier into a subdomain structure and combines the session token and address information of the first application as query parameters for a Uniform Resource Locator (URL) to generate target address information. The server sends this temporary redirect response containing the target address information to the client device, instructing the client device to redirect to the target address information to initiate access to the first application. For example, the server generates the target address information as: http: / / 9a2a.example.com / init?token=abc123&target=192.168.1.100:9090 and sends it to the client device via a 302 response.
[0133] In some embodiments, the target address information represents the complete network address in the temporary redirect response that indicates the client device to subsequently initiate a redirect and access; the session token represents an encrypted credential string issued by the server to verify the client device's access to the first application permission.
[0134] Step 502: Upon receiving an initialization page request from the aforementioned client device, the server sends a page document to the aforementioned client device. The page document contains a client script, which enables the aforementioned client device to write the session token of the aforementioned first application into the aforementioned cookie storage area based on the aforementioned client script.
[0135] In some embodiments, the server receives an initialization page request sent by the client device based on the target address information. In response, the server sends a page document in Hypertext Markup Language (HTML) format to the client device. This page document embeds a client-side script (such as JavaScript) containing the session token of the first application. When the client device's browser loads the page document and executes the client-side script, it writes the session token to the Cookie storage area corresponding to the current subdomain (i.e., the target subdomain identifier) through the Cookie attribute of the Document Object Model. After the writing operation is completed, it automatically triggers a redirect through the hyperlink attribute of the Location object to send a business session request to the server carrying the session token and a host header field containing the access address. For example, if the page document contains a script `document.cookie="token=abc123; path= / "`, the browser will write `abc123` to the storage area of the 9a2a domain after execution.
[0136] In some embodiments, a page document represents a structured document file issued by a server for loading and execution in a client device's browser to complete state initialization; a client script represents program code embedded in the page document that is parsed and executed by the client device to complete data writing and page navigation logic.
[0137] In this way, by combining the construction of a specific subdomain structure of the redirected target address with the writing of the front-end script, the session token of the first application is securely and seamlessly written into the cookie storage area of the deterministic subdomain, providing a legally isolated credential environment for the establishment of subsequent business sessions.
[0138] In some embodiments, combined with Figure 6 ,like Figure 7As shown, step 302 above can also be implemented through steps 302a to 302b below.
[0139] Step 302a: The server receives a service session request sent by the client device, which includes the session token of the first application and the access address of the first application.
[0140] In some embodiments, the server receives a Hypertext Transfer Protocol (HTTP) service session request sent by the client device after completing the session token writing. The server parses the request to obtain the session token of the first application (typically located in the Cookie header field of the request) and the access address of the first application (typically located in the Host header field of the request). For example, if the client device initiates a service request to http: / / 9a2a.example.com / app, the server extracts the access address 9a2a from its Host header and the token abc123 from its Cookie.
[0141] In some embodiments, a business session request represents a network request initiated by a client device to a server after completing the initial page redirection and state writing to obtain actual business data; the host header field represents an attribute field in the Hypertext Transfer Protocol request header used to specify the target server domain name and access address.
[0142] Step 302b: The server establishes a business session between the client device and the first application based on the aforementioned business session request.
[0143] In some embodiments, the server parses the host header field of the aforementioned business session request to obtain the access address, and extracts the session token from the request for security verification. If the verification is successful, the server queries a preset mapping table for address information that has a mapping relationship with the access address (i.e., the actual deployment address of the first application). Subsequently, the server forwards the aforementioned business session request to the target address indicated by the actual address, and receives feedback information returned by the first application based on the business session request. Based on this feedback information, a business session is established and maintained between the client device and the first application. For example, if the server looks up the table and finds that 9a2a corresponds to the internal address 192.168.1.100:9090, it will forward the request to that address and pass through the backend response, thereby establishing a complete business session channel.
[0144] In some embodiments, the mapping table represents a data structure maintained internally by the server that records the correspondence between the target subdomain identifier (i.e., the access address) and the actual address information of the first application; the feedback information represents the response message returned by the first application after processing the business session request.
[0145] In this way, by extracting and verifying the session token and accurately addressing and forwarding it in the mapping table based on the access address, the security and routing accuracy of business session establishment in cross-application proxy access scenarios are ensured.
[0146] In some embodiments, combined with Figure 7 ,like Figure 8 As shown, step 302b above may also include steps 302b1 to 302b5.
[0147] Step 302b1: The server parses the host header field of the above business session request to obtain the access address of the first application.
[0148] In some embodiments, the server parses the HTTP request header of the aforementioned business session request, extracts the value of the host header field, and extracts the subdomain portion from that value to obtain the access address of the first application (i.e., the previously generated target subdomain identifier). For example, the server parses the access address 9a2a from the Host header 9a2a.example.com.
[0149] Step 302b2: The server extracts the session token from the above business session request and verifies the session token.
[0150] In some embodiments, the server extracts the session token of the first application from the cookie field of the aforementioned business session request, and verifies the signature and validity period of the session token using a preset encryption key to confirm the legitimacy of the client device's access to the first application. For example, the server verifies whether the abc123 token was issued locally and has not expired.
[0151] Step 302b3: If the session token verification is successful, the server queries the mapping table for address information that has a mapping relationship with the access address of the first application.
[0152] In some embodiments, if the session token verification is successful, the server uses the access address of the first application as the key to search a preset mapping table to retrieve the real address information (such as internal network IP and port number) that has a mapping relationship with the access address. For example, the query finds that the real address information corresponding to the access address 9a2a is 192.168.1.100:9090.
[0153] Step 302b4: The server forwards the above-mentioned business session request to the target address indicated by the address information that has a mapping relationship with the access address of the first application.
[0154] In some embodiments, the server re-encapsulates or forwards the aforementioned business session request to the target address indicated by the mapped address information, i.e., the internal address where the first application is actually deployed.
[0155] In some embodiments, the target address represents the network communication address that the first application is actually deployed and monitored in the internal network.
[0156] Step 302b5: Upon receiving feedback information from the aforementioned target address, the server establishes a service session between the aforementioned client device and the aforementioned first application.
[0157] In some embodiments, the server receives HTTP feedback information returned by the first application after processing the business session request from the target address, and forwards the feedback information back to the client device, thereby establishing and maintaining a bidirectional data transmission channel between the client device and the first application, and completing the establishment of the business session.
[0158] Thus, through the dual mechanisms of host header resolution and token security verification, coupled with precise routing forwarding of the mapping table, the security of business session establishment and the accuracy of routing are ensured when accessing cross-application proxies.
[0159] In some embodiments, when sending a page document to the client device, the following implementation methods may also be used, for example: the server sends a page document to the client device, the page document containing a client script, so that when the client device executes the client script, it reads the session token of the first application based on the target address information and writes the session token of the first application into the cookie storage area.
[0160] In some embodiments, upon receiving an initialization page request from a client device, the server generates or reads a page document in Hypertext Markup Language (HTML) format and directly appends the session token of the first application to the code statements of the client-side script contained in the page document. The server sends the page document carrying the client-side script to the client device, so that when the browser of the client device parses and executes the client-side script, it writes the session token into the cookie storage area corresponding to the target subdomain identifier through the Cookie attribute of the Document Object Model (DOM). For example, the page document sent by the server contains client-side script like document.cookie="token=abc123; path= / ", and after the client device executes it, it accurately writes the session token into the corresponding subdomain storage area.
[0161] In some embodiments, the session token representation server embedded in the first application above hardcodes or concatenates the string value of the session token as a fixed parameter into the program code of the client script, so that the script can directly read the value and perform the process of writing it to local storage when it is executed.
[0162] In this way, by sending page documents with embedded tokens from the server and having the client execute scripts to write them, the secure transfer of cross-domain states and the writing of subdomain-level cookie storage areas are achieved, providing a legitimate isolated credential environment for the establishment of subsequent business sessions.
[0163] In some embodiments, when determining the access address of the first application based on the target subdomain identifier, the following implementation methods may also be used, for example: obtaining the host identifier of the host where the first application is located and the domain name of the proxy server; constructing the access address of the first application based on the target subdomain identifier, the host identifier and the domain name of the proxy server.
[0164] In some embodiments, the host identifier represents the identifier assigned by the server to the host where the first application is located. The first application is deployed on the host. The server maintains the corresponding host identifier for each connected host and records the mapping relationship between the host identifier and the address information of the first application. The host identifier is used to mark the host where the first application is located in the subdomain, so that the server can locate the host where the first application is located based on the host identifier in the subdomain.
[0165] In some embodiments, the proxy server represents the server that performs the cookie isolation method provided in this embodiment. The proxy server forwards business session requests between the client device and the first application. The client device accesses the first application through a subdomain under the domain name of the proxy server, rather than directly using the address information of the first application.
[0166] In some embodiments, the domain name of the proxy server represents a pre-configured fixed domain name of the proxy server. This domain name is pre-configured with a wildcard certificate covering all subdomains under this domain name, so that any subdomain derived from this domain name can pass certificate verification without the need to configure a separate certificate for each subdomain. For example, the domain name of the proxy server is example.com.
[0167] In some embodiments, the server obtains the host identifier of the host where the first application is located and the domain name of the proxy server, including: after obtaining the target subdomain identifier, the server queries the host identifier corresponding to the host where the address information of the first application is located from the pre-maintained mapping relationship, and reads the domain name of the locally pre-configured proxy server.
[0168] In some embodiments, the server constructs an access address for the first application based on a target subdomain identifier, a host identifier, and a proxy server's domain name. This includes: the server concatenating the target subdomain identifier and the host identifier, combining them with the proxy server's domain name to form a subdomain under the proxy server's domain name, and determining this subdomain as the access address for the first application. For example, if the target subdomain identifier is 9a2a, the host identifier of the host where the first application resides is joinCode, and the proxy server's domain name is example.com, then the subdomain constructed by the server will be in the form of 9a2a followed by the host identifier and then the proxy server's domain name. That is, the subdomain obtained by concatenating 9a2a and joinCode and placing it before example.com is the access address for the first application.
[0169] In some embodiments, after the server constructs the access address of the first application, the client device can access the first application through the access address. Since the subdomain of the access address contains the target subdomain identifier, the cookie generated during the business session between the client device and the first application is written to the cookie storage area corresponding to the target subdomain identifier. When the server receives the business session request, it can locate the host where the first application is located and forward the business session request based on the target subdomain identifier and the host identifier in the subdomain.
[0170] In this way, the access address of the first application is constructed on the spot when the access request arrives by the target subdomain identifier, host identifier and proxy server domain name, without the need to pre-configure the subdomain for the first application, and the access address obtained by the same first application is consistent each time, so that multiple access sessions of the first application can share cookies through the same access address.
[0171] To facilitate understanding of the solutions involved in the embodiments of this application, this application provides some descriptions of remote application web proxy technology, including: Remote application web proxy is a technology that publishes remote applications (such as web desktops, backend management interfaces, AI training platforms, etc.) deployed on an internal network to an external network through a proxy server, allowing users to access them through a browser. In a typical implementation, the user enters the proxy service address in the browser, and the proxy server, after receiving the request, establishes a connection with the internal target application and proxies it as a web page that can be directly operated in the browser. The browser's Same-Origin Policy stipulates that two URLs belong to the same origin only when their protocol, host (domain name), and port are exactly the same. Web pages originating from different origins cannot read each other's cookies, DOM data, etc. Under this policy, cookies are isolated by domain name by default—when a browser sends a request to a.example.com, it will not carry the cookies of b.example.com. However, this policy does not distinguish between different ports (cookies can still be shared even if the ports are different) nor does it distinguish between URL paths (cookies can still be shared even if the paths are different). In the scenario of remote application web proxy, users usually open multiple tabs of different applications simultaneously in the same browser. These applications use the same proxy domain during proxy forwarding, and the browser treats all of these applications' cookies as having the same origin, causing cookies from different applications to overlap under the same domain.
[0172] The following specific embodiments illustrate the cookie isolation method of this application. This application proposes a remote application cookie isolation method based on deterministic subdomains, aiming to achieve natural cookie isolation between remote applications using deterministic subdomains to solve the problem of cookies from different applications overlapping under the same domain. The specific solution includes: calculating a stable deterministic subdomain (scode) based on the target URL; the same target URL always returns the same scode, while different target URLs generate different scodes; simultaneously ensuring cookie sharing across multiple tabs of the same target application; and requiring no modification to the client processing flow, no additional port management, or additional TLS certificates beyond wildcards.
[0173] In some embodiments, the above-described remote application cookie isolation method based on deterministic subdomains further includes: calculating the target subdomain identifier (scode) based on the target URL. The specific implementation of this step includes: an scode generator receiving the target application URL as input and outputting a short identifier of 4-5 displayable characters. If the target URL contains localhost (or the local machine address 127.0.0.1), the port number string is directly used as the scode (e.g., the scode for localhost:7681 is '7681'); otherwise, a CRC32 checksum is calculated for the complete target URL, and the first 4 characters of the checksum's hexadecimal representation are taken as the scode (e.g., the scode for http: / / 172.17.0.1:8080 is '9a2a'). The same target URL always returns the same scode, while different target URLs generate different scodes (the CRC32 collision probability is approximately 1 / 65536).
[0174] In some embodiments, the above-described remote application cookie isolation method based on deterministic subdomains further includes: calculating the target subdomain identifier (scode) based on the target URL. The specific implementation of this step includes: an scode generator receiving the target application URL as input and outputting a short identifier of 4-5 displayable characters. If the target URL contains localhost (or the local machine address 127.0.0.1), the port number string is directly used as the scode (e.g., the scode for localhost:7681 is '7681'); otherwise, a CRC32 checksum is calculated for the complete target URL, and the first 4 characters of the checksum's hexadecimal representation are taken as the scode (e.g., the scode for http: / / 172.17.0.1:8080 is '9a2a'). The same target URL always returns the same scode, while different target URLs generate different scodes (the CRC32 collision probability is approximately 1 / 65536).
[0175] In some embodiments, when sending a temporary redirect response to a client device, the server uses a subdomain structure containing the aforementioned target subdomain identifier and sends it to the client device as the target address information included in the temporary redirect response. The subdomain structure format is {scode}-{joinCode}.{domain}, where scode is a 4-5 character target identifier and joinCode is the identifier of the target host. Wildcard TLS certificates (*.domain) cover all subdomains, allowing all traffic to be deployed on a single port. Cookies are naturally shared among subdomains with the same scode but different joinCodes.
[0176] In some embodiments, the above-described remote application cookie isolation method based on deterministic subdomains further includes a passive recalculation and automatic redirection mechanism for the Relay's scode. The specific implementation of this mechanism includes: when the Relay receives a client request, it extracts the target parameter from the request, recalculates the correct scode corresponding to the target, and compares it with the scode in the current request subdomain. If they do not match, the Relay automatically returns a 302 response, with the Location pointing to the / relay-internal / session-init path of the subdomain constructed with the correct scode, carrying the JWT and target as URL parameters. If they match, the request is processed directly under the current subdomain.
[0177] In some embodiments, the above-described remote application cookie isolation method based on deterministic subdomains further includes: the SessionInit page writing cookies via JavaScript. The specific implementation of this step includes: the redirected request being processed by the / relay-internal / session-init page. This page returns HTML content containing JavaScript. The client browser executes the script, writing the JWT to the cookie storage area of the current subdomain via document.cookie. Because the JavaScript code executes under the correct scode subdomain, the written cookie naturally falls under that domain, without relying on the HTTP Set-Cookie header or considering restrictions such as SameSite / Secure for cross-domain cookies.
[0178] In some embodiments, the above-described remote application cookie isolation method based on deterministic subdomains further includes: automatically redirecting to the actual page after writing the cookie. The specific implementation process of this step includes: after the JS script on the sessionInit page completes writing the cookie, it automatically redirects the browser to the original request path of the target application via location.href. The browser automatically carries the written cookie when making the redirect request.
[0179] In some embodiments, the above-described remote application cookie isolation method based on deterministic subdomains further includes: Relay routing via Host header. The specific implementation of this step includes: subsequent requests carrying cookies under the correct subdomain; Relay extracting the scode from the Host header; finding the corresponding target URL in a table; and forwarding the request. The Relay backend does not directly perceive the scode layer; it only routes and forwards requests via Host header.
[0180] In some embodiments, the aforementioned server may also be referred to as a relay (relay server or proxy gateway), which runs on the server side and is deployed between the client device and the first application actually deployed in the internal network as an intermediate layer for network communication. The relay is the core entity that executes the Cookie isolation method of this application. It is responsible for intercepting and parsing the access request initiated by the client device through the second application, generating a target subdomain identifier based on the address information of the first application, and constructing a temporary redirect response with a subdomain structure containing the target subdomain identifier when a subdomain conflict is determined. This response is then sent to the client device, which executes a client script that embeds the first application session token to write the token to the corresponding Cookie storage area. Subsequently, the relay is responsible for parsing the host header field of the business session request to obtain the access address, extracting and verifying the session token, querying the real address information that has a mapping relationship with the access address in the mapping table, and forwarding (relaying) the business session request to the first application. Finally, based on the feedback information, a business session is established between the client device and the first application, realizing the mutual physical isolation and secure routing of cookies in cross-application proxy access scenarios.
[0181] This application provides embodiments of the above-described remote application cookie isolation method based on deterministic subdomains in different scenarios, including:
[0182] Example 1: Users are redirected to a new application scenario from an old application page, including:
[0183] The user is currently using a remote application (scode 8092) and is redirected to another target application (http: / / 172.17.0.1:8080) via a link on that application's page.
[0184] Step 1: The browser sends a request to https: / / 8092-{joinCode}.example.com / ?target=http%3A%2F%2F172.17.0.1%3A8080.
[0185] Step 2: The Relay receives the request, extracts the target from the query parameter, and calculates its SCode to get 9a2a.
[0186] Step 3: Relay comparison revealed that the current request domain name is 8092-{joinCode}.example.com, which is inconsistent with the correct scode 9a2a.
[0187] Step 4: Relay returns a 302 response with the Location https: / / 9a2a-{joinCode}.example.com / relay-internal / session-init?token={JWT}&target=http%3A%2F%2F172.17.0.1%3A8080.
[0188] Step 5: The browser redirects to the new address (9a2a subdomain) and requests the / relay-internal / session-init page.
[0189] Step 6: The page returns HTML containing JavaScript. The browser executes the script, writing the JWT to a cookie in the 9a2a-{joinCode}.example.com domain via document.cookie.
[0190] Step 7: The JS script automatically redirects to https: / / 9a2a-{joinCode}.example.com / ?target=http: / / 172.17.0.1:8080.
[0191] Step 8: When the browser makes a request, it automatically carries the written cookie. The Relay verifies the cookie and forwards the request to the target.
[0192] Example 2: User direct access to new application scenarios, including:
[0193] Users can access the target application via bookmarks or by directly entering the address: http: / / 192.168.1.100:9090.
[0194] Step 1: The user enters https: / / relay.example.com / ?target=http%3A%2F%2F192.168.1.100%3A9090.
[0195] Step 2: Relay calculates the target's SCode (e.g., a3b8). Since the current domain does not contain an SCode or the SCode does not match, Relay automatically recalculates and redirects to the subdomain with the correct SCode.
[0196] Step 3: The subsequent process is the same as steps 5-8 of Example 1.
[0197] Example 3: Scenario where the same user accesses the same target application across multiple tabs, including:
[0198] The user has opened http: / / 172.17.0.1:8080 (scode 9a2a) in one tab and then opened the same address again in another tab.
[0199] Step 1: The second tab initiates an initialization request, and Relay calculates the scode to get 9a2a (the same as the first time).
[0200] Step 2: The domain name of the second tab in the browser is 9a2a-{joinCode}.example.com.
[0201] Step 3: Because the scode is the same, the browser's same-origin policy allows cookie sharing—the request for the second tab carries the cookie that was written by the first tab.
[0202] Step 4: Users do not need to log in again and can directly enter the logged-in state.
[0203] Example 4: Users access different target application scenarios in multiple tabs, including:
[0204] The user accesses the host at http: / / 127.0.0.1:8080 in the first tab and http: / / 127.0.0.1:8090 in the second tab.
[0205] Step 1: The user accesses the host's http: / / 127.0.0.1:8080 on the first tab, where scode is 8080 and the subdomain is 8080-{joinCodeB}.example.com.
[0206] Step 2: The user accesses the host's http: / / 127.0.0.1:8090 on the second tab, where scode is 8090 and the subdomain is 8090-{joinCodeB}.example.com.
[0207] In some embodiments, besides taking the first 4 hex characters of CRC32, scode generation can use the following methods: MD5 / SHA1 prefix (lower collision probability), custom mapping table (maintaining target→shortcode database), Base64 encoding to take the first few characters, and hash modulo mapping.
[0208] In some embodiments, in addition to writing with JS document.cookie, the following can be used: Set-Cookie response header (automatically written by the browser, but subject to SameSite / cross-domain restrictions), Service Worker interception to set cookies, and automatic form submission.
[0209] In some embodiments, in addition to JWT, the following may be selected: Opaque Token (server-maintained random token), SAMLAssertion (suitable for integration with existing SSO), and encrypted Cookie (directly encrypts session data writing).
[0210] In some embodiments, the use of a path-based reverse proxy (with the scode identifier added to the path), HTTP header routing (via a custom X-Scode header), or WebSocket connection reuse is not considered equivalent infringement.
[0211] In some embodiments, in addition to passive recalculation, the following can be selected: active allocation (actively obtaining scode from relay when the user opens a session), client-side calculation (calculation logic is pushed down to browser JS), and pre-allocation pool (the server pre-calculates the scode cache of commonly used targets).
[0212] It should be noted that the above-described method embodiments, or the various possible implementations of the method embodiments, can be executed individually, or, provided there is no conflict, they can be combined with each other. The specific implementation can be determined according to actual usage requirements, and this application embodiment does not impose any restrictions on this.
[0213] As can be seen, the above mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, the embodiments of this application provide corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the modules and algorithm steps of the various examples described in the embodiments disclosed herein, the embodiments of this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0214] This application embodiment can divide the cookie isolation method into functional modules based on the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. Optionally, the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0215] In some embodiments, this application also provides a cookie isolation device. The cookie isolation device may include one or more functional modules for implementing the cookie isolation method of the above method embodiments.
[0216] For example, Figure 9 This is a schematic diagram of a cookie isolation device provided in an embodiment of this application. Figure 9 As shown, the cookie isolation device 900 includes:
[0217] The receiving module 901 is used to receive an access request sent by the client device, wherein the access request contains the address information of the first application;
[0218] The generation module 902 is used to generate a target subdomain identifier based on the above address information, so that the client device can isolate the cookies generated during the business session between the client device and the first application based on the target subdomain identifier.
[0219] The cookie isolation device provided in this application starts by receiving an access request sent by a client device. This access request carries the address information of a first application. The first application is dynamically introduced into the cookie isolation process at the moment of the request using its own address information, without relying on any pre-registration or binding of subdomains for the first application on the server side. This allows any first application that can be described by its address information to immediately participate in subsequent cookie isolation processing upon the arrival of the access request. Next, the server generates a target subdomain identifier based on this address information. Since the target subdomain identifier is directly derived from the address information of the first application in the access request, the first application does not need to apply for and configure dedicated subdomains one by one before deployment. Any newly added first application can immediately obtain the corresponding target subdomain identifier upon the arrival of the access request, thereby avoiding... Pre-configuring subdomains for applications greatly increases application flexibility and significantly reduces the difficulty of subdomain management. Furthermore, since the target subdomain identifier is deterministically generated from the same address information, when the client device isolates cookies generated during business sessions between the client device and the first application based on this target subdomain identifier, the same first application always corresponds to the same target subdomain identifier in different access sessions. Cookies generated during business sessions are stably attributed to this target subdomain identifier. Thus, cookies are isolated between different first applications due to their different target subdomain identifiers, while multiple access sessions of the same first application can share cookies because they correspond to the same target subdomain identifier, thereby maintaining the determinism of the application's subdomains and enabling multiple access sessions of the application to share cookies.
[0220] In some embodiments, the cookie isolation device provided in this application further includes:
[0221] The first determining module is configured to, when the access request is sent by the client device when accessing the first application through the second application, determine the access address of the first application based on the target subdomain identifier if the access request does not contain a subdomain identifier, or if the access request contains a subdomain identifier of the second application and the subdomain identifier of the second application is different from the target subdomain identifier.
[0222] The module is used to establish a business session between the client device and the first application based on the access address, so that the client device writes the cookies generated during the business session into the cookie storage area corresponding to the target subdomain identifier.
[0223] In some embodiments, the generation module 902 is specifically used for:
[0224] Determine whether the address information of the first application contains the loopback address;
[0225] If the address information of the first application does not contain the loopback address, then a checksum calculation is performed on the address information of the first application to obtain the checksum.
[0226] The above checksum is converted into a string, and a preset number of characters are extracted from the string to serve as the identifier for the target subdomain.
[0227] In other embodiments, the cookie isolation device provided in this application includes:
[0228] The second determining module is used to determine the target subdomain identifier based on the port number of the loopback address when the address information of the first application contains the loopback address.
[0229] In other embodiments, the cookie isolation device provided in this application includes:
[0230] The first sending module is used to send a temporary redirection response to the client device. The temporary redirection response contains target address information, the target address information contains the session token of the first application, and the temporary redirection response is used to instruct the client device to establish a business session between the first application and the client device.
[0231] The second sending module is configured to send a page document to the client device upon receiving an initialization page request from the client device. The page document contains a client script, which enables the client device to write the session token of the first application into the cookie storage area based on the client script.
[0232] In other embodiments, the above-described establishment module is specifically used for:
[0233] Receive a service session request sent by the aforementioned client device, which includes the session token of the aforementioned first application and the access address of the aforementioned first application;
[0234] Based on the aforementioned business session request, a business session is established between the aforementioned client device and the aforementioned first application.
[0235] In other embodiments, the above-described establishment module is specifically used for:
[0236] Parse the host header field of the above business session request to obtain the access address of the first application.
[0237] Extract the session token from the aforementioned business session request and verify the session token.
[0238] If the session token verification is successful, query the mapping table for address information that has a mapping relationship with the access address of the first application mentioned above;
[0239] The aforementioned business session request is forwarded to the target address indicated by the address information that has a mapping relationship with the access address of the aforementioned first application.
[0240] Upon receiving feedback information from the aforementioned target address, a service session is established between the aforementioned client device and the aforementioned first application.
[0241] In other embodiments, the second sending module described above is specifically used for:
[0242] A page document containing a client script is sent to the aforementioned client device so that when the client device executes the client script, it reads the session token of the first application based on the aforementioned target address information and writes the session token of the first application into the aforementioned cookie storage area.
[0243] Another possible implementation, in which the first determining module is specifically used for:
[0244] Obtain the host identifier of the host where the first application is located, and the domain name of the proxy server;
[0245] The access address of the first application is constructed based on the target subdomain identifier, the host identifier, and the domain name of the proxy server.
[0246] It should be noted that the cookie isolation device can implement all the processes implemented in the above method embodiments and achieve the same beneficial effects. To avoid repetition, it will not be described again here.
[0247] In the case where the functions of the integrated modules described above are implemented in hardware, this application provides a possible structural schematic diagram of the electronic device involved in the above embodiments. For example... Figure 10 As shown, the electronic device 90 includes: a processor 92, a communication interface 93, and a bus 94. Optionally, the electronic device 90 may also include a memory 91.
[0248] Processor 92 may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 92 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 92 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0249] Communication interface 93 is used to connect with other devices via a communication network. This communication network can be Ethernet, wireless access network, wireless local area network (WLAN), etc.
[0250] The memory 91 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.
[0251] As one possible implementation, the memory 91 can exist independently of the processor 92. The memory 91 can be connected to the processor 92 via a bus 94 and is used to store instructions or program code. When the processor 92 calls and executes the instructions or program code stored in the memory 91, it can implement the cookie isolation method provided in the embodiments of this application.
[0252] In another possible implementation, memory 91 can also be integrated with processor 92.
[0253] Bus 94 can be an Extended Industry Standard Architecture (EISA) bus, etc. Bus 94 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0254] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the service calling device can be divided into different functional modules to complete all or part of the functions described above.
[0255] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled. The processor is used to run programs or instructions to implement the various processes of the above-described Cookie isolation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0256] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0257] This application also provides a readable storage medium storing a program or instructions that, when executed by a computer, implement the cookie isolation method provided in the above embodiments. It is understood that all or part of the processes in the above method embodiments can be executed by computer instructions instructing related hardware; the readable storage medium can be any of the foregoing embodiments or memory; the readable storage medium can also be an external storage device of the service invocation device, such as a pluggable hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the service invocation device. Further, the readable storage medium can include both internal storage units of the service invocation device and external storage devices. The readable storage medium is used to store the computer program and other programs and data required by the service invocation device. The readable storage medium can also be used to temporarily store data that has been output or will be output.
[0258] This application also provides a computer program product that is stored in a storage medium and implements the cookie isolation method provided in the above embodiments when the computer program product is executed by a computer.
[0259] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0260] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0261] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A cookie isolation method, characterized by, Applied to servers, including: Receive an access request sent by a client device, the access request containing the address information of a first application; A target subdomain identifier is generated based on the address information, so that the client device can isolate cookies generated during business sessions between the client device and the first application based on the target subdomain identifier.
2. The cookie isolation method of claim 1, wherein, After generating the target subdomain identifier based on the address information, the method further includes: When the access request is sent by the client device when accessing the first application through the second application, if the access request does not contain a subdomain identifier, or if the access request contains a subdomain identifier of the second application and the subdomain identifier of the second application is different from the target subdomain identifier, then the access address of the first application is determined based on the target subdomain identifier. A business session is established between the client device and the first application based on the access address, so that the client device writes the cookies generated during the business session into the cookie storage area corresponding to the target subdomain identifier.
3. The cookie isolation method according to claim 1 or 2, characterized in that, The step of generating the target subdomain identifier based on the address information includes: Determine whether the address information of the first application contains a loopback address; If the address information of the first application does not contain the loopback address, then a checksum calculation is performed on the address information of the first application to obtain a checksum. The checksum is converted into a string, and a preset number of characters are extracted from the string to serve as the identifier of the target subdomain.
4. The cookie isolation method of claim 3, wherein, After determining whether the address information of the first application contains a loopback address, the method includes: If the address information of the first application contains the loopback address, then the target subdomain identifier is determined based on the port number of the loopback address.
5. The cookie isolation method of claim 2, wherein, After determining the access address of the first application based on the target subdomain identifier, the method includes: Send a temporary redirection response to the client device. The temporary redirection response contains target address information, which contains the session token of the first application. The temporary redirection response is used to instruct the client device to establish a business session between the first application and the client device. Upon receiving an initialization page request from the client device, a page document containing client scripts is sent to the client device, such that the client device writes the session token of the first application into the cookie storage area based on the client scripts.
6. The cookie isolation method of claim 5, wherein, The step of establishing a business session between the client and the first application based on the access address includes: Receive a service session request sent by the client device, which includes the session token of the first application and the access address of the first application; A business session is established between the client device and the first application based on the business session request.
7. The cookie isolation method of claim 6, wherein, The step of establishing a service session between the client device and the first application based on the service session request includes: Parse the host header field of the business session request to obtain the access address of the first application; Extract the session token from the business session request and verify the session token; If the session token verification is successful, query the mapping table for address information that has a mapping relationship with the access address of the first application; The service session request is forwarded to the target address indicated by the address information that has a mapping relationship with the access address of the first application; Upon receiving feedback information from the target address, a service session is established between the client device and the first application.
8. The cookie isolation method of claim 5, wherein, Sending the page document to the client device includes: A page document containing a client script is sent to the client device so that when the client device executes the client script, it reads the session token of the first application based on the target address information and writes the session token of the first application into the cookie storage area.
9. The cookie isolation method according to claim 2, characterized in that, Determining the access address of the first application based on the target subdomain identifier includes: Obtain the host identifier of the host where the first application is located, and the domain name of the proxy server; The access address of the first application is constructed based on the target subdomain identifier, the host identifier, and the domain name of the proxy server.
10. A cookie isolation device, characterized in that, include: A receiving module is used to receive an access request sent by a client device, wherein the access request contains the address information of a first application; The generation module is used to generate a target subdomain identifier based on the address information, so that the client device can isolate the cookies generated during the business session between the client device and the first application based on the target subdomain identifier.
11. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions, when executed by the processor, implementing the cookie isolation method as described in any one of claims 1-9.
12. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a computer, implement the cookie isolation method as described in any one of claims 1-9.
13. A computer program product, characterized in that, The computer program product is stored in a storage medium, and when executed by a computer, the computer program product implements the cookie isolation method as described in any one of claims 1-9.
