tumobi / nideshop

NideShop 开源微信小程序商城服务端 API(Node.js + ThinkJS)

Home Page:https://www.nideshop.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

可以手动遍历生成token,且在校验的token的时候没有校验iat

Zhuangshao opened this issue · comments

https://github.com/tumobi/nideshop/blob/master/src/api/controller/auth.js#L42
这里可以看到 token 是通过 userId 生成的。
userId 在数据库 nideshop_user 中,生成方式是递增的,可以计算出来。
Token 使用了 jwt.sign 函数来生成,而且secret是硬编码的(没有提示要配置成自己的secret),可以直接通过该secret和上面获得的userid来计算一个token。
正常情况jwt在计算的时候会自己带上iat(一个时间戳),但是在校验token的时候,又没有对iat进行校验,而是直接获取了user_id。
https://github.com/tumobi/nideshop/blob/master/src/api/service/token.js#L18
所以可以通过这种方式来生成别的用户的token来使用。