feat(lan): auth on every box route — media grants + Ed25519 JWT (#3, dev) #4

Open
tucomunidad wants to merge 2 commits from feat/lan-auth into main
Collaborator

Closes the auth part of #3 (DEV only; nothing on Baldwin or prod, no tunnel, no CF).

  • No /api/lan route without auth, LAN included (/healthz static only).
  • snapshot/preview: camera-scoped HMAC grants; vod: grant in the path, bound to the range.
  • ban-list/schedule/recordings/cameras: cloud Ed25519 JWT (aud = device).
  • lan.auth_keys from a wss:// gateway only, stored 600, kid-only logs; documented in wire-format.md.
  • 32 tests incl. shared vectors with tucomunidad (tests/fixtures/lan-auth-vectors.json, byte-identical).

Portal side: tucomunidad.ai/tucomunidad branch feat/lan-auth.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LtXn27WVpdfyansgnf5cgA

Closes the auth part of #3 (DEV only; nothing on Baldwin or prod, no tunnel, no CF). - No /api/lan route without auth, LAN included (/healthz static only). - snapshot/preview: camera-scoped HMAC grants; vod: grant in the path, bound to the range. - ban-list/schedule/recordings/cameras: cloud Ed25519 JWT (aud = device). - lan.auth_keys from a wss:// gateway only, stored 600, kid-only logs; documented in wire-format.md. - 32 tests incl. shared vectors with tucomunidad (tests/fixtures/lan-auth-vectors.json, byte-identical). Portal side: tucomunidad.ai/tucomunidad branch feat/lan-auth. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LtXn27WVpdfyansgnf5cgA
Issue #3 (design §3). No /api/lan route answers without auth, LAN included:
- snapshot/preview: camera-scoped HMAC grant (?exp&sig); vod: grant in the path
  (/api/lan/vod/t/<exp>/<sig>/<cam>/<start>/<end>/<file>), vod prefix bound to
  the range; kinds snap|preview|vod never verify as each other.
- ban-list/schedule/recordings/cameras: cloud Ed25519 JWT (kid, iss, aud =
  this device, <= 15 min, one 60 s skew constant); the any-bearer check is gone.
- exp > now+20 min rejected (not clamped); no keys / unreadable key file =
  every route 401; /healthz static {ok, role} only.
- lan.auth_keys (cloud -> box, on connect) accepted only from a wss:// gateway;
  stored mode 600; logs kid adds/removes only. Documented in wire-format.md.
- Grant params are not forwarded to Frigate; responses Cache-Control private.
Tests: 32 (shared vectors with tucomunidad, route matrix unsigned/expired/
wrong-device/valid, cross-type swaps, fail-closed, wss guard, no TLS overrides
in src). Negative controls fail without the gates. eslint: the repo's config is
the old format the installed ESLint rejects (pre-existing, not changed here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LtXn27WVpdfyansgnf5cgA
CoS ruling on #3 (comment 35702):
- First message on every connect: {type:'hello', lanAuth:1}. The cloud sends
  lan.auth_keys and signed direct URLs only to boxes that announce it, so a
  Portal deploy never breaks an older box. Documented in wire-format.md; the
  contract test checks the union, the doc and that hello goes first.
- storeLanAuthKeys chmods the .tmp to 600 before the rename: writeFileSync's
  mode applies only on create, so a stale .tmp kept its old mode. Test with a
  644 stale file; removing the chmod fails it.
34 tests pass, tsc clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LtXn27WVpdfyansgnf5cgA
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/lan-auth:feat/lan-auth
git switch feat/lan-auth

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/lan-auth
git switch feat/lan-auth
git rebase main
git switch main
git merge --ff-only feat/lan-auth
git switch feat/lan-auth
git rebase main
git switch main
git merge --no-ff feat/lan-auth
git switch main
git merge --squash feat/lan-auth
git switch main
git merge --ff-only feat/lan-auth
git switch main
git merge feat/lan-auth
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tucomunidad-images/secbox!4
No description provided.