如何护照的身份验证功能,知道哪些认证要求?
该passport docs用此来保护路线:
app.get('/api/me',
passport.authenticate('basic', { session: false }),
function(req, res) {
res.json(req.user);
});
authenticate()
如何知道哪些认证要求?我不请求传递给它。
该passport.authenticate
返回的功能。
你可以试试这个
console.log(passport.authenticate('basic', { session: false }));
它会打印出像
function(req, res, next){ ... }
这意味着app.get
会是这个样子你的应用程序启动后,
app.get('/api/me',
function(req, res, next){
// now passport has access to the "req" even though you didn't pass request to it
// passport's authentication logic here
},
function(req, res) {
res.json(req.user);
});