View Categories

Module Description for Module ‘User Roles’ v1

Version #

Version 1

Module Type #

Standard

Status #

Draft

Internal Name #

userRoles

Description #

In Version 1, the User Roles module allows administrators to define and manage system roles. Roles are identified by a numeric “Role Index” that indicates priority—higher indexes represent higher priority. Users can hold multiple roles at once, and each user must have at least one role to ensure they have a baseline set of permissions.

Role management includes creating new roles, updating existing ones, and assigning roles to users or removing them. This module works closely with the User Rights module, which uses each role”s index to determine the effective permissions a user receives when holding multiple roles. The module also supports basic error handling and logs events via webhooks for auditing.

This module has basic error handling.

User Journeys #

To be written.

Authentication #

Authentication for is managed via the Auth Module. Module-to-module communication in Version 1 does not require Authentication. Internal services can call the Admins Module freely.

Schema #

UserRoles #

NameTypeInternal NameDescription
role_idUUID/StringuserRoles.UserRoles.role_idA unique identifier for each role.
role_nameStringuserRoles.UserRoles.role_nameThe name of the role (e.g., “Customer”, “PremiumUser”).
role_descriptionStringuserRoles.UserRoles.role_descriptionA brief description of the role’s purpose and scope.
role_indexNumberuserRoles.UserRoles.role_indexA numeric value representing the role’s priority; higher indexes imply more extensive rights.

UserRolesAssignments #

NameTypeInternal NameDescription
mapping_idUUID/StringuserRoles.UserRolesAssignments.mapping_idA unique identifier for each user-role mapping.
user_idUUID/StringuserRoles.UserRolesAssignments.user_idThe identifier for the user in the mapping.
role_idUUID/StringuserRoles.UserRolesAssignments.role_idThe identifier for the role assigned to the user.

Functions #

NameEndpointDescriptionInternal NameInputResponse
createRole/userRoles/createCreates a new user role in the system.userRoles.CreateRole{“RoleName”: “PremiumUser”, “RoleDescription”: “Grants premium access to advanced features”, “RoleIndex”: 2}{“status”: “success”, “RoleID”: “role-1234”}
updateRole/userRoles/updateUpdates the details of an existing role.userRoles.CreateRole{“RoleID”: “role-1234”, “RoleDescription”: “Updated description”, “RoleIndex”: 3}{“status”: “success”}
deleteRole/userRoles/deletePermanently deletes a role from the system.userRoles.CreateRole{“RoleID”: “role-1234”}{“status”: “success”}
softDeleteRole/userRoles/softDeleteMarks a role as inactive without permanently removing it.userRoles.CreateRole{“RoleID”: “role-1234”}{“status”: “success”}
getRole/userRoles/getRetrieves details of a specific role by RoleID.userRoles.CreateRole{“RoleID”: “role-1234”}{“RoleID”: “role-1234”, “RoleName”: “PremiumUser”, “RoleDescription”: “Grants premium access to advanced features”, “RoleIndex”: 2}
listRoles/userRoles/listRetrieves a paginated list of all roles, with filtering and sorting.userRoles.CreateRole{“page”: 1, “pageSize”: 20}{“roles”: [/* Array of role objects */], “total”: 50}
assignRoleToUser/userRoles/assignRoleAssigns a role to a user. Each user must have at least one role.userRoles.CreateRole{“UserID”: “user-5678”, “RoleID”: “role-1234”}{“status”: “success”}
removeRoleFromUser/userRoles/removeRoleRemoves an assigned role from a user.userRoles.CreateRole{“UserID”: “user-5678”, “RoleID”: “role-1234”}{“status”: “success”}
listRolesForUser/userRoles/listRolesForUserRetrieves all roles assigned to a specific user.userRoles.listRolesForUsers{“UserID”: “user-5678”}{“roles”: [/* Array of role objects */]}
listUsersWithRole/userRoles/listUsersWithRoleRetrieves all users assigned to a specific role.userRoles.listUsersWithRole{“RoleID”: “role-1234”}{“users”: [/* Array of user objects */]}

Webhooks #

NameTriggerDestinationPayloadDescriptionError Handling
roleCreatedWhen a new user role is successfully created.Log Module{ “event”: “roleCreated”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “role”: { “RoleID”: “role-XXXX”, “RoleName”: “PremiumUser”, “RoleDescription”: “Grants premium access”, “RoleIndex”: 2 } }Sends a webhook notification to log the creation of a new user role.None
roleUpdatedWhen an existing user role is successfully updated.Log Module{ “event”: “roleUpdated”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “role”: { “RoleID”: “role-XXXX”, “UpdatedFields”: { “RoleDescription”: “Updated description”, “RoleIndex”: 3 } } }Notifies that a user role’s details have been updated.None
roleDeletedWhen a user role is permanently deleted.Log Module{ “event”: “roleDeleted”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “role”: { “RoleID”: “role-XXXX” } }Sends a webhook to log that a user role has been permanently removed from the system.None
roleSoftDeletedWhen a user role is marked as inactive (soft-deleted).Log Module{ “event”: “roleSoftDeleted”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “role”: { “RoleID”: “role-XXXX”, “status”: “soft-deleted” } }Notifies that a user role has been soft-deleted, making it inactive while retaining its record.None
roleRetrievedWhen the details of a user role are successfully retrieved.Log Module{ “event”: “roleRetrieved”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “role”: { “RoleID”: “role-XXXX”, “RoleName”: “PremiumUser”, “RoleDescription”: “Grants premium access”, “RoleIndex”: 2 } }Sends a notification that role information has been successfully fetched from the system.None
rolesListedWhen the listRoles function successfully retrieves all roles.Log Module{ “event”: “rolesListed”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “roles”: [ { “RoleID”: “role-XXXX”, “RoleName”: “PremiumUser”, “RoleIndex”: 2 } ] }Notifies that a complete list of user roles has been successfully fetched.None
roleAssignedWhen assignRoleToUser successfully assigns a role to a user.Log Module{ “event”: “roleAssigned”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “assignment”: { “UserID”: “user-XXXX”, “RoleID”: “role-XXXX” } }Notifies that a role has been successfully assigned to a user.None
roleRemovedWhen removeRoleFromUser successfully removes a role from a user.Log Module{ “event”: “roleRemoved”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “assignment”: { “UserID”: “user-XXXX”, “RoleID”: “role-XXXX” } }Notifies that a role has been successfully removed from a user.None
rolesForUserListedWhen listRolesForUser successfully retrieves all roles assigned to a specific user.Log Module{ “event”: “rolesForUserListed”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “user”: { “UserID”: “user-XXXX” }, “roles”: [ { “RoleID”: “role-XXXX”, “RoleName”: “PremiumUser” } ] }Notifies that the list of roles for a particular user has been successfully fetched.None
usersWithRoleListedWhen listUsersWithRole successfully retrieves a list of users assigned to a specific role.Log Module{ “event”: “usersWithRoleListed”, “timestamp”: “YYYY-MM-DDTHH:MM:SSZ”, “role”: { “RoleID”: “role-XXXX” }, “users”: [ { “UserID”: “user-XXXX”, “UserName”: “John Doe” } ] }Notifies that the list of users with a specific role has been successfully fetched.None

Settings #

Settings for the User Roles module are maintained in an internal key-value store. These settings may include configuration for pagination defaults, feature toggles (e.g., whether role assignments can be edited by non-admins), and webhook URLs. Settings are stored in JSON format to allow flexible and dynamic configuration.

Clarifications #

  • User Membership: Every user must be assigned at least one role; however, users can belong to multiple roles concurrently.
  • Role Index: Each role has a numeric index that signifies its priority. When a user has multiple roles, the effective permissions for each field are determined by the role with the highest index (i.e., the most permissive role takes precedence).
  • Separation of Concerns: While the User Roles module manages the assignment and metadata of roles, the actual permissions (rights) corresponding to each role are managed by the User Rights module.
  • Administrative Operations: All role management functions (create, update, delete, assign, remove) are intended to be used by administrators. Proper Authentication (via the Auth module) is required to perform these operations.
  • User Retrieval: In addition to administrative functions, the module provides endpoints that allow users to retrieve their own role information, supporting transparency and self-service.
  • Extensibility: The module is designed with simplicity in version 1, providing a foundation for potential future enhancements, such as more complex role hierarchies or dynamic permission evaluations.