简体   繁体   中英

WebSocket Headers in NodeRED on IBM bluemix

I know that WebSocket api not defined headers.

  1. As per this we can set the basic auth with the URL.

ws = new WebSocket("ws://username:password@example.com/service")

In NodeRED(WebSocket IN node) need to authenticate users that connect only with provided username and password. Please let me know handle this in NodeRED ?

  1. Next alternative is Sec-WebSocket-Protocol header on client. I have tried with that also. But Node-RED unable to view, what ever I have set.
 var token = "eyJhbGci"; var options = { headers: { "Authorization" : token } }; var ws = new WebSocket("wss://example.com/path", options);

Please let me know how to view these client inputs in NodeRED and do proper client authentication ? I only see the following.

{ "payload": "Hi1", "_session": { "type": "websocket", "id": "fddc366c.0223c8" }, "_msgid": "47061971.b8f9e8" }

At this time I don't think it's possible.

Node-RED doesn't have access to the HTTP Upgrade request that converts the HTTP connection to a WS connection which is where any authentication would have to happen.

It is something that should probably be looked at in more detail to see if there is anything that could be done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM