Skip to content

Gulshan-gaur/User_AUTH_NODEJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Nodejs User authentication system

Token-based Authentication

Token-Auth is a Token-based Authentication system. It generates token and stores them in local storage with user informations. It verifies provided token from HTTP Header (Authorization) in order to allow access to protected end point api.

Installation

Get the sources:

git clone https://github.com/Gulshan-gaur/User_AUTH_NODEJS.git

NodeJS

In order to start the nodejs server, we need express and node_modules dependencies.

Install the nodejs dependencies:

home$ npm install

Start the server:

home$ node index.js

Usage

Generates a token and stores it

home$ curl http://localhost:3001/signin

This send back the generated token for later usage.

Access protected endpoint

home$ curl --header 'Authorization: AUTH Generated_Token' http://localhost:3001/protected

Expire a token

home$ curl --header 'Authorization: AUTH Generated_Token' http://localhost:3001/expire

Stack

  • Node.js
  • Passport