Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzawa committed Aug 27, 2013
1 parent 9b72350 commit 0eb6913
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -12,3 +12,6 @@ logs
results

npm-debug.log
node_modules

.DS_Store
2 changes: 2 additions & 0 deletions .npmignore
@@ -0,0 +1,2 @@
test
Makefile
4 changes: 4 additions & 0 deletions .travis.yml
@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.8
- 0.10
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013 nkzawa
Copyright (c) 2013 Naoyuki Kanezawa

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
25 changes: 25 additions & 0 deletions index.js
@@ -0,0 +1,25 @@
var passport = require('passport');


exports.initialize = function() {
var fn = passport.initialize();

return function initialize(socket, next) {
var req = socket.request
, res = req.res;

fn(req, res, next);
};
};

exports.session = function() {
var fn = passport.session();

return function session(socket, next) {
var req = socket.request
, res = req.res;

fn(req, res, next);
};
};

28 changes: 28 additions & 0 deletions package.json
@@ -0,0 +1,28 @@
{
"name": "socket.io-passport",
"version": "0.0.0",
"description": "Passport middleware for upcoming Socket.IO 1.0",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/mocha --reporter dot"
},
"keywords": [
"auth",
"authentication",
"connect",
"socket.io",
"passport",
"middleware"
],
"author": "Naoyuki Kanezawa <naoyuki.kanezawa@gmail.com>",
"license": "MIT",
"dependencies": {},
"devDependencies": {
"passport": "*",
"socket.io": "nkzawa/socket.io",
"socket.io-client": "nkzawa/socket.io-client",
"socket.io-bundle": "*",
"mocha": "*",
"chai": "*"
}
}
17 changes: 17 additions & 0 deletions test/index.js
@@ -0,0 +1,17 @@
var passport = require('../')
, expect = require('chai').expect;


describe('socket.io-passport', function() {
it('should create initialization middleware', function() {
var initialize = passport.initialize();
expect(initialize).to.be.a('function');
expect(initialize.length).to.equal(2);
});

it('should create session restoration middleware', function() {
var session = passport.session();
expect(session).to.be.a('function');
expect(session.length).to.equal(2);
})
});

0 comments on commit 0eb6913

Please sign in to comment.