EasyRTC Documentation

Documentation

EasyRTC: Authentication

By default EasyRTC allows all connections, however it can be locked down to work against a variety of authentication methods. Most commonly this is done by sending a username and credential upon connecting to the server.

Even if authentication is not needed, setting the username can be used to create a visible alternative to the easyrtcid.

Setting Username and Credential in JS Client

easyrtc.setUsername()

easyrtc.setCredential()

Checking Authentication On Server

Using "authenticate" Event Listener

The "authenticate" event is fired during the initial connection. The listener is provided with full details about the connection, so it may decide whether to authenticate or disconnect them.

In this simplistic example, any clients connecting to the adminSite application will be denied unless they have a username of "handsomeJack". Any clients connecting to any other application will be let through.

var onAuthenticate = function(socket, easyrtcid, appName, username, credential, easyrtcAuthMessage, next){
  if (appName == "adminSite" && username != "handsomeJack"){
    next(new easyrtc.util.ConnectionError("Failed our private auth."));
  }
  else {
    next(null);
  }
};

easyrtc.events.on("authenticate", onAuthenticate);

Listener Parameters:

For more information about EasyRTC server events, see easyrtcserverevents.md

If You Run Into Problems

Please feel free to post on our discussion forum: