Role API
The Role API provides endpoints for managing roles and role assignments within the UBU Digital Finance Solution.
Endpoints
Create Role
Creates a new role. Requires the create_role permission.
Request Body
Responses
201 Created - Role created successfully
400 Bad Request - Validation error
403 Forbidden - Insufficient permissions
Get All Roles
Retrieves a list of all roles. Requires the view_roles permission.
Responses
200 OK - Roles retrieved successfully
[
{
"role_id": "uuid",
"role_name": "string",
"role_description": "string",
"role_is_active": true
}
]
403 Forbidden - Insufficient permissions
Get Role
Retrieves a specific role. Requires the view_roles permission.
Path Parameters
role_id(UUID): ID of the role
Responses
200 OK - Role retrieved successfully
404 Not Found - Role not found
403 Forbidden - Insufficient permissions
Update Role
Updates a role. Requires the update_role permission.
Path Parameters
role_id(UUID): ID of the role to update
Request Body
Responses
200 OK - Role updated successfully
404 Not Found - Role not found
400 Bad Request - Validation error
403 Forbidden - Insufficient permissions
Delete Role
Deletes a role. Requires the delete_role permission.
Path Parameters
role_id(UUID): ID of the role to delete
Responses
200 OK - Role deleted successfully
404 Not Found - Role not found
400 Bad Request - Role in use
403 Forbidden - Insufficient permissions
Assign Permissions to Role
Assigns permissions to a role. Requires the assign_permissions permission.
Path Parameters
role_id(UUID): ID of the role
Request Body
Responses
200 OK - Permissions assigned successfully
404 Not Found - Role not found
404 Not Found - Permission not found
403 Forbidden - Insufficient permissions
Get Role Permissions
Retrieves the permissions assigned to a role. Requires the view_role_permissions permission.
Path Parameters
role_id(UUID): ID of the role
Responses
200 OK - Permissions retrieved successfully
[
{
"permission_id": "uuid",
"permision_key": "string",
"permission_name": "string",
"permission_desc": "string"
}
]
404 Not Found - Role not found
403 Forbidden - Insufficient permissions
Get User Roles
Retrieves the roles assigned to a user. Requires the view_roles permission.
Path Parameters
user_id(UUID): ID of the user
Responses
200 OK - Roles retrieved successfully
[
{
"role_id": "uuid",
"role_name": "string",
"role_description": "string",
"role_is_active": true,
"assignment_is_active": true
}
]
404 Not Found - User not found
403 Forbidden - Insufficient permissions
Get Role Users
Retrieves the users assigned to a role. Requires the view_roles permission.
Path Parameters
role_id(UUID): ID of the role
Responses
200 OK - Users retrieved successfully
[
{
"user_id": "uuid",
"user_code": "string",
"user_fullname": "string",
"user_email": "string",
"assignment_is_active": true
}
]
404 Not Found - Role not found
403 Forbidden - Insufficient permissions
Role Structure
Roles in the UBU Digital Finance Solution have the following structure:
Role Name
The role name is a human-readable name for the role, such as:
- "Super Admin"
- "Branch Manager"
- "Teller"
- "Customer"
Role Description
The role description provides additional context about what the role represents, such as:
- "Administrator with full system access"
- "Manager of a branch office with oversight capabilities"
- "Front-line staff handling customer transactions"
- "End user of the system with limited access"
Role Status
Roles can be active or inactive:
- Active roles can be assigned to users
- Inactive roles cannot be assigned to users
- Existing assignments to inactive roles are not automatically removed
Default Roles
The system includes a set of default roles:
| Role Name | Description | Permissions |
|---|---|---|
| Super Admin | Administrator with full system access | All permissions |
| Branch Manager | Manager of a branch office | User management, view data, approve transactions |
| Teller | Front-line staff | Basic user operations, process transactions |
| Customer | End user of the system | View own profile, perform basic operations |
Role Assignment
Roles are assigned to users through the User API when creating or updating a user. The assignment includes:
- User ID: The ID of the user
- Role ID: The ID of the role
- Active Status: Whether the role assignment is active
A user can have multiple roles, but typically one primary role is used for most operations.
Role-Based Access Control
The system implements role-based access control (RBAC) through the permission system:
- Permissions are assigned to roles
- Roles are assigned to users
- When a user attempts to access a protected resource, the system checks if the user has the required permission through their assigned roles
This provides a flexible and maintainable approach to access control.