v1.0 Dashboard Public Profile GitHub
✅ Complete (Core) Phase 13

Phase 13 — Security & Compliance

RBAC, audit trails, security HTTP headers, GDPR data export, and an audit log viewer — giving business owners visibility and control over their account security.

What It Does

Phase 13 adds enterprise-grade security controls. Role-based access ensures only the account owner can access billing and security settings. Every sensitive action (login, data export, settings change) is recorded in an audit log. GDPR compliance is supported via CSV data exports. Security headers protect against common web vulnerabilities.

Key Routes

URLAuth RequiredDescription
GET /settings/securityOwner onlySecurity tab — audit log, status panel, purge controls
GET /settings/security/export/customersOwner onlyGDPR: export all customers as CSV
GET /settings/security/export/appointmentsOwner onlyGDPR: export all appointments as CSV
GET /settings/security/export/callsOwner onlyGDPR: export all call logs as CSV
POST /settings/security/purge-logsOwner onlyPurge audit logs older than selected days (90/180/365)

Key Files

TypePath
Serviceapp/Services/AuditService.php — AuditService::log()
Middlewareapp/Http/Middleware/OwnerOnly.php
Middlewareapp/Http/Middleware/SecurityHeaders.php — applied globally
Modelapp/Models/AuditLog.php
Tableaudit_logs — tenant_id, user_id, event_type, description, ip_address, user_agent, created_at
Viewresources/views/settings/security.blade.php

Role-Based Access Control

RoleAccess LevelRestrictions
ownerFull access to all tenant featuresNone — can access billing, security, branding, all settings
adminMost features — no billing/securityCannot access billing, GDPR export, audit logs, or purge functions
staffOperational onlyCan only see appointments, customers, call logs — no settings access

The OwnerOnly middleware checks auth()->user()->role === 'owner'. Applied to:

  • /billing/* — all billing routes
  • /settings/security/* — security and GDPR
  • /settings/branding — branding customisation

Audit Events Logged

Event TypeWhen Triggered
loginSuccessful login
logoutUser logs out
settings_changedAny settings form saved
password_changedPassword update
data_exportedAny GDPR CSV export triggered
logs_purgedAudit log purge executed
api_key_createdNew API key generated
api_key_revokedAPI key revoked or deleted

Security HTTP Headers

The SecurityHeaders middleware is applied globally and adds these headers to every response:

HeaderValuePurpose
X-Content-Type-OptionsnosniffPrevents MIME-type sniffing
X-Frame-OptionsSAMEORIGINPrevents clickjacking
X-XSS-Protection1; mode=blockBrowser XSS filter
Referrer-Policystrict-origin-when-cross-originControls referrer header
Permissions-PolicyRestricts camera, microphone, geolocationLimits browser API access
Strict-Transport-Securitymax-age=31536000 (HTTPS only)Forces HTTPS connections

Security Status Panel

The Settings → Security tab shows a status panel with:

  • Password age indicator (days since last password change)
  • Last login time and IP address
  • Security headers status (✅ active)
  • Audit logging status (✅ active)
  • Data export checklist

What's Complete

  • OwnerOnly middleware protecting billing and security routes
  • isOwner() / isAdmin() helpers on User model
  • Audit log table with AuditService::log() called on all key events
  • Security HTTP headers middleware applied globally
  • GDPR CSV exports for Customers, Appointments, Call Logs
  • Audit log viewer (last 50 events, colour-coded by type, with IP + timestamps)
  • Audit log purge (owner-only, 90/180/365 day options)
  • Security status panel

What's Deferred

  • Two-factor authentication (2FA)
  • Call recording consent banners (needs Twilio/Vobiz IVR changes)
  • Granular per-user permissions (beyond owner/staff split)
  • Data encryption at rest (server/DB config — infrastructure level)
  • Backup systems + disaster recovery
  • Fraud/spam call detection
  • Anomaly/abuse alerts