To manage permissions in your application, you don't need to touch the code structure. Instead, you simply add or modify records in specific database tables. The system uses a Role-Based Access Control (RBAC) model.
If you need a new type of user (e.g., "Editor"), you simply add a row to the roles table.
rolesIf you create a new feature (e.g., a "Blog"), you need to register it as a resource.
resourcesThis is the most important part. To say "Editors can update blog posts", you link the three concepts together in the role_resource_permissions table.
role_resource_permissionsYou repeat this for every action you want to allow (e.g., one row for "read", another for "create").
Finally, to give a user these powers, you just assign them the role.
users| Table Name | Purpose |
|---|---|
roles | Define who exists (Admin, Guest, etc.). |
resources | Define what exists (Products, Orders, etc.). |
permissions | Define actions (Create, Read, Update, Delete). |
role_resource_permissions | The Master Switch. Connects Role + Resource + Action. |
users | Assigns a Role to a specific person via the Role field. |
Public (unauthenticated) access is controlled by the public role in the database. Assign permissions to the public role to allow access to resources for non-logged-in users.