Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aneathaarse/jwt-task
Authedication / Authorization (JWT)
https://github.com/aneathaarse/jwt-task
bcrypt dotenv express mongodb nodejs postman
Last synced: about 1 month ago
JSON representation
Authedication / Authorization (JWT)
- Host: GitHub
- URL: https://github.com/aneathaarse/jwt-task
- Owner: AneathaaRse
- Created: 2024-11-07T09:26:21.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2024-11-07T09:28:41.000Z (about 2 months ago)
- Last Synced: 2024-11-07T10:31:07.663Z (about 2 months ago)
- Topics: bcrypt, dotenv, express, mongodb, nodejs, postman
- Language: JavaScript
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
User Authentication and Authorization with Bearer Tokens
This project is a Node.js application that implements user authentication and authorization using Bearer tokens. It follows the MVC pattern and utilizes MongoDB for data storage, JWT for token-based authentication, and Express.js for routing. API documentation is provided for testing and reference.
Features :
User Registration: Allows new users to register with a unique email and password. Passwords are securely hashed before being saved to the database.
User Login: Registered users can log in with valid credentials to receive a JWT (JSON Web Token) for authorization.
Token Verification: Middleware is used to verify the JWT from the request headers, allowing only authenticated users to access certain routes.
User Information Retrieval: Authenticated users can retrieve their information using their token.Technologies Used:
Node.js
Express.js
MongoDB with Mongoose
JWT (jsonwebtoken)
bcryptjs for Password Hashing
Postman for API documentation and testingError Handling :
Each endpoint includes error handling to provide meaningful responses in cases of failed authentication, missing fields, or invalid credentials. Errors are returned with appropriate HTTP status codes and messages.Documentation :
All API endpoints are documented with sample requests and responses. Use Postman to import this documentation and easily test each endpoint.