Security Guide
What Streamix does to protect members, content and payments, what it does not do yet, and what you must configure as an operator.
Operator checklist
- Set long random values for
JWT_SECRET,SECRET_KEYandCRON_SECRET. Back upSECRET_KEY; losing or changing it makes stored integration credentials unreadable. - Serve the site over HTTPS only (HSTS is sent in production).
- Change the bootstrap admin password; create separate admin users with the least permissions they need.
- Activate the license for your production domain.
- Restrict bucket CORS to your own origins (
scripts/setup-r2-cors.tsnever adds*). - Use gateway sandbox keys only in test environments; rotate keys if a staff member leaves.
- Keep dependencies and the product up to date (see Upgrade Guide).
- Schedule backups and test a restore.
Authentication
| Area | Implementation |
|---|---|
| Member sessions | JWT (jose) in an httpOnly, SameSite=Lax cookie member_session, Secure in production; 30 days, or a browser session when "Remember me" is off. The same token is accepted as a Bearer header for API clients. |
| Admin sessions | Separate admin_token cookie (httpOnly, SameSite=Lax), lifetime JWT_EXPIRES_IN (default 7 days) |
| Secret | JWT_SECRET is required in production; the app fails fast without it |
| Passwords | bcrypt |
| Email codes | Verification, password reset and sign-in codes are short-lived. Sign-in codes are hashed, single use, expire after 15 minutes and die after 5 wrong guesses; requesting one never reveals whether the email exists. |
| Rate limits | Sign-in, sign-up, code requests and verification, coupon checks, PIN attempts and public forms use a sliding-window limiter (src/lib/rate-limit.ts). It is in-memory per process; with several instances, put a shared store behind the same API. |
| CAPTCHA | Optional reCAPTCHA add-on on sign-in and forms |
| Two-factor / SSO | The bundled twofa (TOTP) and sso (OIDC) feature add-ons come from the shared core; their member screens and sign-in buttons are not wired into the Streamix storefront yet |
| Bootstrap admin | Created from ADMIN_EMAIL/ADMIN_PASSWORD; in production a missing password becomes a random one printed once in the logs |
Authorisation
- Every API route checks auth first and scopes queries to the caller (
AND customer_id = me). Account endpoints take no subscription or customer id from the client, so there is nothing to tamper with. - Profiles: the active profile cookie (
sx_profile) orX-Profile-Idheader is re-checked against the signed-in account on every request; a copied cookie cannot open another account's profile. Kids profiles cannot open account pages or account APIs. - Profile PIN: 4 digits, bcrypt-hashed; setting or removing it requires the account password; PIN attempts are rate-limited per member.
- Admin: role-based permissions (
requirePermission(action, resource)) on every admin route; plugin admin pages check their own permission. Admin actions are recorded in the Activity Log. - Admin preview: admins can play any title only in the browser holding the admin session; those plays are not counted as member streams.
Content protection
Be clear with your content licensors about what is and isn't in place:
| In place | Not in place |
|---|---|
| Playback API returns a stream URL only to members with a live subscription, a selected profile, the right maturity level, inside the title's availability window and allowed country | DRM (Widevine, FairPlay, PlayReady) |
| Concurrent-stream limit per plan, enforced when a stream starts; admins and members can end sessions remotely | Signed or expiring media URLs: video, HLS segments and subtitles are served from the bucket's public URL, so anyone with a URL can fetch that file |
| Plan resolution cap applied to transcoded HLS (capped master playlist) | Resolution cap for plain MP4 files |
| Country allow/deny lists per title (edge geo header) | Watermarking, screen-capture prevention |
If your licences require DRM or tokenised URLs, you will need a provider integration (see Roadmap).
Payments
- Amounts are always computed on the server from the database (
quoteFor()); the client chooses only the plan and coupon. - A purchase snapshots plan name, price and currency.
- Access is granted when the gateway confirms capture (
/api/v1/checkout/verify), never because the browser landed on a return URL. (provider, provider_ref)is unique, so replayed returns or provider retries cannot grant a second period.- Coupon validation is rate-limited so codes cannot be brute-forced.
- No card data touches Streamix; cards stay with the gateway.
Secrets and configuration
- Provider credentials (storage, payments, email, SMS, social, captcha…) are stored in
integration_connections, encrypted with AES-256-GCM using a key derived fromSECRET_KEY(falling back toJWT_SECRET), and masked in admin API responses. - The web-push private key is stored encrypted in
settings; only the public key is served. - Storage credentials are never read from environment variables, so there is one place to rotate them.
- The OpenAPI spec (
/api/openapi.json) and reference (/api/docs/v1) require an admin session. /api/v1/cronis closed unlessCRON_SECRETis set, and then requires it.
Uploads and files
- Admin uploads go directly from the browser to the bucket through short-lived presigned URLs; the declared size is capped at 2 GB per file. Server-side (buffered) uploads are capped at 100 MB and validated by type.
- Subtitle files are parsed and rewritten as clean WebVTT (max 2 MB); markup is reduced to
<b>,<i>,<u>. - The
/files/...proxy sendsX-Content-Type-Options: nosniffand forces download for anything that isn't an image, video, audio or PDF, so a stored HTML or SVG file cannot run in your origin. - Page Builder content is sanitised (safe URL schemes, allow-listed tags).
HTTP headers
Set in next.config.ts for every route: X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, a restrictive Permissions-Policy, X-Frame-Options: DENY with frame-ancestors 'none' (except /embed/*), and HSTS in production.
Privacy
- Members can download their data (JSON) and delete their account from Account → Security.
- Viewing activity can be hidden per item or downloaded as CSV.
- Search analytics store an HMAC of the profile, never the profile id.
- Analytics and marketing tags load only after cookie consent.
- Marketing emails and push respect per-template opt-outs.
Reporting a vulnerability
Email support@creative-cape.com privately with steps to reproduce. Please don't file public issues for security problems.
© CreativeCape Solutions · creative-cape.com · support@creative-cape.com