https://github.com/alphapeter/socket.io-express
socket io authorization using express session (express 3)
https://github.com/alphapeter/socket.io-express
Last synced: 3 months ago
JSON representation
socket io authorization using express session (express 3)
- Host: GitHub
- URL: https://github.com/alphapeter/socket.io-express
- Owner: alphapeter
- License: mit
- Created: 2012-09-10T13:38:10.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-09-10T16:35:12.000Z (almost 13 years ago)
- Last Synced: 2025-04-13T07:55:58.223Z (3 months ago)
- Language: JavaScript
- Size: 189 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# socket.io-express
`socket.io-express` is a library for using express session for authorization of socket.io-connections.
Tested with socket.io 0.9.10 and express 3# usage
``` js
express...
var express = require('express')
var RedisStore = require('connect-redis')(express);
var redisStore = new RedisStore( { host:config.redis.address, port: config.redis.port });
var cookieParser = express.cookieParser('supersecret');
app.configure(function(){
... // your configurations
app.use(cookieParser);
app.use(express.session({store: redisStore}));
... // your configurations
});socket.io...
var authFunction = require('./socket.io-express.js').createAuthFunction(cookieParser, redisStore);
io.set('authorization', authFunction);# meta
There were a lot of inaccurate blog posts of how to use express (v.3) sessions with socket.io,
so I created this simple library.Peter Klaesson