最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何护照的身份验证功能,知道哪些认证要求?

运维笔记admin14浏览0评论

如何护照的身份验证功能,知道哪些认证要求?

如何护照的身份验证功能,知道哪些认证要求?

该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);
    });
发布评论

评论列表(0)

  1. 暂无评论