Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Merge pull request #21 from facundoolano/development
Browse files Browse the repository at this point in the history
v 0.0.5
  • Loading branch information
facundoolano committed Nov 4, 2015
2 parents 26ab33d + 8b2cc46 commit 3ad8ec2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# socketio-auth [![Build Status](https://secure.travis-ci.org/invisiblejs/socketio-auth.png)](http://travis-ci.org/invisiblejs/socketio-auth)
# socketio-auth [![Build Status](https://secure.travis-ci.org/facundoolano/socketio-auth.png)](http://travis-ci.org/facundoolano/socketio-auth)

This module provides hooks to implement authentication in [socket.io](https://github.com/Automattic/socket.io) without using querystrings to send credentials, which is not a good security practice.

Expand Down Expand Up @@ -76,7 +76,7 @@ function postAuthenticate(socket, data) {
}
```
* `timeout`: The amount of millisenconds to wait for a client to authenticate before disconnecting it. Defaults to 1000.
* `timeout`: The amount of millisenconds to wait for a client to authenticate before disconnecting it. Defaults to 1000. The value 'none' disables the timeout feature.
## Auth error messages
Expand Down
18 changes: 10 additions & 8 deletions lib/socketio-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var debug = require('debug')('socketio-auth');
* @param {Function} config.authenticate - indicates if authentication was successfull
* @param {Function} config.postAuthenticate=noop - called after the client is authenticated
* @param {Number} [config.timeout=1000] - amount of millisenconds to wait for a client to
* authenticate before disconnecting it
* authenticate before disconnecting it. A value of 'none' means no connection timeout.
*/
module.exports = function socketIOAuth(io, config) {
config = config || {};
Expand Down Expand Up @@ -53,13 +53,15 @@ module.exports = function socketIOAuth(io, config) {

});

setTimeout(function() {
// If the socket didn't authenticate after connection, disconnect it
if (!socket.auth) {
debug('Disconnecting socket %s', socket.id);
socket.disconnect('unauthorized');
}
}, timeout);
if (timeout !== 'none') {
setTimeout(function() {
// If the socket didn't authenticate after connection, disconnect it
if (!socket.auth) {
debug('Disconnecting socket %s', socket.id);
socket.disconnect('unauthorized');
}
}, timeout);
}

});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socketio-auth",
"version": "0.0.4",
"version": "0.0.5",
"description": "Authentication for socket.io",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 3ad8ec2

Please sign in to comment.