Roles and Permissions
The role-based access control system (RBAC) in Brezel is designed to give you fine-grained control over who can do what in each module. This guide will help you understand how permissions work and how to manage them.
Root user
Section titled “Root user”Users with "root": true in their configuration have full access to all modules and entities,
as well as the ability to create and manage workflows.
If you copied the default configuration
from the Brezel repository,
the root user is usually the first user created in the system.
You must set the root user in the .bake configuration file like this:
[{ "resource_user": "root_user", "resource": { "module": "users", "client": "${resource_client.global_client}", "root": true, "fields": { "name": "Root user", "email": "root@my-company.com", "password": "secret" } }}]Users have no permissions by default. You must assign them to roles to give them access to modules and entities.
Each role has a matrix of permissions that define what users can do in each module. When you create a new user, you assign them to one or more roles to give them access to the modules and entities they need. Operations that require permissions are protected by the system and will return an error if the user does not have the necessary permissions, return only the data the user is allowed to see, or silently prevent the user from performing the operation (e.g. by not overwriting a field).
You can add role modules to Brezel using .bake configuration files:
[{ "resource_module": "roles", "resource": { "identifier": "roles", "type": "roles", "icon": "user-group", "title": "name" }}]Roles are added to users by setting the roles field either in the UI, or in the user configuration:
[{ "resource_entity": "users", "resource": { "module": "users", "fields": { "name": "Accountant", "email": "test@example.com", "password": "secret", "roles": ["${resource_entity.accountant}"] } }}]Permissions
Section titled “Permissions”Here is a simple approximation of how the Brezel UI would display role permissions:
| [] | Module | Read | Create | Update | Delete | History |
|---|---|---|---|---|---|---|
| ✅ | Invoices | ✅ | ✅ | ✅ | ✅ | ✅ |
| ⏺️ | Products | ✅ | ❌ | ❌ | ✅ | ✅ |
| ❌ | Customers | ❌ | ❌ | ❌ | ❌ | ❌ |
As you can see, there are five operations: create, read, update, delete, and history.
The symbols in the table represent the permissions for each operation: ✅ means the operation is allowed, ❌ means it is denied, and ⏺️ means it is partially allowed.
You can set permissions per operation or per module. If you set permissions per operation, you can allow or deny each operation individually. In the example above, users can create, read, update, and delete invoices, and their product operations follow the matrix below. If you set permissions per module, you can allow or deny all operations at once.
The above matrix corresponds to the following configuration:
[{ "resource_entity": "roles", "resource": { "module": "roles", "fields": { "name": "Accountant", "slug": "accountant", "modules": { "invoices": true, "products": { "create": false, "read": true, "update": true, "delete": false, "history": true, "fields": true }, "customers": { "create": false, "read": false, "update": false, "delete": false, "history": false, "fields": true } } } }}]Field reads follow module read access when fields is omitted; writes require explicit field write access. See field permissions.
Permission reference
Section titled “Permission reference”- Field read/write permissions
- Entity filters and policies
- Role inheritance
- Client isolation and UI
- Abilities: Brezel 3.x availability
The legacy permissions module is enabled only with use_deprecated_permissions in system configuration. New configurations should use roles and policies.