Overview
Sistema Magdaleno implements a comprehensive authentication and authorization system using CakePHP’s Auth Component combined with Access Control Lists (ACL). This provides fine-grained permission control over all controllers and actions.Authentication Architecture
Components Used
- Auth Component - Handles user login, session management, and basic authorization
- Acl Component - Manages permission trees and access control
- Session Component - Maintains user state across requests
Configuration
Location:app/app_controller.php
Authentication Flow
Login Configuration
Public Access
Some actions are accessible without authentication:Authorization Check
Access Control Lists (ACL)
ACL Architecture
The ACL system uses a dual-tree structure to manage permissions:- ACOs (Access Control Objects) - What can be controlled (resources)
- AROs (Access Request Objects) - Who requests access (users/groups)
ACL Database Tables
acos (Access Control Objects)
Defines the hierarchy of controllable resources. Structure:app/models/aco.php
aros (Access Request Objects)
Defines the hierarchy of requesters (users and groups). Structure:app/models/aro.php
aros_acos (Permission Junction)
Links AROs to ACOs with specific CRUD permissions. Columns:aro_id- Reference to ARO (user/group)aco_id- Reference to ACO (controller/action)_create- Create permission_read- Read permission_update- Update permission_delete- Delete permission
1= Allow - Explicitly grant permission0= Deny - Explicitly deny permission-1= Inherit - Inherit from parent node
app/models/aros_aco.php
User & Group Integration
User Model Integration
File:app/models/user.php
Group Model Integration
File:app/models/group.php
ACL Tree Generation
Automatic ACL Building
Thebuild_acl() method automatically generates ACO tree from controllers:
Location: app/app_controller.php::build_acl()
Process:
- Create root ACO node:
controllers - Scan all controllers in
app/controllers/ - For each controller:
- Create controller ACO node
- Scan public methods
- Create action ACO nodes for each method
- Support plugin controllers
Permission Management
Setting Permissions
Permissions are managed through thearos_acos junction table.
Grant Full Access to Group:
Checking Permissions
Password Security
Password Hashing
Passwords are hashed using SHA1 before storage:Password Validation
File:app/models/user.php
User Roles & Groups
Default Group
Table:groups
| ID | Name | Title |
|---|---|---|
| 1 | administradores | admin |
User Assignment
Users are assigned to groups viagroups_idgrupos foreign key:
Permission Inheritance
Users inherit permissions from their group:Session Management
User Session Data
After successful login, user data is stored in session:Login/Logout
Login:Security Best Practices
1. Always Hash Passwords
2. Use ACL for Authorization
3. Restrict Sensitive Actions
4. Validate User Input
5. Use HTTPS for Login
Permission Scenarios
Scenario 1: Full Admin Access
Scenario 2: Read-Only User
Scenario 3: Limited Editor
Troubleshooting
Common Issues
1. ACL tables not populatedRelated Documentation
- Database Schema - ACL table structure
- MVC Structure - Controller organization