KudosAbhay / nodeAuth

JWT Based Authentication in Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nodeAuth

This app has the following major functionalities -

  • Generation of JWT Tokens
  • Validation of User using using that JWT Token
  • Updation of User password via PATCH Requests

Endpoint functionality (Public Endpoints)

Generation of New Token
  • Generation of New Token to Log In based on user Identity (Request body should contain an arbitrary username)
  • Returns a signed Json Web Token, which can be used to validate future requests.
Validation of Token
  • The JWT obtained in the “Login” endpoint must be present in request. If the JWT is missing or invalid, user will not be able to sign in.
  • Returns a Response message mentioning if the request is invalid or successfull for loggin in.
Updation of Password
  • Using the username existing password can be changed. Existing “uname“ must be present in the request.
  • Returns a Response message mentioning if the request is invalid or successfull for changing user password

Test Suite

Setup

Usage

  • Start the server with npm start
  • Run the test suite with npm test

What's new?

  • Added MySQL Compatibility. Credentials are now stored and retrieved from MYSQL Database
  • Appropriate statusCodes and responses attached to responses for all APIs

List of APIs

  • tokenGenerator - To Generate a New Token for new User based on username and password
  • tokenValidator - To Validate if a user is a returning user, dependent on the token provided
  • userUpdater - To update existing user's password based on his / her username

About

JWT Based Authentication in Node.js


Languages

Language:JavaScript 100.0%