rt所示 , 超过12小时token失效
用这个包 https://www.npmjs.com/package/jsonwebtoken
@jingsam 我用的koa-jwt 目前想直接在secret加个时间值,不知道koa-jwt可以直接设置不
为什么不仔细看下文档呢?
You can specify audience and/or issuer as well:
app.use(jwt({ secret: 'shared-secret', audience: 'http://myapi/protected', issuer: 'http://issuer' }));
If the JWT has an expiration (exp), it will be checked.
@jingsam 找到了 https://cnodejs.org/topic/557d647216839d2d53936351 ths
后面找到了,在这里记录一下
const jwt = require("jsonwebtoken"); let userToken = { id: '123', name: "lmx" }; // 12h 表示 12小时 jwt.sign(userToken, "secret", { expiresIn: "12h" }) // 也可以这样 60 seconds * 60 minutes * 12 = 12 hour jwt.sign(userToken, "secret", { expiresIn: 60 * 60 * 12 });
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
用这个包 https://www.npmjs.com/package/jsonwebtoken
@jingsam 我用的koa-jwt 目前想直接在secret加个时间值,不知道koa-jwt可以直接设置不
为什么不仔细看下文档呢?
You can specify audience and/or issuer as well:
If the JWT has an expiration (exp), it will be checked.
@jingsam 找到了 https://cnodejs.org/topic/557d647216839d2d53936351 ths
后面找到了,在这里记录一下