-
Hi folks -- I'd like to protect my I have run in to trouble when supporting connections initiated from other domains in the browser, or connections from other servers running nodejs. I have a pre-shared secret (an api key of sorts or a JWT, whatever floats your boat) that the JS on the other domain has access to and proves that that client should be able to start a connection, but I am wondering how you would recommend passing it to the server.
Is there an easy way to send a secret in one of the init messages in the Thanks for any pointers you can give me! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey there! The client It allows you to pass a payload with the On the server-side, use the |
Beta Was this translation helpful? Give feedback.
Hey there! The client
connectionParams
option is what you're seeking.It allows you to pass a payload with the
ConnectionInit
message.ConnectionInit
MUST be the first message that the connection transmits, and should therefore be used for authorization. In addition to this, there is a specific timeout within which the client MUST send this message to the server, if the server does not receive it in time - it will close the connection with a:4408: Connection initialisation timeout
. Read more about theConnectionInit
message in the Protocol.On the server-side, use the
onConnect
option to authenticate the connection and respond accordingly.