Overview
SMAF implements a comprehensive role-based access control (RBAC) system to manage permissions across different organizational levels. The permission system controls access to modules, features, and data based on user roles and hierarchical relationships.Role-Based Access Control (RBAC)
Permission Entity Structure
The system manages permissions through thecrip_permisos table with the following structure:
Permission Levels and Roles
Organizational Hierarchy
The system defines a hierarchical permission structure based on roles:Level 1: General Director
Role Code:
DIRGRAINA- Highest authority level
- System-wide access to all modules and data
- Can authorize any request regardless of amount or type
- Access to all departments and centers
Level 2: Adjunct Directors
Role Codes:
DIRADJUNT, SUBDIRAD- Regional authority over assigned directorates
- Can approve requests within their directorate
- Access to all centers under their directorate
- Budget oversight for their area
Level 3: Administrative Directors
Role Codes:
DIRADMIN, ADMINP- Financial and administrative oversight
- Budget management and approval authority
- System configuration access
- User management capabilities
Level 4: Center Chiefs
Role Code:
JFCCRIPSC- Authority over specific research centers
- Approval of requests from center personnel
- Access to center-level reports and data
- Budget management for their center
Level 5: Administrators
Role Code:
ADMCRIPSC- Center-level administrative access
- Process and validate expense requests
- Generate reports for their center
- User support and assistance
Level 6: Department Chiefs
Role Code:
JFDEPTO- Department-level approval authority
- Manage department personnel
- Access to department reports
Level 7: Liaison Personnel
Role Code:
ENLACE- Coordinate request processing
- Data entry and validation
- Limited approval authority
Permission Types
The system defines specific permission codes for different operations:Travel Allowance (Viáticos)Permission to create and approve travel allowance requests. Date-based permission that must be renewed daily.
Major Official DocumentsPermission to generate official documents with certain thresholds. Date-based, requires daily renewal.
External AccessSpecial permission for external users or consultants. Requires daily authorization.
External Project AccessPermission for external users to access specific projects. Date-based and project-specific.
Local AdministratorLocal administrative permissions for center-level management.
External AdministratorAdministrative permissions for external consultants or contractors.
Permission Validation
Check User Permission
The system validates permissions using theobtienePermisos method:
Time-sensitive permissions (VIAT, OFMAY, EXT, EXTPROY) are validated against the current date. These permissions expire daily and must be renewed by an authorizer.
Count Active Permissions
Check how many active permissions a user has for a specific type:Get Permission Quantity
Retrieve the number of operations allowed under a permission:Module Access Control
Department-Based Access
Users can only access data from their assigned department(s):Role-Based Data Filtering
The system uses role codes to filter accessible data:Hierarchical Permissions
VoBo (Approval) Authorization
The system implements a “VoBo” (Visto Bueno / Approval) workflow:Approval Workflow
VoBo Review
Request is routed to the user’s supervisor or department chief for initial approval (VoBo).
Permission Assignment Process
Creating New Permission
Grant a new permission to a user:Permission Parameters
User ID receiving the permission
Permission type code (VIAT, EXT, ADML, etc.)
User ID of the person granting the permission
Date the permission is valid for (format: YYYY-MM-DD)
Optional notes or justification for the permission
Optional quantity limit for the permission
Permission Catalog
List Available Permissions
Retrieve all available permission types:Organizational Unit Permissions
Directorate-Level Access
The system defines permissions for major organizational units:Directorate General of Aquaculture Research and InnovationDepartment code:
2000Special permissions include access to aquaculture sub-directorate (SUBACUA).Directorate General of Fisheries Research in the PacificDepartment code:
4000Directorate General of Fisheries Research in the AtlanticDepartment code:
3000Directorate of AdministrationDepartment code:
5000Includes sub-directorates: Informatics (5100), Financial (5200), Materials (5300), Human Resources (5100)General DirectorateDepartment code:
1000Highest organizational levelCross-Directorate Access
Some roles have special cross-directorate permissions:Request Limits and Quotas
Daily Request Limits
Check the number of requests submitted by a user today:This can be used to implement daily quotas or rate limiting for request submission.
Project-Specific Permissions
Permissions can be scoped to specific projects and project departments:Security Best Practices
Validate permissions on every request
Always check user permissions before allowing access to sensitive operations or data.
Use least privilege principle
Grant only the minimum permissions necessary for users to perform their job functions.
Permission Validation Example
Complete example of validating and using permissions:Database Schema
Permission Tables
crip_permisos - Active permissions- Stores granted permissions with date and quantity limits
- Status field for activation/deactivation
- Links to user, project, and authorizer
- Master list of available permission types
- Permission codes and descriptions
- Active/inactive status
- Links users to roles and departments
- Period-based for historical tracking
- Status field for active assignments
- Consolidated view of users with role and department information
- Filtered by active status and current period
- Used for permission validation queries