View Code? Open in Web Editor
NEW
Node.js+Mongoose的RestfulApi的用户token权限验证(just a demo)
nauth-restful-api's Introduction
- 👋 Hi, I’m @Nicksapp
- 👀 I’m interested in FE
- 🌱 I’m currently learning Web
- 💞️ I’m looking to collaborate on Frond End
- 📫 How to reach me [email protected]
nauth-restful-api's People
Contributors
nauth-restful-api's Issues
代码看下来,感觉只是一个 JWT token,没有涉及到太多的接口安全的问题,比如说 api接口请求放篡改,请求过期(token过期只是一种,允许匿名访问的资源请求过期怎么处理)都没有涉及到
const UserSchema = new Schema({
name: {
type: String,
unique: true, // 不可重复约束
required: true // 不可为空约束
},
password: {
type: String,
required: true
},
token: {
type: String
}
});
文档中写到GET访问localhost:8080/api/users/info, 应该是 localhost/8080/api/user/user_info。写的不错,之前一直不清楚这块。赞。
session key保存在database里,没有expire。也没有logout。所以session key一直可以用
Cannot GET /api/users/info