简体   繁体   中英

WebRTC Node.JS WebSocket Server, Block a Request if WSS Parameter is Not 1

I would like that the node Web Socket server (command: node /root/server.js) will refuse connection if PARAM is not 1. Connection like this will be refused: wss://example.com/socket.io/?**PARAM**=**0**&EIO=3&transport=websocket

server.js looks like this(EasyRTC Framework): https://github.com/open-easyrtc/open-easyrtc/blob/master/server_example/server_ssl.js

I finally realized it's actually not that simple (doing inside server.js if PARAM.= 1 then exit), Anyone can confirm this complexity or offer a simple solution. without recommending complex authentication frameworks. Also can't see that EasyRTC Framework will offer something like this.

Can someone lead me in the right direction because I am lost.

Thank you

I crawled all the EasyRTC Group, there is an authentication system for node server.js web socket and it's very simple:

var onAuthenticate = function(socket, easyrtcid, appName, username, credential, easyrtcAuthMessage, next){
// do your checks
next(null); // Run next with a null if they are allowed in / or if not the socket is "disconnected" for them not for others.
};
easyrtc.events.on("authenticate", onAuthenticate);

Tested and works perfectly. More testing will follow.

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