Role Hierarchy
Tesis Rutas implements a three-tier role system to manage access control and permissions across the platform:Visitante
Browse destinations, save favorites, track visits
Editor
Create and manage routes, toggle destination status
Administrador
Full platform access and user management
Role Definition
Roles are defined in theUsuario entity as a string field:
src/domain/entities/usuario.py:21
Permission Matrix
The following table shows which operations are available to each role:| Feature | Visitante | Editor | Administrador |
|---|---|---|---|
| Authentication | |||
| Register account | ✓ | ✓ | ✓ |
| Login/logout | ✓ | ✓ | ✓ |
| View own profile | ✓ | ✓ | ✓ |
| Update own profile | ✓ | ✓ | ✓ |
| Destinations | |||
| Browse destinations | ✓ | ✓ | ✓ |
| View destination details | ✓ | ✓ | ✓ |
| Create destinations | ✗ | ✗ | ✓ |
| Edit destinations | ✗ | ✗ | ✓ |
| Toggle destination status | ✗ | ✓ | ✓ |
| Delete destinations | ✗ | ✗ | ✓ |
| Upload multimedia | ✗ | ✗ | ✓ |
| Delete multimedia | ✗ | ✗ | ✓ |
| Routes | |||
| View routes | ✓ | ✓ | ✓ |
| Create routes | ✗ | ✓ | ✓ |
| Update routes | ✗ | ✓ | ✓ |
| Delete routes | ✗ | ✓ | ✓ |
| Generate AI routes | ✓ | ✓ | ✓ |
| Get POI suggestions | ✓ | ✓ | ✓ |
| User Management | |||
| View all users | ✗ | ✗ | ✓ |
| View any user profile | ✗ | ✗ | ✓ |
| Delete users | ✗ | ✗ | ✓ |
| Assign roles | ✗ | ✗ | ✓ |
| Personal Features | |||
| Add favorites | ✓ | ✓ | ✓ |
| Remove favorites | ✓ | ✓ | ✓ |
| Track visited POIs | ✓ | ✓ | ✓ |
| Register completed routes | ✓ | ✓ | ✓ |
Role Enforcement
Roles are enforced at the API level using FastAPI dependency injection with three main guard functions:require_user
Allows any authenticated user (visitante, editor, or administrador):src/infrastructure/security/jwt_utils.py:88-92
require_editor
Restricts access to editors and administrators only:src/infrastructure/security/jwt_utils.py:95-99
require_admin
Restricts access to administrators only:src/infrastructure/security/jwt_utils.py:102-106
These guard functions are used as FastAPI dependencies via
Depends() in router endpoints to enforce permissions.Default Role Assignment
When new users register through the/auth/register endpoint, they are automatically assigned the visitante role:
src/domain/entities/usuario.py:11
Role Modification
Role assignment is restricted to administrators through theAsignarRol use case:
src/infrastructure/api/routers/usuario_router.py:202
Next Steps
Visitor Role
Learn about visitor capabilities
Editor Role
Explore editor permissions
Admin Role
Understand admin privileges