BrowserID allows you to implement incredibly convenient website authentication without any storage requirements.
Signed cookies allow you to implement sessions without any server storage requirments.
The connect framework let's zap together web applications with redonkulous efficiency.
connect-browserid puts the first two together in a way that's crazy easy to use in the third. It's magic.
npm install connect-browserid
app.use(express.session);
app.use(require('connect-browserid')({
secret: "yabba dabba do",
audience: "https://example.com"
}.authUser());
app.use(app.router);
This middleware must come after session but before router middlewares.
if (req.user) res.send('hi ' + req.user);
else res.send('I don't know you.');
navigator.id.getVerifiedEmail(function(assertion) {
if (assertion) {
$.post("/auth", assertion, function(res) {
if (res.success) alert("now you're logged in as: " + res.user);
else alert("log in failure: " + res.reason);
});
}
});