jeremykenedy/laravel-roles
jeremykenedy/laravel-roles is a comprehensive Laravel package for managing user roles and permissions. It provides migrations, models, middleware, Blade directives, and an optional admin interface to create roles, assign permissions, and protect routes with ease.
auth:api, so any authenticated user could enumerate every role, permission and user, and create roles. If you have the API on, treat this as an unauthenticated-privilege-escalation class bug that has been live, not a feature upgrade.ROLES_API_MIDDLEWARE_ENABLED is now a real switch rather than decoration. Decide deliberately whether role/permission/user data is exposed over JSON at all, and to whom; the flag gives you a documented rollback (false restores the old, unsafe behaviour — useful only as a temporary compatibility shim while you fix callers, not as a steady state).role/permission/level middleware now return 403 instead of a 500 with a stack trace. Correct, but it changes what your front end and any consumer sees — error handling, monitoring alerts and tests that assert on 500 need review.roles:install --css=… --force, roles:update, roles:switch all run unattended, so framework choice becomes a provisioning parameter in Dockerfiles, CI and config-as-code instead of a manual step. Supports standardising admin UI per environment.getPermissions() no longer issues a query per user when the relation is loaded (per-page cost on large user lists), and bulk restore/destroy now run in a transaction and report outcomes rather than silently half-applying. Both are the kind of thing that quietly blocks scaling an admin area past a few hundred users.Adopt when:
docs/ folder (install, config, roles, permissions, levels/inheritance, blade & middleware, GUI, artisan, API, seeding, testing, upgrading) materially lowers onboarding and support cost.Look elsewhere when:
rolesAPIMiddleware/rolesAPIMiddlewareEnabled deliberately, and the package defaults (role:admin) are a starting point, not a policy.For executives (one paragraph): The admin area that governs who can do what in our application had two genuine security defects. When its JSON API was switched on, any logged-in user — not just administrators — could read every role, permission and user record and create new roles, because the routes ignored the middleware settings the package itself ships. Separately, role and permission names were rendered unescaped, so anyone permitted to create a role could plant script that would run inside the next administrator's session. v13.0.0 closes both, hardens the remaining output escaping, and comes back with a clean composer audit. The same release adds Bootstrap 5 and Tailwind admin themes so the screens match our design system, scriptable install/update commands, and a full documentation set. The upgrade is low-effort and requires no data migration.
For engineering leads: Treat this as a security upgrade, not a feature upgrade. Three things to plan for. First, the breaking change: the API route group now builds middleware from config, so audit every consumer of the roles endpoints and confirm rolesAPIMiddleware (default role:admin) is the policy you actually want — ROLES_API_MIDDLEWARE_ENABLED=false is a stopgap only, since it reinstates the insecure behaviour. Second, denials now return 403 rather than a 500 with a stack trace; update client error handling, alerts and any test asserting the old status. Third, Laravel 11 is out of the test matrix — the package still declares support, and the GUI fixes cover 11+, but our own verification should focus on 12/13. Regression scope: API authorization paths, admin GUI rendering under whichever CSS framework we select, and bulk restore/destroy flows, which now run in transactions and report partial failures instead of failing quietly.
For the roadmap conversation: This release removes the blockers to using the package in compliance-adjacent contexts (stored XSS fixed, dependency audit clean, 403 semantics correct) and removes the design-system objection (Bootstrap 5 / Tailwind view sets, default unchanged so existing installs look identical). It also keeps the option open to standardise the admin UI through ROLES_CSS_FRAMEWORK in provisioning rather than maintaining custom views. The residual questions are strategic, not technical: whether we want a roles/permissions JSON API exposed at all, and how long we intend to sit on a framework line the maintainer no longer tests against.
How can I help you explore Laravel packages today?