Overview
Integra uses a hierarchical permission structure based on UI modules (UIModulo). This allows fine-grained control over what users can access in the application.Permission Hierarchy
Permissions are organized in a tree structure where:- Root Modules: Top-level features (e.g., Asistencia, Empleados, Reportes)
- Sub-modules: Nested features within a parent module
- Actions: Specific operations within a module (e.g., ver, crear, editar, eliminar)
Example Structure
Get Permission Tree
Retrieve the complete hierarchical structure of all available permissions.Endpoint
Response
Success message: “Catálogo jerárquico recuperado”
Example Request
cURL
Example Response
Permission Usage
In Roles
Permissions are assigned to roles, and roles are assigned to users. This provides:- Centralized Management: Update role permissions once, affects all users with that role
- Scalability: Easily manage permissions for large numbers of users
- Flexibility: Users can have multiple roles, permissions are combined
In User Tokens
When a user logs in, their JWT token includes their permissions in theuiPermissions array:
- Show/hide UI elements
- Enable/disable features
- Route guards and navigation control
- Dynamic menu generation
Backend Authorization
The server validates permissions on each request:- Extract JWT token from Authorization header
- Decode and validate token signature
- Load user’s roles and associated permissions
- Check if required permission exists for the requested endpoint
- Allow or deny access
Permission Codes
Permission codes follow a dot-notation pattern:Common Modules
asistencia- Attendance managementempleados- Employee managementreportes- Report generationkioscos- Kiosk configurationusuarios- User administrationroles- Role managementcredenciales- Credential managementobservaciones- Observation/note management
Common Actions
ver- View/read accesscrear- Create new recordseditar- Update existing recordseliminar- Delete recordsexportar- Export dataimportar- Import dataconfigurar- Configure settings
Examples
| Permission Code | Description |
|---|---|
asistencia.ver | View attendance records |
asistencia.registrar | Register attendance |
empleados.crear | Create new employees |
empleados.editar | Edit employee information |
reportes.generar | Generate reports |
reportes.exportar.excel | Export reports to Excel |
kioscos.configurar | Configure kiosk settings |
usuarios.administrar | Manage user accounts |
Best Practices
Principle of Least Privilege
Role Design
Create roles based on job functions:- Administrator: Full system access
- HR Manager: Employee and attendance management
- Supervisor: View reports and manage team attendance
- Employee: Register own attendance only
Permission Naming
Use consistent, descriptive names:- Use Spanish for display names (matches UI language)
- Use English dot-notation codes for programmatic access
- Keep codes short but meaningful
- Group related permissions under common parent modules
Testing
Always test permission changes:- Create a test role with specific permissions
- Assign test user to that role
- Log in as test user
- Verify UI elements show/hide correctly
- Verify API endpoints accept/reject requests appropriately
Related Endpoints
User Management
Manage users and their permissions
Role Management
Create and configure roles
Authentication
JWT tokens and login flow