Skip to content

Instantly share code, notes, and snippets.

@robwormald
Last active January 4, 2016 07:49
Show Gist options
  • Save robwormald/8591577 to your computer and use it in GitHub Desktop.
Save robwormald/8591577 to your computer and use it in GitHub Desktop.
// ../api/auth/methods.js
exports.basicAuth = passport.authenticate('basic',{session : false})
//../api/auth/passport.js
passport.use(new BasicStrategy(
function(username, password, done) {
done(null,{id : 1, username : 'somefakeusername'})
}
))
// ../routes.js
app.get('/api/v1/users/me', api.auth.basic, api.v1.users.current.retrieve)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment