Skip to content

Instantly share code, notes, and snippets.

@superfeedr
Created October 7, 2012 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superfeedr/3849734 to your computer and use it in GitHub Desktop.
Save superfeedr/3849734 to your computer and use it in GitHub Desktop.
// Ideal OAuth 2 (may be insane, impractical), also, lots of default behavior, all customizable, of course by some mechanism of your choice
app.get('/my-protected-resource', passport.authenticate('mechanism'), function(req, res, end) {
// Do stuff that requires to be logged in
});
// Now the middleware does all the hard work: redirect to the oauth provider of choice (or to a 'dummy' page where the user can choice theirs and then to it, handle the dance, add all the required information to the session, and finally redirect the user to /my-protected-resource when the user was eventually logged in! How does that sound?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment