Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/negativo/JWT-Auth-NodeJS-Starter-Kit

a Simple implementation of JWT Token auth with NodeJS and Express
https://github.com/negativo/JWT-Auth-NodeJS-Starter-Kit

auth javascript jwt mongodb nodejs

Last synced: about 2 months ago
JSON representation

a Simple implementation of JWT Token auth with NodeJS and Express

Awesome Lists containing this project

README

        

# Simple Node JWT-Token Authentication starter kit.

![alt tag](http://i.imgur.com/vlLzUe4.gif)

This repo uses JSON Web Tokens and the [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) package to implement token based authentication on a simple Node.js API with a MongoDB Database.

This is a starting point to have an API up and running in notime.

The Api Features:

- JWT Auth Token
- User Management

##Installation

###With Docker

- edit `.env.example` and save it as `.env`
- docker-compose up

###Without Docker

This project needs NodeJS > v5.0.0, MongoDB and `forever` to manage the process.

- clone the project `git clone [email protected]:negativo/JWT-Auth-NodeJS-Starter-Kit`
- run `npm install`
- run `mongod`
- edit `.env.example` and save it as `.env`
- `npm start`
- `npm test`

##API

###Setup test user

To setup an admin user edit your `.env` file and request the url `http://localhost:8282/setup`

`curl http://localhost:8282/setup`

###Versioning

###Authenticate

To authenticate a user do a POST request to http://localhost:8282/auth
with the `name` and the `password` in the body

{
name:"jwtauth",
password:"jwtauth"

}

`curl -H "Content-Type: application/json" -X GET http://localhost:8080/setup`
`curl -H "Content-Type: application/json" -X POST -d '{ "name":"user","password":"password"}' http://localhost:8080/api/auth`