# Security Checklist, Hosting Notes & Backup/Restore Guide

## 1. Production Security Controls Implemented
- **Password Hashing**: PHP `password_hash()` with **Argon2id** (`PASSWORD_ARGON2ID`, fallback `PASSWORD_DEFAULT`). Zero plaintext passwords anywhere in code or database.
- **Session Hardening**: `HttpOnly`, `Secure` (HTTPS), `SameSite=Lax`, session ID regeneration on login, plus database-tracked `user_sessions` supporting instant remote session revocation from Admin Console.
- **CSRF & XSS Protection**: Per-session 256-bit CSRF token verified on every mutating `POST` request (`X-CSRF-Token`), strict PDO prepared statements (`ATTR_EMULATE_PREPARES => false`), and output escaping (`WS.esc()`).
- **Brute-Force Protection**: IP + email sliding-window lockout (`login_attempts` table, default 8 attempts / 15 minutes).
- **Two-Factor Authentication**: Built-in RFC 6238 TOTP (Google Authenticator / Authy compatible) with AES-256-GCM encrypted secrets.
- **Private File Storage**: Uploaded Drive files are stored with random hex filenames inside `private_codevra/storage/drive/` (outside web root) and streamed only through permission-checked `api/download.php`.

## 2. Hosting Compatibility & External Infrastructure Notes
- **Real-Time Chat & Meet Signaling**: Shared cPanel hosting generally does not permit persistent Node.js/WebSocket daemons. Codevra Chat and Codevra Meet use authenticated short-interval AJAX polling backed by MySQL so they work reliably on standard cPanel hosting. If you upgrade to a VPS later, you can swap the polling layer for a WebSocket server (e.g., Ratchet or Node/Socket.IO).
- **Codevra Meet (WebRTC) TURN Server**: Peer-to-peer WebRTC works across standard networks using the pre-configured STUN servers, but strict corporate/mobile carrier NAT firewalls require a **TURN relay server** (e.g., self-hosted `coturn`, Metered.ca, or Cloudflare Calls). Add your TURN URL, username, and credential inside `private_codevra/config.php` under `webrtc.ice_servers`.
- **Collaborative Docs/Sheets/Slides**: Documents, spreadsheets, and presentations save full editable state and version snapshots to MySQL. Simultaneous character-by-character CRDT co-editing (like Google Docs real-time cursors) requires a dedicated WebSocket/OT server (such as Yjs or Collabora Online) beyond standard shared cPanel PHP.

## 3. Backup & Restore Procedures
- **One-Click SQL Backup**: Super Admins can click **Admin Console -> Download SQL Backup** (`api/admin.php?action=backup_sql`), which saves a timestamped `.sql` dump inside `private_codevra/backups/` and downloads a copy.
- **Automated cPanel Cron Backup**: Add a daily cron job in **cPanel -> Cron Jobs**:
  ```bash
  0 2 * * * mysqldump -u CPANEL_USER_wsadmin -p'YOUR_DB_PASS' CPANEL_USER_workspace | gzip > /home/CPANEL_USERNAME/private_codevra/backups/db_$(date +\%F).sql.gz
  ```
- **Private Drive Storage Backup**: Archive `/home/CPANEL_USERNAME/private_codevra/storage/` weekly using **cPanel -> Backup Wizard**.
- **Restore**: Import the `.sql` file in **cPanel -> phpMyAdmin -> Import** and restore `private_codevra/storage/`.
