https://github.com/nimjetushar/jwt-authentication-solution
End to end solution for authentication using JWT
https://github.com/nimjetushar/jwt-authentication-solution
expressjs jwt-authentication jwt-tokens nodejs react-client refresh-tokens
Last synced: 2 months ago
JSON representation
End to end solution for authentication using JWT
- Host: GitHub
- URL: https://github.com/nimjetushar/jwt-authentication-solution
- Owner: nimjetushar
- License: apache-2.0
- Created: 2018-09-16T06:15:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-10T04:47:14.000Z (over 2 years ago)
- Last Synced: 2025-06-09T14:05:49.861Z (about 1 year ago)
- Topics: expressjs, jwt-authentication, jwt-tokens, nodejs, react-client, refresh-tokens
- Language: JavaScript
- Homepage:
- Size: 516 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jwt authentication solution
[](https://semaphoreci.com/nimjetushar/jwt-authentication-solution)
[](https://www.codacy.com/app/tushar/jwt-authentication-solution?utm_source=github.com&utm_medium=referral&utm_content=nimjetushar/jwt-authentication-solution&utm_campaign=Badge_Grade)
[](https://dependabot.com)
[](https://github.com/nimjetushar/jwt-authentication-solution/blob/master/LICENSE)
[](https://stackshare.io/nimjetushar/jwt-authentication-solution)

Project provide the end to end solution for authentication.
It covers following points:-
- User creation
- Login
- logout
- Reset password / Forget password
## Api
### Create new user
```
Request: POST
api: /api/auth/create
Request: { name: string;
email: string;
password: string; }
Success: Return user success message
```
### Login to create authorization token
```
Request: POST
api: /api/auth/login
Request: { username: string;
password: string; }
Success: { email: string;
name: string;
role: string;
token: string;
loginTime: number; }
```
### Logout from that particular session
```
Request: GET
api: /api/auth/logout
Require "authorization" Header with recived token.
```
### Verify user before changing password and issue reset token to process for change password request
```
Verifies if user exists and sends reset token which can be used to reset password by password serivice
Request: POST
api: /api/reset/verifyUser
Request: { email: string; }
Success: { resetToken: string;
email: string; }
```
### Upadate user password
```
Takes reset token which is send by verifyUser service
Request: POST
api: /api/reset/password
Request: { resetToken: string;
password: string;
confirmPassword: string;
email: string; }
```
### Verify received authorization token
```
Request: POST
api: /api/auth/verify
Require "authorization" Header with recived token.
```
### Client UI
```
Request: GET
api: /
Return client application which can be used to login / create user / change password.
```
### Options
Application configurations can be updated using config.js
1: Port
Default port is 8080 but can be updated as required.
2: db_url
DB url where authorization collection is present.
3: auth_token_timeout
Duration for which auth token send to client side will be valid.
Default is 1 day.
4: refresh_token_timeout
Duration for which refresh token will be valid which stats a logined user will be valid into application.
Default is 2 days.
5: reset_token_timeout
Duration for which password reset token is valid.
Default 5 min.
The implementaion is based on JWT tokken having concept of refresh tokken and auth tokken to keep user authenticated and reset token in case of password reset.
Server implementation can be verified using Client application which is present in `/client`.
## Usefull commands
Start client locally
```npm run client```
Start server locally
```npm run server```
Build client and server
```npm run build```