我需要带有Passport.js的JWT吗?

问题描述

我一直在使用Auth0在我的反应网页上创建用户帐户。它使用发送到服务器的JWT来验证和保护路由。

我现在正在开发一个使用Auth0和Passport.js的基于Express的应用程序。服务器使用中间件函数调用.isAuthenticated()函数,以检查用户是否已登录。我的客户端正在询问是否应“升级”该系统以使用JWT而不是使用此中间件。你们可以指导我吗?我应该尝试将他的网站更改为使用JWT吗?

谢谢!

这是所有路由的中间件功能-

const isLoggedIn = (request,response,next) => {
// if user is authenticated in the session,carry on
if (request.isAuthenticated())
    return next();
// if they aren't,redirect them to the home page
response.redirect('/login');
};

我在护照文件中找到了该方法-现在,我想我需要弄清楚_passport是什么,以便查看其安全性。

/**
* Test if request is authenticated.
*
* @return {Boolean}
* @api public
*/
  req.isAuthenticated = function() {
    var property = 'user';
    if (this._passport && this._passport.instance) {
      property = this._passport.instance._userProperty || 'user';
    }

 return (this[property]) ? true : false;

};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)