Download the PHP package zainburfat/rbac without Composer
On this page you can find all versions of the php package zainburfat/rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zainburfat/rbac
More information about zainburfat/rbac
Files in zainburfat/rbac
Package rbac
Short Description This package allows you to manage user permissions and roles in a database and authentication and authorization
License MIT
Informations about the package rbac
⚠️ DEPRECATED — DO NOT INSTALL
This package is unmaintained and contains security defects. It should not be used in any application.
A full audit is in AUDIT.md: 22 findings, five of them critical. The most serious:
- It adds a public, unauthenticated user-registration endpoint (
POST /rbac_register) to any application that installs it — with no validation, no email uniqueness check, no password rules and no rate limiting. - It breaks the host application on install.
routes/api.phpreferences a controller class whose namespace does not match its PSR-4 path, so it can never autoload — and the service provider loads that route file unconditionally. - It runs a database query during
boot(), sophp artisan migratefails on a fresh install and every HTTP request pays a full table scan. - Authorization failures return HTTP 200. Any client checking
response.oktreats a denied request as successful. php artisan config:cachefails, because the config file returns Carbon objects.
It also targets Laravel 8/9 and Passport 10. Passport::routes() was removed in Passport 11, so this cannot run on any currently supported version regardless.
Use this instead
A complete rewrite against the same idea, with the above fixed and 32 tests running against SQLite, PostgreSQL and MySQL:
→ zain-ul-abdain/laravel-route-permissions
The most important design change: permissions derive from route names rather than controller class names. In this old version, renaming a controller silently changed the required permission string and orphaned every grant referencing it — authorization breaking during an ordinary refactor, with no error.
This repository is kept public and archived for reference and for the audit. It is not a maintained package.
Original README (2022), unchanged below
Laravel - Role Based Access Control
Custom Route Wise Access Control
This package allows you to manage user permissions and roles in a database and Authentication and Authorization
- Custom RBAC user based roles and permissions package
- Custom RBAC provides flexibility to use Laravel/Passport in a manner of minutes.
Prerequisites
Commands
Run migrations:
Install Passport:
Use trait in the "User" model:
To exclude some methods/class from creating permissions of them just add "@exclude-permission" in the docs block of class/method you want to exclude.
Permissions are created dynamically through command according to the controllers having methods:
Define an api authentication guard and set the driver option to passport in config/auth.php:
Publish config file
Set token expirations inside config\customrbac.php:
Use PermissionsApi middleware to authorize user to specific Api route and for web routes use PermissionsWeb middleware
app/http/kernel.php under protected $routeMiddleware:
Login and register using package's route
For Login use paramenters ('email', 'passport')
For Register use paramenters ('name', 'email', 'passport')