Tag: token

Angular Node – 在打开新的浏览器窗口时向服务器发送令牌

这个问题是不言自明的:我有一个令牌存储在我的浏览器。 当我login时,服务器端authentication中间件使用Passport来authentication我。 但是,当我closures并重新打开浏览器窗口时,令牌仍然存在,但护照不知道我是谁。 我怎样才能从客户端到服务器端检索令牌? 以下是我的代码。 app.get('/main', ensureAuthenticated, function(req, res, next) { // thingToSend gets sent the first time, I will modify it // later so it doesn't resend token if token exists var thingToSend = { token: createSendToken(req.user, config.secret), id: req.user._id, username: req.user.username, authorization: req.user.authorization }; res.render('main.ejs', thingToSend); }); function ensureAuthenticated(req, res, next) { if […]

要存储jwt令牌未解码的服务器端或不?

原谅我,如果这是一个愚蠢的问题。 正如标题所要求的,为每个请求解码令牌服务器端是不是很昂贵,存储和查找未解码的令牌不是更好吗? 你会将会话令牌存储在nodejs对象或mongodb中吗? Mongodb将是另一次往返,但是你可以使用_id轻松地find(请纠正我,如果我错了,我正在学习,所以我build议/资源=非常欢迎!)