Admin Dashboard
Admin Dashboard Documentation
Overview
The Conformo admin dashboard provides secure access to audit logs and platform management features. It implements role-based access control (RBAC) with mandatory two-factor authentication (2FA) for admin users, ensuring compliance with Italian and EU regulations (GDPR).
Features
1. Role-Based Access Control
Admin Role
- Stored in the database (
users.rolecolumn) - Can be set to
'admin'or'user'(default) - Admin role grants access to:
- Audit log viewing and filtering
- Log export functionality
- Platform statistics
- User management (future enhancement)
Access Control
- Implemented at both backend middleware and frontend component levels
- Non-admin users attempting to access admin routes receive a 403 Forbidden error
- Backend validates role on every API request to admin endpoints
2. Two-Factor Authentication (2FA)
Implementation
- Uses Time-based One-Time Password (TOTP) algorithm
- Compatible with standard authenticator apps (Google Authenticator, Authy, etc.)
- Provides 8 backup codes for account recovery
Setup Process
- Admin user initiates 2FA setup via API
- System generates secret and QR code
- User scans QR code with authenticator app
- User enters verification code to enable 2FA
- System provides backup codes (store securely!)
Login Flow with 2FA
- User enters email and password
- If 2FA is enabled, system returns temporary token
- User enters 6-digit TOTP code
- System verifies code and issues full authentication tokens
- User gains access to admin dashboard
API Endpoints
POST /api/auth/2fa/setup- Initialize 2FA setupPOST /api/auth/2fa/verify- Enable 2FA with verification codePOST /api/auth/2fa/disable- Disable 2FA (requires current code)GET /api/auth/2fa/status- Check if 2FA is enabledPOST /api/auth/2fa/verify-login- Complete login with 2FA code
3. Audit Log Management
Log Types
- Authentication Logs: Registration, login, logout, password resets, email verification
- Admin Actions: Dashboard access, log exports, configuration changes
Filtering Options
- Email: Filter by user email address
- Event Type: Filter by specific event (login, logout, etc.)
- IP Address: Filter by source IP address
- Outcome: Success or failure
- Date Range: From/To datetime filters
- Environment: Automatic filtering by current environment (production/staging/development)
Timestamp Format
- All timestamps displayed in Central European Time (CET/Europe/Rome)
- Format:
dd/mm/yyyy HH:MM - Complies with Italian date/time conventions
Export Functionality
- Export filtered logs as CSV file
- Max 10,000 rows per export
- Includes all log fields: ID, timestamp, event type, email, IP, user agent, etc.
- Filename format:
audit_logs_YYYY-MM-DD.csv
4. Italian Localization
All admin dashboard text is in Italian:
- Navigation and menu items
- Form labels and placeholders
- Error messages
- Success notifications
- Table headers and content
- Event type translations
5. GDPR Compliance
Log Retention
- Auth logs: 13 months (1 year + 1 month buffer)
- Admin action logs: 25 months (2 years + 1 month buffer)
- Automated cleanup functions provided in database migrations
- Should be scheduled via cron job or similar
Data Privacy
- Personal data minimization in logs
- Secure storage with encrypted connections
- Access logging for all admin actions
- Right to access (users can request their logs)
- Right to erasure (logs older than retention period)
Audit Trail Every admin action is logged:
- Dashboard access
- Log viewing
- Log exports
- Configuration changes
- Includes: admin user ID, action type, timestamp, IP, user agent
Setup Instructions
1. Database Migration
Run the main schema to create required tables:
-- Run backend/db/schema.sql
psql -d your_database < backend/db/schema.sql
Optional: Set up log retention policy:
-- Run backend/db/migrations/log_retention_policy.sql
psql -d your_database < backend/db/migrations/log_retention_policy.sql
-- Schedule cleanup (example cron job, adjust as needed)
0 2 * * 0 psql -d your_database -c "SELECT cleanup_old_auth_logs(); SELECT cleanup_old_admin_action_logs();"
2. Create Admin User
Update an existing user to have admin role:
UPDATE users
SET role = 'admin'
WHERE email = 'admin@yourcompany.com';
3. Environment Configuration
Add to your .env file:
# Environment identifier (important for log filtering)
ENVIRONMENT=production # or staging, development
# Optional: Fallback admin emails (for backward compatibility)
ADMIN_EMAILS=admin@yourcompany.com,admin2@yourcompany.com
4. Enable 2FA for Admin Users
Via API (recommended)
After logging in as admin:
- Call
POST /api/auth/2fa/setup:curl -X POST https://your-domain.com/api/auth/2fa/setup \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -
Scan the QR code with authenticator app
- Call
POST /api/auth/2fa/verifywith the code:curl -X POST https://your-domain.com/api/auth/2fa/verify \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"token": "123456"}' - Store backup codes securely!
Via Frontend (when UI is implemented)
Navigate to admin settings and follow the 2FA setup wizard.
Usage
Accessing the Dashboard
- Navigate to
/adminor/admin/dashboard - If not logged in, you’ll be redirected to login
- After login (with 2FA if enabled), dashboard loads
- Non-admin users see “Access Denied” message
Viewing Audit Logs
- Navigate to “Log di Audit” tab
- Logs from current environment are displayed automatically
- Use filters to narrow results:
- Enter email to find logs for specific user
- Select event type from dropdown
- Enter IP address
- Select outcome (success/failure)
- Set date range
- Click “Applica Filtri” to apply
- Click “Resetta” to clear all filters
Exporting Logs
- Apply desired filters
- Click “Esporta CSV” button
- CSV file downloads automatically
- Export action is logged for audit trail
Security Best Practices
- Mandatory 2FA: All admin users should enable 2FA
- Strong Passwords: Enforce password policy (min 12 characters)
- Regular Reviews: Periodically review audit logs for suspicious activity
- Access Limits: Only grant admin role to necessary personnel
- Backup Codes: Store backup codes in secure password manager
- Monitor Exports: Track who exports logs and when
- Log Retention: Run cleanup tasks regularly to maintain compliance
- Secure Access: Always use HTTPS in production
- Session Management: Implement appropriate session timeouts
- IP Whitelisting: Consider restricting admin access to known IPs (optional)
API Reference
Admin Dashboard Endpoints
All endpoints require authentication and admin role.
Get Audit Logs
GET /api/auth/logs
Query Parameters
email(string): Filter by emailevent_type(string): Filter by event typeip_address(string): Filter by IPsuccess(boolean): Filter by outcomefrom(ISO datetime): Start dateto(ISO datetime): End dateenvironment(string): Environment filter (auto-detected if not provided)limit(number): Results per page (default: 20, max: 100)cursor(string): Pagination cursororder(string): Sort order (‘asc’ or ‘desc’)
Response
{
"data": [
{
"id": "uuid",
"user_id": "uuid",
"email_attempted": "user@example.com",
"event_type": "login_success",
"success": true,
"ip_address": "192.168.1.1",
"user_agent": "Mozilla/5.0...",
"origin": "INTERNAL",
"session_id": "uuid",
"environment": "production",
"metadata": {},
"created_at": "2025-10-17T12:00:00Z"
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "cursor_string"
},
"count": 20
}
Export Audit Logs
GET /api/auth/logs/export
Same query parameters as above. Returns CSV file.
Get Audit Log Stats
GET /api/auth/logs/stats?days=30
Returns aggregated statistics.
Get Single Log Entry
GET /api/auth/logs/:id
Returns detailed log entry with user information.
Troubleshooting
Admin Access Issues
Problem: User has admin role but can’t access dashboard
Solutions:
- Check database role:
SELECT role FROM users WHERE email = 'user@example.com' - Verify authentication token is valid
- Check browser console for error messages
- Verify backend environment variable
ENVIRONMENTis set
Problem: 2FA code not working
Solutions:
- Check device time is synchronized (TOTP depends on accurate time)
- Try backup code instead
- Regenerate 2FA setup if needed
- Verify 6-digit code is entered correctly
Log Viewing Issues
Problem: No logs appearing
Solutions:
- Check environment filter matches your setup
- Verify logs exist in database:
SELECT COUNT(*) FROM auth_logs WHERE environment = 'production' - Clear all filters and try again
- Check browser network tab for API errors
Problem: Export fails
Solutions:
- Reduce date range (max 10,000 rows)
- Check backend logs for errors
- Verify user has admin role
- Try with fewer filters applied
Admin Preferences
The Admin Preferences page provides comprehensive configuration management for all platform settings.
Accessing Preferences
- Navigate to Admin Dashboard
- Click on “Preferenze” tab
- View and modify settings organized by category
Preference Categories
Available Settings:
- Authentication & Security
- 2FA enforcement for admins
- Session timeout configuration
- Password complexity requirements
- Login attempt limits
- Account lockout settings
- Audit Logging & GDPR
- Log retention periods
- Audit logging toggles
- Pseudonymization options
- Environment Configuration
- Environment selection (development/staging/production)
- Email & Notifications
- FROM_EMAIL configuration
- Trusted domain allowlist
- Feature Flags
- Landing page visibility
- User registration toggle
- GDPR questionnaire
- Risk scoring
- Subscriptions
- Other platform features
- Localization & Timezone
- Default locale (Italian/English)
- Timezone (Europe/Rome default)
- Timestamp format
- Export/Reporting
- Max export rows
- Export filename prefix
- CSV/PDF export toggles
- Privacy/GDPR
- Right to erasure
- Retention enforcement
- Auto cleanup scheduling
- Advanced/Operational
- Rate limiting settings
- Webhook integrations
Using Admin Preferences
Modifying Settings:
- Navigate to desired category
- Update field values
- Click “Salva Modifiche” (Save Changes)
- Success message confirms save
- All changes are logged in audit trail
Validation:
- All inputs are validated
- Error messages shown in Italian
- Numeric fields have min/max ranges
- Email and URL formats checked
Audit Trail:
- Every change is logged
- Includes admin user, timestamp, IP
- Changes viewable in Audit Logs
Business Value
The preferences system provides:
- GDPR Compliance: Configure retention, pseudonymization, right to erasure
- Localization: Italian-first configuration (CET timezone, it-IT locale)
- Security: Enforce 2FA, password policies, rate limiting
- Operational Efficiency: No developer needed for configuration changes
- Audit Trail: Full traceability for compliance requirements
Documentation
For detailed information:
- User Guide: ADMIN_PREFERENCES.md - Complete settings reference
- API Documentation: ADMIN_PREFERENCES_API.md - API contracts and usage
Future Enhancements
Planned improvements for the admin dashboard:
- Statistics Dashboard: Visual charts and graphs for log data
- Real-time Alerts: Notifications for suspicious activity
- User Management: Create/edit/disable users
- Role Management: Create custom roles with specific permissions
- Advanced Filtering: Save filter presets, complex queries
- Bulk Operations: Bulk user actions
- API Keys Management: Generate and manage API keys
System Settings: Configure platform-wide settings✅ IMPLEMENTED (Admin Preferences)- Backup Management: Scheduled backups and restore
- Compliance Reports: Generate compliance reports for auditors
Support
For issues or questions:
- GitHub Issues: https://github.com/GrewingM/conformo/issues
- Documentation: /docs
- Admin Preferences: ADMIN_PREFERENCES.md
- Admin Preferences API: ADMIN_PREFERENCES_API.md
- Technical Architecture: TECHNICAL_ARCHITECTURE.md
- Authentication: AUTHENTICATION.md