Overview
The Seguridad system uses a role-based authentication mechanism that controls access to different modules and functionalities based on user permissions. All authentication is handled through PHP sessions and PostgreSQL database validation.Login Process
Login Form
Users access the system through the main login page (index.php) which presents a simple authentication form:
Enter Credentials
Users must provide their username (
usuario) and password (password) in the login form.Form Validation
Client-side JavaScript validation ensures both fields are not empty before submission.
Role-Based Routing
Upon successful authentication, users are redirected to their designated module based on their permission level (see User Roles).
Session Management
Session Initialization
When a user successfully logs in, the system creates several session variables:Session Validation
Themiconexion.php file is included in protected pages to validate user sessions:
Session Timeout
The system tracks the last access time but the automatic timeout mechanism is currently commented out in the source code. The original implementation checked for 10-minute inactivity periods:Session timeout is currently disabled. Users remain authenticated until they manually log out or the session expires due to server configuration.
Password Security
Current Implementation
The system implements basic password handling:Password Storage
Passwords are stored in the
pwd field of the usuario tablePassword Length
Maximum length: 16 characters
Password Input
Password fields use HTML
type="password" for masked inputPassword Confirmation
User creation/modification requires password confirmation
Password Validation
When creating or modifying users, the system validates that passwords match:Role-Based Access Control
Permission System
Access control is managed through thepermisos field in the usuario table. Each permission code determines:
- Module Access - Which functional areas the user can access
- Landing Page - Where users are redirected after login
- Data Scope - What regional or departmental data they can view/modify
Permission Categories
The system uses numeric and text-based permission codes:- Regional Units
- Judicial
- Specialized Units
- Special Access
- Text Codes
- 0 - Administrator (full system access)
- 1-15 - Regional Units (UR1 through UR15)
Logout
Users can end their session by accessing the logout functionality:The logout option is available in the main navigation menu for all authenticated users.
Database Connection
The system connects to PostgreSQL with the following configuration:Database connection parameters are hardcoded in
index.php and miconexion.php. Consider moving these to a configuration file for easier maintenance.Troubleshooting
Login Failed: Usuario o Clave Incorrectos
Login Failed: Usuario o Clave Incorrectos
This error appears when:
- Username doesn’t exist in the database
- Password doesn’t match
- Database connection failed
No estas autentificado - RESTRICCION TOTAL
No estas autentificado - RESTRICCION TOTAL
This message indicates:
- Session expired or was never created
- Direct access attempt to a protected page
Redirected to Wrong Module
Redirected to Wrong Module
If redirected to the wrong area after login:
- Check your
permisosvalue in the database - Contact administrator to update your role
usuario table.Next Steps
User Roles
Learn about different user roles and their permissions
Navigation
Explore the system’s navigation structure and modules