Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ AdminControl-RBAC Public template

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

64 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

🚀 Quick Start: The system automatically creates dummy data (roles, permissions, and users) when the server starts if the database is empty. No manual setup required!

Dummy Role-Based Login Credentials

Admin

Dev

Viewer


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


🌱 Auto-Seeding Feature

The application automatically seeds the database with dummy data when the server starts if the collections are empty:

Default Permissions

  • read: Permission to view and read data
  • write: Permission to create and edit data
  • delete: Permission to delete data

Default Roles

  • Admin: Full access with read, write, and delete permissions
  • Dev: Developer access with read and write permissions
  • Viewer: View-only access with read permission

Default Users

Three test users are automatically created with the credentials listed above. This allows you to:

  • Start testing immediately without manual setup
  • Understand the RBAC system with pre-configured examples
  • Sign up new users with existing roles and permissions

Note: The seeding only happens once when collections are empty. Existing data is never overwritten.

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages