feathersjs/canjs-feathers — pull request #1 by marshallswain (2014-04-18 04:40:52+00:00)
Title: Enabled custom connect queries for socket.io.  Needed for token auth

Added a second parameter for using a custom query with socket.io. This is useful and required for using token authentication.

```js
var token = $.cookie('feathers-token');
can.Feathers.connect('',{
query: 'token=' + token
});
```

Although I do plan to dive into Primus soon, I haven't taken the time to figure out token auth for Primus, so this will probably only work for socket.io unless they have the same connect() api.

Here's an example of how this would be used to setup socket.io auth on the server side:
```js
app.configure(feathers.socketio(function(io) {

io.set('authorization', function (handshake, callback) {

if (handshake.query.token) {

// where decodeToken can be any script for decoding a token
decodeToken(handshake.query.token, function(err, data){
if (err) {
console.log(err);
} else if (data.email) {
handshake.feathers = {
user: data
};
callback(null, true);
}
});

} else {
callback(null, false);
}
});

}));
```