Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Zhuangshao opened this issue Aug 10, 2020 · 0 comments

Comments

@Zhuangshao
Copy link

Zhuangshao commented Aug 10, 2020

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来使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant