Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snehamgithub/authendication_authorization
Authendication_Authorization
https://github.com/snehamgithub/authendication_authorization
bcrypt cors dotenv expressjs jwt nodejs nodemon
Last synced: 17 days ago
JSON representation
Authendication_Authorization
- Host: GitHub
- URL: https://github.com/snehamgithub/authendication_authorization
- Owner: SnehaMgithub
- Created: 2024-10-26T20:07:36.000Z (19 days ago)
- Default Branch: main
- Last Pushed: 2024-10-27T07:02:27.000Z (19 days ago)
- Last Synced: 2024-10-28T01:13:00.587Z (18 days ago)
- Topics: bcrypt, cors, dotenv, expressjs, jwt, nodejs, nodemon
- Language: JavaScript
- Homepage: https://authendication-authorization-gqda.onrender.com
- Size: 23.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 Token
This project is a Node.js-based application that implements user authentication and authorization using Bearer tokens. The application follows the Model-View-Controller (MVC) pattern and utilizes Express.js, Mongoose (MongoDB), and JWT for token-based authentication.
## Project Overview
This application provides a secure user registration and login system using JWT (JSON Web Tokens) for token-based authentication. The user data is stored in a MongoDB database, and the application follows the MVC architecture for better separation of concerns. The application also includes a protected route for fetching user information, accessible only with a valid JWT.
## Tech Stack
- **Node.js**: JavaScript runtime used for server-side development.
- **Express.js**: Web framework for Node.js to build RESTful APIs.
- **Mongoose**: MongoDB ODM for modeling application data.
- **JWT (jsonwebtoken)**: Used to generate and verify Bearer tokens for secure authentication.
- **Postman**: For API testing and documentation.## Features
- **User Registration**: Users can register with `username`, `email`, `password`, and `role`.
- **Password Hashing**: User passwords are hashed using `bcrypt` before saving them to the database.
- **User Login**: Users can log in with their email and password. A JWT is returned upon successful login.
- **JWT Authentication**: JWTs are used to authenticate requests. A middleware function verifies the token and attaches user information to the request object.
- **Protected Routes**: A protected route for fetching user information, accessible only by providing a valid JWT.
- **API Documentation**: Postman collection for testing and sample API requests.## API Documentation
For detailed API documentation, including request/response examples, you can refer to the full Postman documentation:https://documenter.getpostman.com/view/39168825/2sAY4sjjZz