in the passport [configure authentication] documentation, it has a rather scary-looking function that uses the mysterious function \"done.\'
passport.use(new
Let's back up because I think you may have some confusion.
Express is a web application framework. It's responsible for directing users to resources, in a very broad sense.
Passport is a authentication framework. It's responsible for making sure that users are allowed to access said resources.
In both frameworks there is a idea of middleware. Middleware is basically generalized control flow. For example, in some Express framework you could say:
Make sure parameter x is valid when requesting route /user/:x
Make sure the user has a session, etc
And when all middleware has been executed, then we execute the application
For example,
router.get('/', function(req, res) { // when the '/' route is requested
res.render('index', { title: 'Express' }); // send index.html
});
In Passport, they also use the idea of middleware, however, instead of next(), they use done()
and it's a little more complex.
See this page for more info
http://toon.io/understanding-passportjs-authentication-flow/