fix: restore Access auth, add egress network, harden media routes
CD — Kai-Sa-Cam Deployment / deploy (push) Successful in 10s

The app returned 401 on every request because jwtVerify could not fetch
the Cloudflare Access signing keys (getaddrinfo EAI_AGAIN): kai-sa-cam
was only attached to internal networks (kai-sa-cam-internal and the
external kai-sa-cam-tunnel, which has Internal=true), so it had no DNS
or route to the Internet.

Network
- add a dedicated kai-sa-cam-egress bridge network, attached to
  kai-sa-cam only
- kai-sa-go2rtc stays on kai-sa-cam-internal only (no published ports,
  no outbound access); the video stream remains reachable solely through
  the authenticated /go2rtc proxy

Auth (index.ts)
- log the reason when an Access JWT is rejected instead of silently
  returning 401
- fail closed: exit at startup when CF_ACCESS_TEAM_DOMAIN or
  CF_ACCESS_AUD is missing, unless ALLOW_NO_AUTH=1

Media (media.ts)
- replace inline require() calls with ESM imports (resolve, mkdirSync)
- resolve the path first, then check it against MEDIA_DIR + path.sep
  (previous check ran after existsSync and accepted sibling prefixes)
- on export, delete files only on the response "finish" event, not when
  the archive is finalized, so an interrupted download no longer loses
  media
- snapshots: stop calling reject() after the response was sent, which
  caused unhandled rejections

Recorder (recorder.ts)
- enforce DISK_MIN_FREE_GB with statfsSync (was a stub returning true)
- track the recording in a single state object and wait on an exit
  promise instead of polling; make cleanup idempotent
- return 502 when ffmpeg exits right after start
- recover orphaned .part files at startup
- return file names instead of full paths from /start, /stop and /status
This commit is contained in:
2026-10-26 01:19:16 +01:00
parent 64d0d3dcfe
commit c1047892ae
4 changed files with 316 additions and 323 deletions
+2
View File
@@ -57,6 +57,7 @@ services:
networks:
- kai-sa-cam-internal
- kai-sa-cam-tunnel
- kai-sa-cam-egress
cap_drop:
- ALL
security_opt:
@@ -73,3 +74,4 @@ networks:
kai-sa-cam-tunnel:
external: true
name: kai-sa-cam-tunnel
kai-sa-cam-egress: {}