Skip to content

Instantly share code, notes, and snippets.

@iriefish
Created June 18, 2011 03:19
Show Gist options
  • Save iriefish/1032766 to your computer and use it in GitHub Desktop.
Save iriefish/1032766 to your computer and use it in GitHub Desktop.
Everyauth example with vhosts
var express = require('express'),
Everyauth = require('everyauth').Everyauth,
app = express.createServer();
var auth1 = new Everyauth();
// Google
auth1.googlehybrid
.myHostname('http://region1.example.com')
.consumerKey('CONSUMER KEY')
.consumerSecret('CONSUMER SECRET')
.scope([])
.findOrCreateUser( function (session, attrs) {
return attrs;
})
.entryPath('/auth/google')
.redirectPath('/');
site1 = express.createServer(
express.bodyParser(),
express.cookieParser(),
express.session({ secret: "secret" }),
auth1.middleware(),
express.logger()
);
site1.get('/', function (req, res) { res.send('Region 1'); });
app.use(express.vhost('region1.example.com', site1));
var auth2 = new Everyauth();
// Google
auth2.googlehybrid
.myHostname('http://region2.example.com')
.consumerKey('CONSUMER KEY')
.consumerSecret('CONSUMER SECRET')
.scope([])
.findOrCreateUser( function (session, attrs) {
return attrs;
})
.entryPath('/auth/google')
.redirectPath('/');
site2 = express.createServer(
express.bodyParser(),
express.cookieParser(),
express.session({ secret: "secret" }),
auth2.middleware(),
express.logger()
);
site2.get('/', function (req, res) { res.send('Region 2'); });
app.use(express.vhost('region2.example.com', site2));
app.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment