Overview
Bar Galileo uses a comprehensive role-based access control (RBAC) system to manage user permissions. Control who can access which features and perform which actions throughout the system.Role-Based Access
Define roles with specific permissions for different staff levels
User Profiles
Extended user information including personal and emergency contacts
Module Permissions
Granular control over access to different system modules
Social Authentication
Sign in with Google using django-allauth integration
User Management
User Accounts
Bar Galileo uses Django’s built-in User model, providing:- username: Unique login identifier
- email: Email address for communications
- password: Securely hashed password
- first_name and last_name: User’s full name
- is_active: Whether account is enabled
- is_staff: Admin panel access
- is_superuser: Full system access
User Profiles
Each user has an extended profile with additional information:- nombre: Full name
- cedula: National ID or employee number
- telefono: Contact phone number
- direccion: Address
- avatar: Profile picture (uploaded to
img/avatar/)
Emergency Contacts
For staff safety, each user profile can have emergency contact information:- nombre: Emergency contact’s name
- relacion: Relationship (spouse, parent, sibling, etc.)
- telefono: Primary phone number
- telefono_alt: Alternative phone number
- sangre: Blood type
- alergias: Known allergies or medical conditions
Emergency contact information is private and should only be accessible to authorized management personnel.
Role-Based Access Control
System Components
The RBAC system consists of four key models:- Module: Areas of the system (e.g., “Products”, “Orders”, “Reports”)
- Action: What can be done (e.g., “View”, “Create”, “Edit”, “Delete”)
- Role: Job position or responsibility level (e.g., “Manager”, “Waiter”, “Chef”)
- RolePermission: Links roles to specific module-action combinations
How It Works
Define Modules
Create modules for each major system area:
- Products & Inventory
- Tables & Orders
- Invoicing
- Reports
- User Management
- Settings
Define Actions
Create standard actions that can be performed:
- View: See information
- Create: Add new records
- Edit: Modify existing records
- Delete: Remove records
- Export: Download data
Create Roles
Define roles matching your staff structure:
- Owner/Administrator
- Manager
- Server/Waiter
- Chef/Kitchen Staff
- Host/Hostess
Assign Permissions
For each role, specify which actions they can perform on which modules by creating RolePermission records.
Permission Checking
The system uses a custom middleware (PermissionMiddleware) to check permissions:
- Intercepts requests to protected views
- Checks user’s role and associated permissions
- Allows or denies access based on module-action requirements
- Redirects unauthorized users appropriately
Common Role Configurations
Administrator/Owner
Full System Access
Full System Access
Administrators typically have all permissions:All Modules:
- View, Create, Edit, Delete
- User management
- System configuration
- Financial reports
- Backup management
- Role and permission management
Manager
Operational Management
Operational Management
Managers need broad access but may not manage users:Products Module:
- View, Create, Edit (maybe not Delete)
- View, Create, Edit, Delete
- View, Create
- View, Export
- View only
Server/Waiter
Front-of-House Operations
Front-of-House Operations
Servers need order management and limited product access:Products Module:
- View only (see what’s available)
- View, Create, Edit (their own orders)
- View, Create (to generate bills)
- View, Edit (to update table status)
- View (their own sales)
Kitchen Staff
Order Preparation Focus
Order Preparation Focus
Kitchen staff need to see orders but not financial data:Orders Module:
- View (to see what to prepare)
- Edit (to mark items as completed)
- View (to check ingredients/recipes)
- Generally no access to invoicing or reports
Host/Hostess
Table and Reservation Management
Table and Reservation Management
Hosts manage tables and customer flow:Tables Module:
- View, Edit (to manage table status)
- View, Create (to start orders)
- View (to answer customer questions)
- Generally no access
Authentication
Standard Login
Bar Galileo uses django-allauth for authentication:- Login URL:
/accounts/login/ - Custom form:
CustomLoginFormwith captcha protection - Redirect: After login, users go to
/(home page) - Session management: Secure session handling
Google OAuth
Users can also sign in with Google:- Provider: Google OAuth configured in settings
- Scopes: Profile and email
- PKCE: Enabled for enhanced security
- Site ID: Configured for django.contrib.sites
Google OAuth requires configuration of client ID and secret in your environment variables and Google Cloud Console.
Email Management
Users can manage multiple email addresses:- Custom form:
CustomAddEmailFormfor adding emails - Verification: Email verification process for new addresses
- Primary email: Users can set primary email for communications
Admin Interface
Admin Redirect Middleware
Bar Galileo includes custom middleware (AdminRedirectMiddleware) that:
- Handles admin-specific routing
- Manages staff user access to admin panel
- Ensures proper authentication flow
Superuser vs Staff
- Superusers: Full system access including Django admin
- Staff users: Can access admin panel with limited permissions
- Regular users: Application access only, no admin panel
Security Features
Password Security
Bar Galileo enforces strong password standards:- Similarity validation: Password can’t be too similar to user info
- Minimum length: Enforced by validator
- Common password check: Prevents common passwords
- Numeric validation: Can’t be entirely numeric
Session Security
Production environments use enhanced security:- SSL redirect: Forces HTTPS
- Secure cookies: Session and CSRF cookies require HTTPS
- HSTS: HTTP Strict Transport Security enabled
- Referrer policy: Strict origin when cross-origin
CAPTCHA Protection
Login forms include captcha protection:- Simple captcha: django-simple-captcha integration
- Configurable: Adjust length, size, and font
- Bot prevention: Reduces automated login attempts
User Management Workflows
Onboarding New Staff
Changing User Roles
Offboarding Staff
Never delete user accounts if they have associated orders or other data. Deactivate instead to preserve historical records.
Best Practices
Principle of Least Privilege
Principle of Least Privilege
Grant users only the permissions they need for their job:
- Start with minimal permissions
- Add permissions as needed
- Regularly review and audit permissions
- Remove unnecessary permissions promptly
- Don’t grant admin access unless required
Regular Permission Audits
Regular Permission Audits
Periodically review who has access to what:
- Check all user role assignments
- Verify permissions match job responsibilities
- Remove permissions from users who changed positions
- Look for orphaned or inactive accounts
- Update roles as business needs change
Role Documentation
Role Documentation
Document what each role can do:
- List modules and actions for each role
- Explain why certain permissions are granted
- Keep role descriptions current
- Use documentation during onboarding
- Reference during permission disputes
Secure Password Practices
Secure Password Practices
Enforce good password hygiene:
- Use strong temporary passwords
- Force password change on first login
- Educate users about password security
- Never share passwords
- Use Google OAuth where appropriate
Emergency Contact Updates
Emergency Contact Updates
Keep emergency information current:
- Request annual updates
- Update when users report changes
- Verify phone numbers periodically
- Keep information confidential
- Ensure management can access in emergencies
