Skip to content

An RBAC system in React and Node.js restricts access based on user roles. Node.js handles role verification, while React dynamically renders components, ensuring users only access resources aligned with their privileges, enhancing security and efficient permission management.

Notifications You must be signed in to change notification settings

roxylius/AdminControl-RBAC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Admin Control - A Responsive Full-Stack Role-Based Access Control (RBAC) System

Dummy Role-Based Login Credentials

Admin

  • Email: admin@mail.com
  • Password: admin
  • Permissions: Can read, write, and delete.

Viewer

  • Email: viewer@mail.com
  • Password: viewer
  • Permissions: Can only read.

Dev

  • Email: dev@mail.com
  • Password: dev
  • Permissions: Can read and write.

System Components

1. Users Management

This component allows the admin to view, add, edit, or remove users.

Functionality
  - Add new user to the list
  - Edit exisiting user details
  - Delete user from the list
User Model
const UserModel = {
  name: String,
  email: { type: String, unique: true },
  role: String,
  permissions: [String],
  provider: String, //where did the user data come from 
  // password: { // Password field not required as it is being handled by passport-local-mongoose
  //     type: String,
  //     required: true
  // },
  data: Schema.Types.Mixed
}
API Endpoint

  1. /api/user/all

Method: GET Description: Retrieves a list of all users in the system.

  2. /api/user/add

Method: POST Description: Adds a new user to the system with specified details.

  3. /api/user/edit

Method: PUT Description: Updates the details of an existing user based on their email.

  4. /api/user/delete

Method: DELETE Description: Deletes a user from the system based on their email.

  5. /api/user

Method: GET Description: Retrieves the details of the currently authenticated user.


users

2. Roles Management

Allows defining and managing roles with varying permissions, including viewing, adding, editing, or removing roles.

Functionality
  - Add new role to the list
  - Edit exisiting role details
  - Delete user role the list
Role Model
const RoleModel = {
    name: String,          // Unique role name
    description: String,   // Description of the role
    permissions: [String]  // List of permissions assigned to the role
};
API Endpoint

  1. /api/role

Method: GET
Description: Retrieves a list of all roles in the system.

  2. /api/role/add

Method: POST
Description: Adds a new role to the system with specified details.

  3. /api/role/edit

Method: PUT
Description: Updates the details of an existing role based on its name.

  4. /api/role/delete

Method: DELETE
Description: Deletes a role from the system based on its name.


roles

3. User Profile

Displays the user's profile information, including personal details and settings.

profile


4. Permissions Management

Allows the admin to assign or revoke permissions and to view, add, edit, or remove roles.

Functionality
  - Add new permissions to the list
  - Edit exisiting permissions
  - Delete permission from the list
Permission Model
const PermissionModel = {
    name: String,          // Unique permission name
    description: String    // Description of the permission
};
API Endpoint

  1. /api/permission

Method: GET
Description: Retrieves a list of all permissions in the system.

  2. /api/permission/add

Method: POST
Description: Adds a new permission to the system with specified details.

  3. /api/permission/edit

Method: PUT
Description: Updates the details of an existing permission based on its name.

  4. /api/permission/delete

Method: DELETE
Description: Deletes a permission from the system based on its name.


permissions

5. Activity Log

Displays logs to track user actions and maintain system accountability.

Functionality
  - View logs of change in admin panel
  - store any edit, add and delete changes made to admin Control Panel 
Log Model
const LogModel = {
    name: String,          // User's name
    email: String,         // User's email
    role: String,          // User's role
    timestamp: String,     // Timestamp of the action
    action: String         // Description of the action performed
};
API Endpoint

  1. /api/logs

Method: GET
Description: Retrieves a list of all logs for auditing purposes.


log

6. Dashboard Overview

Provides a summary of the system's current state, including user statistics and role assignments.

dashboard

About

An RBAC system in React and Node.js restricts access based on user roles. Node.js handles role verification, while React dynamically renders components, ensuring users only access resources aligned with their privileges, enhancing security and efficient permission management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages