mirror of
https://github.com/expressjs/expressjs.com.git
synced 2026-02-22 03:51:33 +00:00
570 B
570 B
basicAuth()
Basic Authentication middleware, populating req.user
with the username.
Simple username and password:
app.use(express.basicAuth('username', 'password'))
Callback verification:
app.use(express.basicAuth(function (user, pass) {
return user === 'tj' && pass === 'wahoo'
}))
Async callback verification, accepting fn(err, user),
in this case req.user will be the user object passed.
app.use(express.basicAuth(function (user, pass, fn) {
User.authenticate({ user: user, pass: pass }, fn)
}))