-
Notifications
You must be signed in to change notification settings - Fork 1
roles permissions
The data-primals-engine implements a robust Role-Based Access Control (RBAC) system to manage user authorizations. This system relies on two core models: role and permission, allowing for granular control over what users can access and perform within the platform.
A Permission defines a specific action or access right within the system. Permissions can be very broad (e.g., "admin.full_access") or highly specific (e.g., "product.edit").
-
name(string, required): A unique identifier for the permission (e.g.,model.create,product.read,user.delete). -
description(richtext, optional): A detailed explanation of what the permission grants. -
filter(code - JSON, optional): A JSON filter that restricts the scope of this permission. This is a powerful feature for implementing granular access control. For example, aproduct.editpermission could have a filter{ "owner": "{_user}" }to allow a user to only edit products they own. The target model is typically deduced from the permission name (e.g.,product.editimplies theproductmodel).
A Role is a collection of permissions. Instead of assigning individual permissions to each user, you assign roles, which simplifies management. A user can have multiple roles.
-
name(string, required, unique): The name of the role (e.g.,Administrator,Editor,Viewer). -
permissions(multiple relation topermissionmodel): A list ofpermissiondocuments associated with this role. Any user assigned this role will inherit all its permissions.
-
Define Permissions: Create specific
permissiondocuments for every action or resource you want to control. Use thefilterfield for fine-grained control. -
Create Roles: Group relevant permissions into
roledocuments. -
Assign Roles to Users: Assign one or more
roledocuments to eachuserdocument.
When a user attempts an action (e.g., accessing an API endpoint or modifying a data entry), the system checks if the user's assigned roles grant them the necessary permissions. If a permission has a filter, that filter is applied to the data access query, ensuring the user only interacts with allowed subsets of data.
The userPermission model allows for exceptions to the standard role-based permissions. This model can grant or revoke specific permissions for an individual user, either permanently or temporarily.
-
user(relation tousermodel): The user for whom the exception applies. -
permission(relation topermissionmodel): The specific permission being granted or revoked. -
isGranted(boolean, required):trueto grant the permission,falseto explicitly revoke it. -
expiresAt(datetime, optional): If set, the exception is temporary.
This comprehensive RBAC system ensures that your data-primals-engine application remains secure and that users only have access to the functionalities and data they are authorized to use.
Next: Automation with Workflows