【发布时间】:2016-12-13 22:51:41
【问题描述】:
我在我的应用程序中使用 JWT,我这样定义我的声明:
const claims = {
iss: process.env.DOMAIN, // The URL of your service
sub: user.email, // The UID of the user in your system
scope: "game",
email: user.email
};
虽然这可以正常工作,但我不喜欢将会话数据添加到声明对象中以使其在前端也可用的想法。相反,我只想在后端保留某些会话数据,例如:
nJwt.verify(socket.handshake.query.token, app.get("jwt.secret"), (err, decoded) => {
if (err) return;
// pseudo code
Session.of(decoded.body.email).get("cheater_accuracy"); // 0.48912715
});
对我来说理想的方法是让声明对象像这样简单:
const claims = {
iss: process.env.DOMAIN,
sub: user.email,
scope: "game",
email: user.email
};
并将每个会话数据仅保留在后端,可以随时通过令牌引用。
有什么办法吗?
【问题讨论】:
标签: node.js session express socket.io jwt