Skip to content

Instantly share code, notes, and snippets.

@techitesh
Last active October 4, 2019 04:47
Show Gist options
  • Save techitesh/b6702cb952640fa2d9dc21e6b9554121 to your computer and use it in GitHub Desktop.
Save techitesh/b6702cb952640fa2d9dc21e6b9554121 to your computer and use it in GitHub Desktop.
Passport Basic Auth
const passport = require('passport')
const BasicStrategy = require('passport-http').BasicStrategy
passport.use(new BasicStrategy(
function(userid, password, done) {
if(userid !== 'admin') return done(null, false)
if(password !== 'admin@123') return done(null, false)
if(userid == 'admin' && password == 'admin@123') {
return done(null,true)
}
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment