# MAYA OS ENTERPRISE — SECURITY & HARDENING ARCHITECTURE

## 1. Authentication & Session Controls

- **Password Hashing**: Argon2id primary (`Argon2PasswordHasher`) with PBKDF2 fallback; 12+ character policy enforced.
- **Mandatory Super Admin TOTP MFA**: Initial Super Admin creation requires a secret server-side `BOOTSTRAP_SETUP_TOKEN` (compared with constant-time `hmac.compare_digest`), rejects weak usernames (`admin`, `root`, `test`, `demo`), immediately generates TOTP MFA + single-use recovery codes, and permanently locks the unauthenticated bootstrap endpoint once completed.
- **Session Hygiene**: Cookie `HttpOnly`, `SameSite=Lax`, TLS `Secure` cookies + HSTS in non-debug deployments (`settings.py`), server-tracked active sessions with per-session revocation (`/api/v1/sessions/<uuid>/revoke/`), and DRF scoped throttling (`anon`, `user`, `login`, `report_export`).

## 2. Multi-Tenant Company Isolation & RBAC

- Every financial and operational entity scopes strictly to `company_id` via authenticated membership (`CompanyMembership` + `Role` permission matrix), preventing horizontal IDOR across companies.
- Privileged Super Admin actions, payroll runs, opening balance locks, software upgrades, and audit views require explicit granular permissions and emit immutable `AuditEvent` records.

## 3. Data & File Protection

- Sensitive BFI credentials and API secrets are encrypted at rest via `MAYA_FIELD_ENCRYPTION_KEY` (Fernet AES-128-CBC + HMAC-SHA256) with blind SHA-256 uniqueness hashes.
- Uploaded private documents live outside static web roots (`PRIVATE_DOCUMENT_ROOT`) and are served exclusively through authorized API checks.
- Reverse proxy headers (`deployment/nginx/maya-os.tls.conf`): TLS 1.2/1.3, HSTS preload, `X-Frame-Options: DENY`, `X-Content-Type-Options: nosniff`, `Referrer-Policy`.

