gooyoung / Node Auth
Licence: mit
基于 Node Express Mongoose 实现的用户注册/登陆权限验证
Stars: ✭ 10
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Node Auth
Securing Restful Apis With Jwt
How to secure a Nodejs RESTful CRUD API using JSON web tokens?
Stars: ✭ 301 (+2910%)
Mutual labels: mongoose, mongodb, express, authorization
Mern Boilerplate
Fullstack boilerplate with React, Redux, Express, Mongoose, Passport Local, JWT, Facebook and Google OAuth out of the box.
Stars: ✭ 112 (+1020%)
Mutual labels: mongoose, mongodb, express, authorization
Express Graphql Mongodb Boilerplate
A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).
Stars: ✭ 288 (+2780%)
Mutual labels: mongoose, mongodb, express, authorization
Node Express Mongodb Jwt Rest Api Skeleton
This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API). Demo of frontend in VueJS here: https://github.com/davellanedam/vue-skeleton-mvp
Stars: ✭ 603 (+5930%)
Mutual labels: mongoose, mongodb, express
Express Boilerplate
🚀 Starter project for a RESTful API in Node with Express & mongoose component-based
Stars: ✭ 9 (-10%)
Mutual labels: mongoose, mongodb, express
Jianshu
仿简书nx+nodejs+nestjs6+express+mongodb+angular8+爬虫
Stars: ✭ 296 (+2860%)
Mutual labels: mongoose, mongodb, express
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: ✭ 307 (+2970%)
Mutual labels: mongoose, mongodb, express
Mevn Cli
Light speed setup for MEVN(Mongo Express Vue Node) Apps
Stars: ✭ 696 (+6860%)
Mutual labels: mongoose, mongodb, express
Nodepress
😎 RESTful API service for Blog/CMS, powered by @nestjs
Stars: ✭ 829 (+8190%)
Mutual labels: mongoose, mongodb, express
Node Express Boilerplate
A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose
Stars: ✭ 890 (+8800%)
Mutual labels: mongoose, mongodb, express
Blog Node
基于 node + express + mongodb 的博客网站后台
Stars: ✭ 364 (+3540%)
Mutual labels: mongoose, mongodb, express
Nodejs Api Boilerplate
A boilerplate for kickstart your nodejs api project with JWT Auth and some new Techs :)
Stars: ✭ 364 (+3540%)
Mutual labels: mongoose, mongodb, express
Nodejs Restful Api
How to create a RESTful CRUD API using Nodejs?
Stars: ✭ 285 (+2750%)
Mutual labels: mongoose, mongodb, express
Node Express Mongoose Demo
A simple demo app using node and mongodb for beginners
Stars: ✭ 4,976 (+49660%)
Mutual labels: mongoose, mongodb, express
Express Mongoose Es6 Rest Api
💥 A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (+28010%)
Mutual labels: mongoose, mongodb, express
Typescript Express Starter
🚀 TypeScript Express Starter
Stars: ✭ 238 (+2280%)
Mutual labels: mongoose, mongodb, express
Meantorrent
meanTorrent - MEAN.JS BitTorrent Private Tracker - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js, A BitTorrent Private Tracker CMS with Multilingual, and IRC announce support, CloudFlare support. Demo at:
Stars: ✭ 438 (+4280%)
Mutual labels: mongoose, mongodb, express
Vue Node Pastime
😄 基于vue全家桶、nodejs和mongodb的前后端整合项目
Stars: ✭ 200 (+1900%)
Mutual labels: mongoose, mongodb, express
Saas
Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
Stars: ✭ 2,720 (+27100%)
Mutual labels: mongoose, mongodb, express
Bulletproof Nodejs
Implementation of a bulletproof node.js API 🛡️
Stars: ✭ 4,369 (+43590%)
Mutual labels: mongoose, mongodb, express
基于 Node Express Mongoose 实现的用户注册/登陆权限验证
项目介绍
-
路由设计
- POST /api/signup: 用户注册
- POST /api/user/accesstoken: 账号验证,获取token
- GET /api/user/info: 获得用户信息,需验证
-
user 模型
- name : 用户名
- password: 密码
- token: 验证相关token
-
目录结构
├── index.js 入口页面 ├── passport.js 配置权限模块所需功能 ├── package.json npm包配置文件 ├── config.js 配置MongoDB数据库连接和token的密钥。 ├── models 模型文件夹 │ └── user.js 用户模型 ├── routers 路由相关文件 │ ├── index.js 路由入口 │ └── users.js 根组 ├── static 可以删除 └── README.md
-
依赖包
- express : 基于 Node.js 平台的 web 应用开发框架
- mongoose: 与MongoDB数据库进行交互的框架,需提前安装好mongodb并开启mongodb服务
- morgan: 将程序请求过程的信息显示在Terminal中,方便调试
- jsonwebtoken : 用来生成token
- passport: 权限验证库
- bcryptjs: 对用户密码进行hash加密。bcrypt的优化版,不需要安装任何依赖
{
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"jsonwebtoken": "^7.1.9",
"mongoose": "^4.7.1",
"morgan": "^1.8.1",
"passport": "^0.3.2",
"passport-http-bearer": "^1.0.1"
}
}
运行
git clone https://github.com/gooyoung/Node-Auth.git
npm install
node index
服务器运行在 localhost:8080/
使用 Postman 测试
注册一个账号
- url:localhost:8080/api/signup
- method:POST
设置body
的Content-Type
为x-www-form-urlencoded
以便我们的body-parser
能够正确解析。
key | value |
---|---|
name | zivhe |
password | 123456 |
用MongoChef连接数据库可以看到password被加密保存了
获取专属token
- url:localhost:8080/api/user/accesstoken
- method:POST
如果name或者password输错会返回验证失败。
获取用户信息
- url:localhost:8080/api/user/info
- method:GET 在head中加入token信息
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].