Skip to content

November 2026 · RBAC · Laravel · React · Security

Planning RBAC Centrally for a School System

A school has more kinds of user than most businesses. This is how I planned roles and permissions so one rule change does not mean hunting through the whole codebase.

Planning RBAC Centrally for a School System

The problem with scattered checks

My school product covers students, fees, exams, attendance, payroll and a public website. The system it replaced listed 27 modules, each with its own idea of who could do what. If permission logic lives in every controller, it will drift. A menu shows a link, the page returns an error, and nobody can say what an accountant is really allowed to do. So I made one decision early: permissions would be data, kept in one place, and everything else would read from there.

How the plan is laid out

There are three tables that matter: roles, permissions and the link between them. A user has one role, a role has many permissions, and a permission is a plain name such as fee.collect. Seeders create the permission list and the default role mapping, so a new installation starts in a known state. Adding a feature means adding a permission name in one seeder. That list has quietly become the most useful document in the project, because it describes the whole system in one screen.

One rule, checked at the door

Every protected route passes through a single CheckPermission middleware. It answers 401 if you are not logged in and 403 if your role lacks the permission, and the response is always the same shape. It also checks that the role itself is active, so switching off a role takes effect at once. The front end hides menu items and buttons based on the same permission names, but that is only a courtesy to the user. The real decision always happens on the server.

Roles are not enough

This is the part I underestimated. Knowing someone is a teacher does not tell you which classes are theirs. Permissions answer what you can do, and scoping answers which records you can do it to. I wrote a separate plan comparing model scopes, reusable traits, global scopes and filter classes, and went with reusable traits inside a shared repository. Global scopes are tempting, but they cause surprises in reports and in data moved between sessions.

What changes for the SaaS version

Selling this to many schools by subscription adds one more layer. Today the question is whether this role can do something. Tomorrow it is also whether this school’s plan includes it at all. I plan to keep those as two separate checks: the plan decides which modules exist for a school, and roles decide who uses them inside it. Mixing the two would be a mistake I would pay for every time pricing changes.

What I would tell myself at the start

Name permissions by action, not by screen, because screens get redesigned and actions rarely do. Seed them from code so every environment matches. And write the tests that check someone is refused, not only the ones that check someone gets in. A broken feature gets reported the same day. A permission that quietly allows too much can sit there for a year.

Md. Fawjul Azim

Focusing on building high-performance web applications with modern tech stacks.