Methods, apparatuses, devices, medium and product for establishing a web socket connection
The use of one-time tokens in Websocket connections addresses the security gaps in existing protocols, ensuring secure and authenticated communication by validating access tokens through cryptographic methods.
Patent Information
- Application Number
- PCT/CN2024/088778
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-04-19
- Publication Date
- 2025-10-23
AI Technical Summary
Existing Websocket communication protocols lack effective security measures for authenticating parties, leading to potential unauthorized access and data breaches.
A novel authentication mechanism using one-time tokens generated based on access tokens, transmitted as authorization headers, and validated through cryptographic techniques to ensure secure Websocket connections.
Ensures secure and authenticated communication between clients and servers by preventing unauthorized access and reducing the risk of data breaches.
Smart Images

Figure CN2024088778_23102025_PF_FP_ABST
Abstract
Description
METHODS, APPARATUSES, DEVICES, MEDIUM AND PRODUCT FOR ESTABLISHING A WEB SOCKET CONNECTIONFIELD
[0001] Embodiments of the present disclosure generally relate to the field of computer technology and in particular, to methods, apparatuses, electronic devices, a computer-readable medium and a computer program product for establishing a web socket connection between a client and a server.BACKGROUND
[0002] Hypertext transfer protocol (HTTP) is a foundational communication protocol used for transmitting hypermedia documents, such as HyperText markup language (HTML) . It is an application layer protocol that operates within the client-server model and is the backbone of data communication for the World Wide Web. HTTP functions in a request-response model.
[0003] WebSocket is a network communication protocol that enables full-duplex communication between a browser and a server over a single, long-lived connection. Unlike traditional HTTP requests where the client must initiate each communication, Websocket allows for real-time, bidirectional data transfer without the need for the client to send a request first. This protocol is designed to support applications that require fast, real-time interactions and is particularly useful for applications like online gaming, chat applications, and real-time data feeds.SUMMARY
[0004] In general, various example embodiments of the present disclosure provide a solution for establishing a web socket connection between a client and a server.
[0005] In a first aspect, it is provided a method of establishing a web socket connection. The method comprises receiving, at a server from a client, a frame indicating a request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing the server. The method further comprises validating the first token extracted from the header of the frame. The method further comprises generating a second token for establishing a web socket connection between the client and the server based on the first token in response to validating the first token being valid. The method further comprises transmitting the second token from the server to the client.
[0006] In a second aspect, it is provided a method of establishing a web socket connection. The method comprises determining, at a client, a frame indicating a first request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing a server. The method further comprises transmitting the frame indicating the first request to the server. The method further comprises receiving, from the server, a second token for establishing a web socket connection between the client and the server generated by the sever based on the first token. The method further comprises transmitting, to the server, a second request for establishing the web socket connection between the client and the server, wherein the second request comprises the second token.
[0007] In a third aspect, it is provided an apparatus of establishing a web socket connection. The apparatus comprises a receiving module configured to receive, at a server from a client, a frame indicating a request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing the server. The apparatus further comprises a validating module configured to validate the first token extracted from the header of the frame. The apparatus further comprises a generating module configured to generate, in response to validating the first token being valid, a second token for establishing a web socket connection between the client and the server based on the first token. The apparatus further comprises a transmitting module configured to transmit the second token from the server to the client.
[0008] In a fourth aspect, it is provided an apparatus of establishing a web socket connection. The apparatus comprises a determining module configured to determine, at a client, a frame indicating a first request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing a server. The apparatus further comprises a first transmitting module configured to transmit the frame indicating the first request to the server. The apparatus further comprises a receiving module configured to receive, from the server, a second token for establishing a web socket connection between the client and the server generated by the sever based on the first token. The apparatus further comprises a second transmitting module configured to transmit, to the server, a second request for establishing the web socket connection between the client and the server, wherein the second request comprises the second token.
[0009] In a fifth aspect, it is provided an electronics device. The electronics device comprises a processor; and a memory coupled to the processor, wherein the memory has instructions stored therein, and the instructions, when executed by the processor, cause the device to execute actions of the first aspect or the second aspect.
[0010] In a sixth aspect, it is provided a computer-readable medium. The computer-readable medium comprises instructions stored therein, which when executed by a processor, cause the processor to perform methods of the first aspect or the second aspect.
[0011] In a seventh aspect, it is provided a computer program product. The computer program product comprises instructions stored therein, which when executed by a processor, cause the processor to perform methods of the first aspect or the second aspect.
[0012] It is to be understood that the Summary is not intended to identify key or essential features of embodiments of the present disclosure, nor is it intended to be used to limit the scope of the present disclosure. Other features of the present disclosure will become readily comprehensible through the description below.DESCRIPTION OF DRAWINGS
[0013] Through the following detailed descriptions with reference to the accompanying drawings, the above and other objectives, features and advantages of the example embodiments disclosed herein will become more comprehensible. In the drawings, several example embodiments disclosed herein will be illustrated in an example and in a non-limiting manner, wherein:
[0014] FIG. 1 illustrates a schematic diagram of an example environment in which a plurality of embodiments of the present disclosure can be implemented;
[0015] FIG. 2 illustrates an example signaling process of establishing a connection between a client and a server in accordance with some embodiments of the present disclosure;
[0016] FIG. 3 illustrates another example signaling process of establishing a connection between a client and a server in accordance with some embodiments of the present disclosure;
[0017] FIG. 4 illustrates a further example signaling process of establishing a connection between a client and a server in accordance with some embodiments of the present disclosure;
[0018] FIG. 5 illustrates a flowchart of an example method for establishing a web socket connection between a client and a server implemented at a server in accordance with some embodiments of the present disclosure;
[0019] FIG. 6 illustrates a flowchart of an example method for establishing a web socket connection between a client and a server implemented at a client in accordance with some embodiments of the present disclosure;
[0020] FIG. 7 illustrates a block diagram of an example apparatus for establishing a web socket connection between a client and a server in accordance with some embodiments of the present disclosure;
[0021] FIG. 8 illustrates another block diagram of an example apparatus for establishing a web socket connection between a client and a server in accordance with some embodiments of the present disclosure; and
[0022] FIG. 9 illustrates a block diagram illustrating an electronic device in accordance with some embodiments of the present disclosure.
[0023] Throughout all the drawings, the same or similar reference numerals represent the same or similar elements.DETAILED DESCRIPTION OF EMBODIMENTS
[0024] Principles of the present disclosure will now be described with reference to several example embodiments shown in the drawings. Though example embodiments of the present disclosure are illustrated in the drawings, it is to be understood that the embodiments are described only to facilitate those skilled in the art in better understanding and thereby achieving the present disclosure, rather than to limit the scope of the disclosure in any manner.
[0025] The term comprises "or" includes "and" its variants are to be read as open terms that mean "includes, but is not limited to" . The term "or" is to be read as "and / or" unless the context clearly indicates otherwise. The term "based on" is to be read as "based at least in part on" . The term "being operable to" is to mean a function, an action, a motion or a state can be achieved by an operation induced by a user or an external mechanism. The term "one embodiment" and "an embodiment" are to be read as "at least one embodiment" . The term "another embodiment" is to be read as "at least one other embodiment" . The terms "first" , "second" , and the like may refer to different or same objects. Other definitions, explicit and implicit, may be included below. A definition of a term is consistent throughout the description unless the context clearly indicates otherwise.
[0026] The functions or algorithms described herein may be implemented in software in one embodiment. The software may consist of computer executable instructions stored on computer readable media or computer readable storage device such as one or more non-transitory memories or other type of hardware-based storage devices, either local or networked. Further, such functions correspond to modules, which may be software, hardware, firmware or any combination thereof. Multiple functions may be performed in one or more modules as desired, and the embodiments described are merely examples. The software may be executed on a digital signal processor, ASIC, microprocessor, or other type of processor operating on a computer system, such as a personal computer, server or other computer system, turning such computer system into a specifically programmed machine.
[0027] The functionality can be configured to perform an operation using, for instance, software, hardware, firmware, or the like. For example, the phrase "configured to" can refer to a logic circuit structure of a hardware element that is to implement the associated functionality. The phrase "configured to" can also refer to a logic circuit structure of a hardware element that is to implement the coding design of associated functionality of firmware or software. The term "module" refers to a structural element that can be implemented using any suitable hardware (e.g., a processor, among others) , software (e.g., an application, among others) , firmware, or any combination of hardware, software, and firmware. The term "logic" encompasses any functionality for performing a task. For instance, each operation illustrated in the flowcharts corresponds to logic for performing that operation. An operation can be performed using, software, hardware, firmware, or the like. The terms, "component" , "system" , and the like may refer to computer-related entities, hardware, and software in execution, firmware, or combination thereof. A component may be a process running on a processor, an object, an executable, a program, a function, a subroutine, a computer, or a combination of software and hardware. The term, "processor" may refer to a hardware component, such as a processing unit of a computer system.
[0028] The terms "a" or "an" as used herein, are defined as one or more than one. Also, the use of introductory phrases such as "at least one" and "one or more" in the claims should not be construed to imply that the introduction of another claim element by the indefinite articles "a" or "an" limits any particular claim containing such introduced claim element to disclosures containing only one such element, even when the same claim includes the introductory phrases "one or more" or "at least one" and indefinite articles such as "a" or "an" . The same holds true for the use of definite articles.
[0029] Furthermore, the claimed subject matter may be implemented as a method, apparatus, or article of manufacture using standard programming and engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computing device to implement the disclosed subject matter. Computer-readable storage media can include, but are not limited to, magnetic storage devices, e.g., hard disk, floppy disk, magnetic strips, optical disk, compact disk (CD) , digital versatile disk (DVD) , smart cards, flash memory devices, among others. In contrast, computer-readable media, i.e., not storage media, may additionally include communication media such as transmission media for wireless signals and the like.
[0030] As discussed above, HTTP functions in a request-response model. Further, HTTP transmits data without encryption, which can lead to eavesdropping and tampering. On the other hand, Websocket, as mentioned above, is an example of a bidirectional communication protocol that operates over a single connection and allows for full-duplex communication. This means that the client and server can send messages to each other independently and simultaneously. Basically, the first operation to establish a Websocket is connection establishment: the client initiates a Websocket connection by sending a special HTTP upgrade request. This request indicates the client's desire to switch to the Websocket protocol. When the server receives the handshake request, it decides whether to accept the upgrade to the Websocket protocol. If it accepts, it responds with an HTTP response containing information that confirms the upgrade.
[0031] Therefore, the first operation of the connection establishment may cause the access token exposed to malware. Although Websocket has gained significant popularity as a communication protocol for real-time web applications, yet traditional solutions, in general, are lack of applicable security measures for authenticating the parties involved in the communication. The Websocket protocol does not support custom headers. Therefore, systems that use OAuth2 JWT token sessions cannot place access tokens in the header. Furthermore, the alternative of the client placing a bearer token in cookies to pass it to the server will increase both the attack surface and the session management complexity (dedicated client to server data flow to guarantee the cookie lifecycle) . Finally, unauthorized access to Websocket connection would potentially result in data breaches, unauthorized data retrieval, and compromised system integrity. Thus, there is a need for an improved authentication mechanism for Websocket to enhance security and prevent unauthorized access.
[0032] Therefore, the present disclosure proposed a new solution for establishing a Websocket connection between a client and a server, especially for a Websocket connection. The provided Websocket authentication solution can ensure secure communication between clients and servers. The solution employs a unique combination of cryptographic techniques and authentication method based on one-time token to verify the authenticity of Websocket connections.
[0033] For example, the proposed solution provides a novel approach for validating the identities of clients for servers when they are communicating over Websocket connections by generating a one-time token at server based on the access token provided by an identity server (where the access token is in the header of the frame instead of in the body of the frame) and using the one-time token for Websocket authentication. In this way, it can ensure the secure transmission of data over the network.
[0034] FIG. 1 illustrates a schematic diagram of an example environment 100 in which a plurality of embodiments of the present disclosure can be implemented. The example environment 100 is only illustrated and is not intended to suggest any limitations as to scope of use or functionality of embodiments of the disclosure described herein.
[0035] As shown, the example environment 100 comprises a client 110 and a server 120. An example of the client 110 may be a browser. In an example, the server 120 is associated with a robot. The client 110 wish to access the server 120 and obtain the velocity and temperature of the robot. Therefore, the client 110 and the server 120 can communicate with each other via HTTP.
[0036] To establish a connection between the client 110 and the server 120, the server 120 may use an access token to authenticate the client 110. If the client 110 is not the one who has the permission to access the server 120, the server 120 will reject the request for establish the connection between the client 110 and the server 120. If the client 110 is the one who has the permission to access the server 120, the server 120 will allow the request for establish the connection between the client 110 and the server 120.
[0037] FIG. 2 illustrates an example signaling process of establishing a connection between a client and a server in accordance with some embodiments of the present disclosure. A client 202 in FIG. 2 may correspond to the client 110 in FIG. 1. A server 204 in FIG. 2 may correspond to the server 120 in FIG. 1.
[0038] The client 202 determines (210) a frame indicating a first request for obtaining a token for establishing a Websocket connection. The first token is used for accessing the server 204 and the first token is comprised in a header of the frame. The client 202 transmits (212) a request 216 for obtaining a token for establishing a Websocket connection to the server 204. The request 206 may also be referred to as a first request. The request 206 may be transmitted in the form of a frame, and the header of the frame may comprise the first token. The first token may be an access token indicating the identity of the client 202. In some example embodiments, the client 202 may request the second token using HTTP Post request with an authorization header containing a bearer token.
[0039] The server 204 receives (214) the request 216 from the client 202. The server 204 validates (218) the first token. For example, the server 204 may get a post request comprising first token and validate the first token. If the validation result is that the first token is valid, the server 204 may proceed to generate (220) a second token based on the first token. For example, the server 204 may generate a request identifier (ID) representing the second token based on the first token. The request ID (second token) may be a one-time token, and will be stored in an entry in the cache or memory.
[0040] The server 204 transmits (222) the second token 226 to the client 202. The client 202 receives (224) the second token 226 from the server 204. In some example embodiments, the second token 226 may be set as a cookie and may be sent back to the client 202. In some example embodiments, the second token 226 may be a cryptogram. It may be generated by a unique request ID, a random ticket and an origin-header from the client 202, so different clients may have their own unique second token 226. In some example embodiments, the second token 226 may have an expiration time to establish the Websocket connection between client 202 and the server 204. The expiration time can be set very short. Thus, the expiration time can improve security and reduce the likelihood of cyber-attacks.
[0041] The client 202 transmits (228) a request 232 for establishing the Websocket connection comprising the second token 226. The request 232 may also be referred to as a second request. In some example embodiments, the client 202 may embed the received second token 226 in the Uniform Resource Locator (URL) of the request 232 and send the request 232 to the sever 204 to request the Websocket connection.
[0042] In some example embodiments, the client 202 may use a hardened cookie (for example, using '__HOST-' prefixed rather than just '__SECURE-' ) to deliver the second token 226 back to the server 204 without ever being exposed to malicious scripts that may be running in the browser of the client 202.
[0043] The server 204 receives (230) the request 232 from the client 202. In some example embodiments, the server 204 may get the second token 226 by using the request ID as a key to filter cookies of the request 232. It then validates it against stored request ID with the assistance of an algorithm (for example, a hash algorithm) . The Websocket connection will be established if validation is successful. Otherwise, the connection Websocket connection will be failed.
[0044] By implementing the embodiments of the signaling process 200, it can ensure the secure transmission of data over the network. The access token is transmitted as authorization header and no access token is stored in cookies. Thus, the access token is not accessible by client-side scripts, which reduces the chance of malicious actors to capture it.
[0045] FIG. 3 illustrates another example signaling process 300 of establishing a connection between a client and a server in accordance with some embodiments of the present disclosure. A client 302 in FIG. 3 may correspond to the client 110 in FIG. 1. A server 304 in FIG. 3 may correspond to the server 120 in FIG. 1.
[0046] At 306, the client may use a GET function to initiate a request for a one-time token (may refer to the second token) . The request may contain an access token (may refer to the first token) provided by an identity server. At 308, the server 304 may obtain the credentials from cache to validate the client 302. If the validation of the client 302 is passed, it means that the client 302 can be allowed to establish a Websocket connection with the server 304. Thus, the server 304 may generate the one-time token.
[0047] After the one-time token is generated, at 310, the server 304 may set the one-time token on a browser session. The client 302 may get the one-time token through the browser session. At 312, the client 302 may send a request for the Websocket connection comprising the one-time token via the Websocket Secure (WSS) switch protocol. The server 304 may obtain the request for the Websocket connection comprising the one-time token.
[0048] The server 120 may validate and clear the one-time token. For example, at 314, server 120 may authenticate the one-time token with the stored credentials in the cache. If the one-time token is validated, the server may determine to establish the Websocket connection with the client 302. For example, at 316, an authenticated WSS is established.
[0049] FIG. 4 illustrates a further example signaling process 400 of establishing a connection between a client and a server in accordance with some embodiments of the present disclosure. A client 402 in FIG. 4 may correspond to the client 110 in FIG. 1. A server 406 in FIG. 4 may correspond to the server 120 in FIG. 1. A one-time token factory 404 is a front-end component which manages the one-time token. A Cache 408 is a cache of the server 406 which is shown individually for the purpose of a more detailed illustration.
[0050] At step 1, the client 402 may decide to start a Websocket connection in the client hub. At step 2, the client 402 may send a post request comprising an access token to request a one-time token to the one-time token factory 404. In some example embodiment, to include a new field in the headers of a post request, some programming languages and tools to set the appropriate headers with the required information can be used. For example, in Python, the requests library can be used to make HTTP requests. For another example, in JavaScript, the fetch API can be used to make requests.
[0051] At step 3, the one-time token factory 404 may transmit the post request to the server 406 by combining the service ID and / or a WSS request. At step 4, the server 406 may get and validate the access token. At step 5, the server 406 may generate the one-time token. In some examples, the one-time token may be also referred to as a request ID. At step 6, the server 406 may create an entry and stored it to the cache 408. As an example, the entry may comprise the real token, the one-time token, the expired time and other information used to validate the one-time token. The expiration time may be set to 10 seconds.
[0052] At step 7, the sever 406 may put the one-time token and some settings into the response cookie. At step 8, the server 406 may return the request ID (the one-time token) to the one-time token factory 404. At step 9, the one-time token factory 404 may send the request ID (the one-time token) to the client 402. At step 10, the client 402 may send a request for establishing a Websocket connection to the server 406. At step 11, the sever 406 may get the one-time token from the response cookie, and delete it from the response cookie. At step 12, the server 406 may get values from the cache 408. At step 13, the server 406 may validate the one-time token.
[0053] If the one-time token is validated. The signaling process 400 continues to block 410. At step 14, the server 406 may remove the entry from the cache 408. At step 15, the authenticated Websocket connection is established. The loop 412 shows the signaling after the Websocket connection is established. At step 16, the client 402 may communicate with the server 406 over the Websocket connection. At step 17, the client 402 may communicate with the client 402 over the Websocket connection.
[0054] If the one-time token is not validated. The signaling process 400 continues to block 414. At step 18, the server 406 may remove the entry from the cache 408. At step 19, the server 406 may return Client Error message (for example, a 401 message) to the client 402.
[0055] By implementing the embodiments of the signaling processes 300 or 400, no Websocket connection is ever started anonymously. A more secure communication between clients and servers can be achieved. The signaling processes 300 or 400 can be integrated and enforced in a single point of the Websocket lifecycle.
[0056] FIG. 5 illustrates a flowchart of an example method 500 for establishing a web socket connection between a client and a server implemented at a server in accordance with some embodiments of the present disclosure. FIG. 5 will be described with reference to FIG. 1.
[0057] At 502, the server 120 receives, from the client 110, a frame indicating a request for obtaining a token for establishing a web socket connection. A header of the frame comprises a first token used for accessing the server 120. At 504, the server 120 validates the first token extracted from the header of the frame.
[0058] At 506, if the first token is valid, the server 120 generates a second token for establishing a web socket connection between the client 110 and the server 120 based on the first token. At 508, the server 120 transmits the second token from the server 120 to the client 110.
[0059] In some example embodiments, the second token may be associated with an expiration period during which the web socket connection between the client 110 and the server 120 is allowed to be established, and the second token may be expired out of the expiration period.
[0060] In some example embodiments, the second token may be generated based further on at least one of the following: an identifier of the request; a random ticket (such as random number) ; or an origin-header from the client.
[0061] In some example embodiments, the request for obtaining the token for establishing a web socket connection may be a first request. In some example embodiments, the server 120 may receive, from the client 110, a second request for establishing the web socket connection between the client 110 and the server 120, and second request may comprise the second token. The server 120 may validate the second token and if the second token is valid, the server 120 may determine to establish the web socket connection.
[0062] In some example embodiments, the server 120 may receive the second request via a hardened cookie. In some example embodiments, the first request may comprise a HTTP post request, and the first token may comprise a bearer token. In some example embodiments, the client 110 may comprise a browser, and the client 110 and the server 120 may be in a browser / server architecture.
[0063] FIG. 6 illustrates a flowchart of an example method 600 for establishing a web socket connection between a client and a server implemented at a client in accordance with some embodiments of the present disclosure. FIG. 6 will be described with reference to FIG. 1.
[0064] At 602, the client 110 determines a frame indicating a first request for obtaining a token for establishing a web socket connection. A header of the frame comprises a first token used for accessing the server 120. At 604, the client 110 transmits the frame indicating the first request to the server 120.
[0065] At 606, the client 110 receives, from the server 120, a second token for establishing a web socket connection between the client 110 and the server 120 generated by the sever 120 based on the first token. At 608, the client 110 transmits, to the server 120, a second request for establishing the web socket connection between the client 110 and the server 120. The second request comprises the second token.
[0066] In some example embodiments, the server 120 may transmit the second request via a hardened cookie. In some example embodiments, the second token may be associated with an expiration period during which the web socket connection between the client 110 and the server 120 is allowed to be established. The second token may be expired out of the expiration period. The first request may comprise a HTTP post request. The first token may comprise a bearer token. The client may comprise a browser. The client and the server may be in a browser / server architecture.
[0067] By implementing the embodiments of the method 500 and / or 600, the secure transmission of data over the network can be ensured. The access token is transmitted as authorization header and no access token is stored in cookies. Thus, the access token is not accessible by client-side scripts, which reduces the chance of malicious actors to capture it. In some example embodiments, no Websocket connection is ever started anonymously. A more secure communication between clients and servers can be achieved.
[0068] Reference is made to FIG. 7, which illustrates a block diagram of an example apparatus 700 for establishing a web socket connection between a client and a server in accordance with some embodiments of the present disclosure.
[0069] The apparatus 700 comprises a receiving module 702 configured to receive, at a server from a client, a frame indicating a request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing the server. The apparatus 700 further comprises a validating module 704 configured to validate the first token extracted from the header of the frame. The apparatus 700 further comprises a generating module 706 configured to generate, in response to validating the first token being valid, a second token for establishing a web socket connection between the client and the server based on the first token. The apparatus 700 further comprises a transmitting module 708 configured to transmit the second token from the server to the client.
[0070] In some example embodiments, the apparatus 700 further comprises a first module configured to receive, from the client, a second request for establishing the web socket connection between the client and the server, wherein second request comprises the second token. The apparatus 700 further comprises a second module configured to validate the second token. The apparatus 700 further comprises a third module configured to determine to establish the web socket connection in response to validating the second token being valid.
[0071] In some example embodiments, the receiving module 702 further comprises a fourth module configured to receive the second request via a hardened cookie.
[0072] FIG. 8 illustrates another block diagram of an example apparatus 800 for establishing a web socket connection between a client and a server in accordance with some embodiments of the present disclosure.
[0073] The apparatus 800 comprises a determining module 802 configured to determine, at a client, a frame indicating a first request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing a server. The apparatus 800 further comprises a first transmitting module 804 configured to transmit the frame indicating the first request to the server. The apparatus 800 further comprises a receiving module 806 configured to receive, from the server, a second token for establishing a web socket connection between the client and the server generated by the sever based on the first token. The apparatus 800 further comprises a second transmitting module 808 configured to transmit, to the server, a second request for establishing the web socket connection between the client and the server, wherein the second request comprises the second token.
[0074] In some example embodiments, the second transmitting module 808 further comprises a fifth module configured to transmit the second request via a hardened cookie.
[0075] By implementing the example embodiments of FIG. 7 and / or FIG. 8, the secure transmission of data over the network can be ensured. The access token is transmitted as authorization header and no access token is stored in cookies. Thus, the access token is not accessible by client-side scripts, which reduces the chance of malicious actors to capture it. In some example embodiments, no Websocket connection is ever started anonymously. A more secure communication between clients and servers can be achieved.
[0076] FIG. 9 illustrates a block diagram illustrating an electronic device 900 in accordance with some embodiments of the present disclosure. As indicated, the device 900 includes a central processing unit (CPU) 901, which can execute various appropriate actions and processing based on the computer program instructions stored in a read-only memory (ROM) 902 or the computer program instructions loaded into a random access memory (RAM) 903 from a storage unit 908. The RAM 903 also stores all kinds of programs and data required by operating the electronic device 900. CPU 901, ROM 902 and RAM 903 are connected to each other via a bus 904, to which an input / output (I / O) interface 905 is also connected.
[0077] A plurality of components in the device 900 are connected to the I / O interface 905, comprising: an input unit 906, such as a keyboard, a mouse and the like; an output unit 907, such as various types of displays, loudspeakers and the like; a storage unit 908, such as a storage disk, an optical disk and the like; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver and the like. The communication unit 909 allows the device 900 to exchange information / data with other devices through computer networks such as Internet and / or various telecommunication networks.
[0078] Each procedure and processing described above, such as the method 500 and / or 600, can be executed by a processing unit 901. For example, in some embodiments, the method 500 and / or 600 can be implemented as computer software programs, which are tangibly included in a machine-readable medium, such as a storage unit 908. In some embodiments, the computer program can be partially or completely loaded and / or installed to the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded to the RAM 903 and executed by the CPU 901, one or more steps of the above described method 500 and / or 600 are implemented. Alternatively, in other embodiments, the CPU 901 may also be configured in any proper manner to implement the above process / method.
[0079] The present disclosure may be a method, a device, a system and / or a computer program product. The computer program product can include a computer-readable storage medium loaded with computer-readable program instructions thereon for executing various aspects of the present disclosure.
[0080] The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include: a portable computer diskette, a hard disk, a random access memory (RAM) , a read-only memory (ROM) , an erasable programmable read-only memory (EPROM or Flash memory) , a static random access memory (SRAM) , a portable compact disc read-only memory (CD-ROM) , a digital versatile disk (DVD) , a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination thereof. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable) , or electrical signals transmitted through a wire.
[0081] Computer readable program instructions described herein can be downloaded to respective computing / processing devices from a computer readable storage medium, or downloaded to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and / or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and / or edge servers. A network adapter card or network interface in each computing / processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing / processing device.
[0082] Computer readable program instructions for carrying out operations of the present disclosure may be assembly instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN) , or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider) . In some embodiments, by means of state information of the computer readable program instructions, an electronic circuitry including, for example, programmable logic circuitry (PLC) , field-programmable gate arrays (FPGA) , or programmable logic arrays (PLA) can be personalized to execute the computer readable program instructions, thereby implementing various aspects of the present disclosure.
[0083] Aspects of the present disclosure are described herein with reference to flowchart and / or block diagrams of methods, apparatus (systems) , and computer program products according to embodiments of the present disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer readable program instructions.
[0084] These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which are executed via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and / or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function / act specified in the flowchart and / or block diagram block or blocks.
[0085] The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which are executed on the computer, other programmable apparatus, or other device implement the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0086] The flowchart and block diagrams illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, snippet, or portion of codes, which comprises one or more executable instructions for implementing the specified logical function (s) . In some alternative implementations, the functions noted in the block may be implemented in an order different from those illustrated in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustration, and combinations of blocks in the block diagrams and / or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or by combinations of special purpose hardware and computer instructions.
[0087] Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are contained in the above discussions, these should not be construed as limitations on the scope of the present disclosure, but rather as descriptions of features that may be specific to particular embodiments. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment may also be implemented in multiple embodiments separately or in any suitable sub-combination.
[0088] A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed by hardware or software depends on particular applications and design constraints of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.
[0089] It may be clearly understood by a person skilled in the art that, for the purpose of convenient and brief description, for a detailed working process of the foregoing system, apparatus, and unit, refer to a corresponding process in the foregoing method embodiment. Details are not described herein again.
[0090] In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the described apparatus embodiment is merely an example. For example, the unit division is merely logical function division and may be other division in actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented through some interfaces. The indirect couplings or communication connections between the apparatuses or units may be implemented in electronic, mechanical, or other forms.
[0091] The units described as separate parts may be or may not be physically separate, and parts displayed as units may be or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units may be selected based on actual requirements to achieve the objectives of the solutions of the embodiments.
[0092] In addition, functional units in the embodiments of this application may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit.
[0093] When the functions are implemented in a form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer readable storage medium. Based on such an understanding, the technical solutions in this application essentially, or the part contributing to the prior art, or some of the technical solutions may be implemented in a form of a software product. The computer software product is stored in a storage medium, and includes several instructions for instructing a computer device (which may be a personal computer, a server, a network device, or the like) to perform all or some of the steps of the methods described in the embodiments of this application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM) , a random access memory (Random Access Memory, RAM) , a magnetic disk, or an optical disc.
[0094] The foregoing descriptions are merely specific implementations of this application, but are not intended to limit the protection scope of this application. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in this application shall fall within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.
Claims
1.A method of establishing a web socket connection, comprising:receiving, at a server from a client, a frame indicating a request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing the server;validating the first token extracted from the header of the frame;in response to validating the first token being valid, generating a second token for establishing a web socket connection between the client and the server based on the first token; andtransmitting the second token from the server to the client.2.The method of claim 1, wherein the second token is associated with an expiration period during which the web socket connection between the client and the server is allowed to be established, and the second token is expired out of the expiration period.3.The method of claim 1, wherein generating the second token based further on at least one of the following:an identifier of the request;a random ticket; oran origin-header from the client.4.The method of claim 1, wherein the request for obtaining the token for establishing a web socket connection is a first request, and the method further comprises:receiving, from the client, a second request for establishing the web socket connection between the client and the server, wherein second request comprises the second token;validating the second token; andin response to validating the second token being valid, determining to establish the web socket connection.5.The method of claim 4, wherein receiving the second request comprises:receiving the second request via a hardened cookie.6.The method of claim 4, wherein the first request comprises a hypertext transfer protocol (HTTP) post request, and the first token comprises a bearer token.7.The method of claim 1, wherein the client comprises a browser, and the client and the server are in a browser / server architecture.8.A method of establishing a web socket connection, comprising:determining, at a client, a frame indicating a first request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing a server;transmitting the frame indicating the first request to the server;receiving, from the server, a second token for establishing a web socket connection between the client and the server generated by the sever based on the first token; andtransmitting, to the server, a second request for establishing the web socket connection between the client and the server, wherein the second request comprises the second token.9.The method of claim 8, wherein at least of the following:the second token is associated with an expiration period during which the web socket connection between the client and the server is allowed to be established;the second token is expired out of the expiration period;the first request comprises a hypertext transfer protocol (HTTP) post request;the first token comprises a bearer token;the client comprises a browser; orthe client and the server are in a browser / server architecture.10.The method of claim 8, further comprising:transmitting the second request via a hardened cookie.11.An apparatus of establishing a web socket connection, comprising:a receiving module configured to receive, at a server from a client, a frame indicating a request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing the server;a validating module configured to validate the first token extracted from the header of the frame;a generating module configured to generate, in response to validating the first token being valid, a second token for establishing a web socket connection between the client and the server based on the first token; anda transmitting module configured to transmit the second token from the server to the client.12.An apparatus of establishing a web socket connection, comprising:a determining module configured to determine, at a client, a frame indicating a first request for obtaining a token for establishing a web socket connection, wherein a header of the frame comprises a first token used for accessing a server;a first transmitting module configured to transmit the frame indicating the first request to the server;a receiving module configured to receive, from the server, a second token for establishing a web socket connection between the client and the server generated by the sever based on the first token; anda second transmitting module configured to transmit, to the server, a second request for establishing the web socket connection between the client and the server, wherein the second request comprises the second token.13.An electronic device, comprising:a processor; anda memory coupled to the processor, wherein the memory has instructions stored therein, and the instructions, when executed by the processor, cause the device to execute actions of any of claims 1-7 or 8-10.14.A computer-readable medium having instructions stored therein, which when executed by a processor, cause the processor to perform a method of any of claims 1-7 or 8-10.15.A computer program product having instructions stored therein, which when executed by a processor, cause the processor to perform a method of any of claims 1-7 or 8-10.
Citation Information
Patent Citations
Network communication safety protection method and device
CN105450587A
Websocket connection method and websocket connection system based on token authentication
CN112492017A
Access control method, device and system
CN115996122A
Method for enhancing network application security
US20100077216A1