Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2012 21:00
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 jaredhanson/3854950 to your computer and use it in GitHub Desktop.
Save jaredhanson/3854950 to your computer and use it in GitHub Desktop.
Sketch RelMeAuth strategy for Passport
// mapping relmeauth provider support to local URLs for initiating
// authentication, using OAuth, OAuth 2.0, or just about anything else
passport.use(new RelmeStrategy({
'': '/auth/twitter'
'': '/auth/facebook'
function(token, profile, done) {
// relme auth is mostly a discovery mechanism, which redirects
// the the highest-priority, supported provider. The verify
// callback would likely be handled best by the configured
// FacebookStrategy, TwitterStrategy, etc. Having a verify
// callback here is debatable, and likely not needed
passport.use(new TwitterStrategy({
callbackURL: ""
passport.use(new FacebookStrategy({
callbackURL: "http://localhost:3000/auth/facebook/callback"
// Mount the protocol routes. This can be trivially wrapped in a single
// function if it seems too boilerplate.
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/',
failureRedirect: '/login' }));
app.get('/auth/twitter', passport.authenticate('twitter'));
app.get('/auth/twitter/callback', passport.authenticate('twitter', { successRedirect: '/',
failureRedirect: '/login' }));'/auth/relme', passport.authenticate('relme'));
app.get('/login', /* render the following form */);
<form action="/auth/relme" method="post">
<input type="text" name="me"/><br/>
<input type="submit" value="Submit"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment