PHPackages                             vishveshbusa/rbac - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vishveshbusa/rbac

ActiveLibrary

vishveshbusa/rbac
=================

Complete RBAC (Role-Based Access Control) package for Laravel - transforms a fresh Laravel installation into a fully featured RBAC system with authentication, permissions, roles, and complete UI scaffolding.

v1.0.0(2mo ago)02↓100%MITJavaScriptPHP ^8.2

Since Mar 5Pushed 2mo agoCompare

[ Source](https://github.com/vishveshbusa803/package-RBAC)[ Packagist](https://packagist.org/packages/vishveshbusa/rbac)[ RSS](/packages/vishveshbusa-rbac/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Param RBAC - Laravel RBAC Package
=================================

[](#param-rbac---laravel-rbac-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6d463b66db26d8bdce64c26c3ae2d32c288ed246377760bb754ffa426f8ecb81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7669736876657368627573612f726261632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vishveshbusa/rbac)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A comprehensive Role-Based Access Control (RBAC) package for Laravel that transforms a fresh Laravel installation into a fully featured RBAC system with authentication, permissions, roles, and complete UI scaffolding.

⚠️ **Important Note**
---------------------

[](#️-important-note)

**This package is designed for fresh Laravel projects only.**

⚡ When you run the installation command, it will:

- Remove all default Laravel scaffolding (controllers, models, views, authentication UI)
- Replace it with the complete RBAC UI and system
- Modify your existing `composer.json` dependencies

**⚠️ MAKE SURE YOUR PROJECT IS BACKED UP** before installing this package, as it will significantly modify your project structure and configurations.

🎯 Features
----------

[](#-features)

- **Complete RBAC System** - Role-based access control with permissions and roles
- **Authentication System** - Multi-factor authentication support (2FA, Email OTP, Mobile OTP, CAPTCHA)
- **User Management** - Complete user CRUD operations with role assignment
- **Permission Management** - Create and manage module-based permissions
- **Role Management** - Full role lifecycle management with permission assignment
- **Beautiful UI** - Bootstrap 5-based responsive admin template
- **Database Migrations** - Pre-configured database structure
- **Seeders** - Sample data and admin user creation
- **Middleware** - Custom middleware for authentication and authorization
- **Service Providers** - Laravel service provider integration

📋 Requirements
--------------

[](#-requirements)

- PHP ^8.2
- Laravel ^10|^11|^12
- Composer
- Node.js &amp; npm (for asset compilation)

⚙️ Installation
---------------

[](#️-installation)

Install the package via Composer:

```
composer require vishveshbusa/rbac:1.0.0
```

Run the installation command:

```
php artisan param-rbac:install --force
```

Run migrations:

```
php artisan migrate:fresh --seed
```

Build frontend assets:

```
npm install
npm run dev
```

📁 Package Structure
-------------------

[](#-package-structure)

```
param-rbac/
├── src/
│   ├── ParamRbacServiceProvider.php
│   └── Console/
│       └── InstallCommand.php
├── stubs/
│   ├── app/
│   │   ├── Http/
│   │   │   ├── Controllers/
│   │   │   ├── Middleware/
│   │   │   └── Kernel.php
│   │   ├── Models/
│   │   ├── Providers/
│   │   └── Exceptions/
│   ├── database/
│   │   ├── migrations/
│   │   └── seeders/
│   ├── resources/
│   │   ├── views/
│   │   ├── js/
│   │   └── scss/
│   ├── public/
│   │   └── assets/
│   ├── routes/
│   └── config/
├── composer.json
└── README.md

```

🔐 Authentication Methods
------------------------

[](#-authentication-methods)

The package supports multiple authentication methods that can be configured via the `authentication_settings` table:

### 1. **CAPTCHA** - Image-based verification

[](#1-captcha---image-based-verification)

- Verify user is human with image captcha
- Default: Disabled

### 2. **EMAIL\_VERIFY** - Email OTP verification

[](#2-email_verify---email-otp-verification)

- Send one-time password to user email
- Default OTP: `111111`
- Expires: 10 minutes
- Attempts: 3

### 3. **MOBILE\_VERIFY** - Mobile OTP verification

[](#3-mobile_verify---mobile-otp-verification)

- Send one-time password to user phone
- Default OTP: `222222`
- Attempts: 3

### 4. **TWO\_FACTOR** - Google Authenticator 2FA

[](#4-two_factor---google-authenticator-2fa)

- TOTP-based two-factor authentication
- Default Code: `333333`
- Uses google-authenticator mobile app

👥 Default Users
---------------

[](#-default-users)

After installation, the following default user is created:

EmailPasswordRole`admin@example.com``password`Admin🛠️ Configuration Files
----------------------

[](#️-configuration-files)

Key configuration files published by the package:

- `config/app.php` - Application settings
- `config/auth.php` - Authentication configuration
- `config/database.php` - Database configuration
- `config/permission.php` - Spatie permission settings
- `config/mail.php` - Mail/SMTP settings

📚 Database Structure
--------------------

[](#-database-structure)

### Key Tables

[](#key-tables)

- `users` - User accounts
- `roles` - Available roles
- `permissions` - System permissions
- `role_has_permissions` - Role-permission relationships
- `model_has_roles` - User-role assignments
- `authentication_settings` - Auth method configurations
- `user_two_factor` - 2FA secret keys
- `password_rules` - Password policy configurations

🔄 Workflow
----------

[](#-workflow)

### User Registration/Login Flow

[](#user-registrationlogin-flow)

```
1. User submits login credentials
2. CAPTCHA verification (if enabled)
3. Credentials validation
4. Email OTP verification (if enabled)
5. Mobile OTP verification (if enabled)
6. Two-Factor Authentication (if enabled)
7. Session established and user logged in

```

🎭 Role &amp; Permission Manager
-------------------------------

[](#-role--permission-manager)

### Creating Roles

[](#creating-roles)

Navigate to **Admin &gt; Roles &gt; Create Role** and:

1. Enter role name
2. Select permissions (grouped by module)
3. Click "Create"

### Managing Permissions

[](#managing-permissions)

Navigate to **Admin &gt; Permissions** to:

- Create new permission modules with operations
- Edit existing permission structures
- Delete permissions (if not assigned)
- View permission assignments

### Assigning Roles to Users

[](#assigning-roles-to-users)

In **User Management**:

1. Select a user
2. Choose one or more roles
3. Save changes

🔧 Customization
---------------

[](#-customization)

### Modifying Authentication Settings

[](#modifying-authentication-settings)

Edit the `authentication_settings` table:

```
UPDATE authentication_settings
SET IsEnabled = 1
WHERE AuthCode = 'TWO_FACTOR';
```

### Adding Custom Controllers

[](#adding-custom-controllers)

Place custom controllers in `app/Http/Controllers/`:

```
