Documentation Index
Fetch the complete documentation index at: https://mintlify.com/IvBanzaga/Refugio/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Refugio authentication system implements secure login with role-based access control, password hashing using bcrypt, and session management with anti-hijacking protections.User Roles
The system supports two distinct roles:- admin: Full system access including user management, reservation approval, and special reservations
- user: Standard members who can create reservations, view availability, and manage their own bookings
Login Flow
Authentication Process
The login is handled inlogin.php:12-40 with secure credential verification:
Database User Lookup
Thecomprobar_username() function in functions.php:13-25 uses prepared statements to prevent SQL injection:
The system uses
password_verify() which is resistant to timing attacks and automatically handles bcrypt hash comparison.Security Features
Password Hashing
Passwords are hashed using bcrypt (PASSWORD_BCRYPT) with automatic salt generation:Session Fixation Prevention
Session IDs are regenerated on login to prevent session fixation attacks:viewAdmin.php:14
SQL Injection Protection
All database queries use PDO prepared statements with parameter binding:Access Control
Authentication Check
Protected pages verify authentication inauth.php:8-11:
Role-Based Access
Admin pages check both authentication and role:Session Data Structure
After successful login, the session contains:Cookie Usage
The system stores last visit information in HTTP-only cookies:The
HttpOnly flag prevents JavaScript access to cookies, mitigating XSS attacks.Input Sanitization
All user input is sanitized before storage or display:viewAdmin.php:28:
Logout Process
The logout mechanism destroys the session and redirects to login:Best Practices Implemented
Password Security
Password Security
- Uses
password_hash()with bcrypt algorithm - Automatic salt generation per password
- Timing-attack resistant verification with
password_verify() - Passwords never stored in plain text
Session Security
Session Security
- Session regeneration on login (prevents fixation)
- Session regeneration on protected pages
- Session data sanitized before storage
- Proper session destruction on logout
SQL Injection Prevention
SQL Injection Prevention
- All queries use PDO prepared statements
- Parameters bound with type hints (PDO::PARAM_INT, etc.)
- No string concatenation in queries
- Error logging instead of displaying database errors
XSS Prevention
XSS Prevention
- All output sanitized with
htmlspecialchars() - ENT_QUOTES flag prevents attribute injection
- UTF-8 encoding specified
- HttpOnly cookies prevent JavaScript access
Test Credentials
The system includes test accounts for development:Admin Account
Email: admin@hostel.com
Password: admin123
Password: admin123
User Account
Email: user1@mail.com
Password: user123
Password: user123