# Security (developers)

What the application itself enforces, so an install is protected whatever its web server adds.

- **Headers** (`Platform\Http\Middleware\SecurityHeaders`, global): `X-Frame-Options: SAMEORIGIN` and
  `Content-Security-Policy: frame-ancestors 'self'`, `Referrer-Policy: strict-origin-when-cross-origin`,
  `X-Content-Type-Options: nosniff`, `Permissions-Policy` without camera, microphone, location or topics, and HSTS on
  https in production. A header a response already set is left alone. A full script CSP needs nonces for the inline
  scripts and Alpine's CSP build; it is not on yet.
- **Staff sessions** (`StaffSession`): bound to the password at sign-in, checked on every admin route (through
  `RequireTwoFactor`), Horizon, the broadcast auth route and Fortify's account routes; a change or reset of the
  password ends every other session and rotates "remember me".
- **Staff sign-in log** (`Listeners\RecordStaffSignIns`, subscribed in the Platform provider; `staff_sign_ins`,
  `Data\StaffSignInEvent`): Laravel's `Login` (password and code, or "remember me"), `Failed` (an existing account
  only) and `Logout` on the staff guard, and Fortify's `TwoFactorAuthenticationFailed` and `RecoveryCodeReplaced`,
  with the IP and `Platform\Data\DeviceName` (never the raw user agent). Shown on the security page (10), a user's
  page (20) and the users list (last session); pruned after a year by `PlatformRetention`.
- **Limits**: staff sign-in per address and per account, the staff forgot-password form (`LimitResetLinks`, in
  `fortify.middleware` so a route cache keeps it; one answer for any address), customer sign-in and recovery,
  checkout and cart, vouchers, chat, order lookups (per visitor, order number and contact), the APIs.
- **Secrets**: encrypted at rest, never flashed back (`dontFlash`), never printed into password inputs.
- **Inbound webhooks**: only for families with a handler, at most 256 KB, stored raw and verified on the queue against
  the time they arrived.
- **Outbound requests**: webhook and storage URLs go through `SafeUrl` (global addresses only, pinned, no redirects).
- **Scheduler**: shell tasks only where the server sets `SCHEDULER_ALLOW_SHELL`, and only for the Owner role.

Tests: `tests/Feature/Platform/SecurityHeadersTest.php`, `StaffSessionsTest.php`, `StaffOnlyEndpointsTest.php`, `StaffSignInsTest.php`.
