This project demonstrates the implementation of JSON Web Tokens (JWT) for authentication and authorization in a web application.
It is an implementation of the following article: https://medium.com/@prashantramnyc/authenticate-rest-apis-in-node-js-using-jwt-json-web-tokens-f0e97669aad3
To convert Epoch and Unix Timestap: https://www.epochconverter.com/
To inspect JWT-tokes: https://jwt.io/
- User authentication with JWT
- Token-based authorization
- Secure password storage
- Token expiration and renewal
- Clone the repository:
git clone https://github.com/yourusername/jwt-token.git
- Navigate to the project directory:
cd jwt-token
- Install dependencies:
npm install
-
Start the authentication server:
npm run authenticateServer
-
Start the validation server:
npm run validateServer
-
Add users using POST localhost:4000/user {"name" : "name","password" : "password"}
-
Login using POST localhost:4000/login {"name" : "name","password" : "password"}
-
Access using GET localhost:5000/posts (until accesstoken expires) add accesstoken to Authorization / type OAuth 2.0
-
Refresh token using POST localhost:4000/refreshToken {"name" : "name","token" : "refreshtoken"}
-
Access using GET localhost:5000/posts (until access token expires) add accesstoken to Authorization / type OAuth 2.0
-
Logout using DELETE localhost:4000/logout {"token" : "refreshtoken"}
-
POST localhost:4000/user ({"name":"name","password":"password"} in Body )
-
POST localhost:4000/login ({"name":"name","password":"password"} in Body )
This project is licensed under the MIT License.