Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zakircodearchitect/mern-role-based-access
This backend authentication system, built with the MERN stack, provides user login, registration, and role-based access control. Users can register as admin, manager, or user, with each role having specific permissions and access to resources. Designed for use in educational applications where access is controlled based on user roles.
https://github.com/zakircodearchitect/mern-role-based-access
backend-api express-middleware javascript jwt-auth jwt-authentication jwt-tokens nodejs-server role-based-access-control server
Last synced: 11 days ago
JSON representation
This backend authentication system, built with the MERN stack, provides user login, registration, and role-based access control. Users can register as admin, manager, or user, with each role having specific permissions and access to resources. Designed for use in educational applications where access is controlled based on user roles.
- Host: GitHub
- URL: https://github.com/zakircodearchitect/mern-role-based-access
- Owner: ZakirCodeArchitect
- Created: 2024-10-26T17:54:02.000Z (24 days ago)
- Default Branch: main
- Last Pushed: 2024-10-27T16:03:10.000Z (23 days ago)
- Last Synced: 2024-10-27T16:54:37.257Z (23 days ago)
- Topics: backend-api, express-middleware, javascript, jwt-auth, jwt-authentication, jwt-tokens, nodejs-server, role-based-access-control, server
- Language: JavaScript
- Homepage:
- Size: 3.21 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MERN Authentication & Role-Based Access Control (RBAC) System
This project is a backend authentication system built with the MERN stack, designed for educational applications. It supports role-based access control (RBAC) with roles such as `admin`, `user`, and `manager`, allowing specific features to be restricted based on the user's role.
## Features
- 🔑 **User Authentication**: Register and log in with JWT for session management.
- 🛡 **Role-Based Access Control**: Restrict access based on roles.
- 🔒 **Protected Routes**: Middleware to control route access by role.
- 🗝 **Password Hashing**: Secure password storage using bcrypt.
- ⚠️ **Error Handling**: Consistent, secure API responses.## Tech Stack
- **Backend**: Node.js, Express
- **Database**: MongoDB with Mongoose
- **Authentication**: JSON Web Tokens (JWT), bcrypt## Prerequisites
- [Node.js](https://nodejs.org/)
- [MongoDB](https://www.mongodb.com/)## Getting Started
Follow these instructions to set up and run the project locally.
### 1. Clone the Repository
```bash
git clone https://github.com/your-username/mern-auth-rbac.git
cd mern-auth-rbac## API Endpoints
### Auth Routes
| Method | Endpoint | Description |
|--------|-------------------------|---------------------------|
| POST | `/api/auth/register` | Register a new user |
| POST | `/api/auth/login` | Login with user credentials |### User Routes
| Method | Endpoint | Description | Access Level |
|--------|--------------------------|----------------------------------------|--------------------|
| GET | `/api/users` | Retrieve all users | Admin only |
| GET | `/api/users/:id` | Retrieve a specific user by ID | Admin/Manager |### Role-Based Access
| Role | Permissions |
|---------|------------------------------------------------------------------|
| Admin | Full access to all routes and resources |
| Manager | Access to specific management features |
| User | Limited access to general features |