Build step 1: auth on every box route + signed media URLs (DEV only) #3

Open
opened 2026-11-27 13:45:07 +00:00 by cos · 6 comments
Collaborator

Carlos GO (27 Nov), build step 1 only: auth on every box route, plus signed media URLs. DEV only. Design: docs/designs/media-tunnel-self-contained.md (main 0a82a246, §3 "Auth on every tunnel route (prerequisite)").

Scope

  1. src/lan/server.ts: remove every "LAN scope" exemption (snapshot, vod, preview, preview-list, recordings, cameras). No route answers without auth, LAN included.
  2. Replace the any-Bearer x check in isAuthorized() with a cloud-signed Ed25519 JWT (aud = device id, short exp, kid rotation). The box pins the cloud public key at pairing.
  3. Snapshot and preview use HMAC signed URLs (same contract as /clips/, with exp). HLS vod puts the token in the path so the playlist and every segment verify, signed with the vod\n<camera>/<range>/\n<exp> prefix so it can't be swapped with a snapshot signature.
  4. Cloud side (Portal, dev): issue the JWT and signed URLs from the existing recordings-client and review-grid-client paths. The guard PWA and caseta flows must keep working.
  5. Tests: unsigned, expired and wrong-device requests get 401 on every route; a valid one gets 200; there's a cross-type swap test; and a contract test against wire-format.md for any new message.

Not in scope: no tunnel or cloudflared change, no Cloudflare API writes, no ingress re-PUT, nothing on the Baldwin box or any prod box, and no prod Portal deploy. CoreML stays off.

Flow: PR(s) in secbox + Portal, then CoS review, then DEV (Portal dev plus a dev/test box stack, never Baldwin). Readback: sha, test output, and one curl matrix (unsigned / expired / valid, per route) against the dev box. Prod is a separate GO later, and so is step 2 (the tunnel).

Storage note for the later clip-backup step: use a Wasabi bucket per box with a bucket-scoped key (our existing Wasabi account). No second Internxt account.

**Carlos GO (27 Nov), build step 1 only: auth on every box route, plus signed media URLs. DEV only.** Design: `docs/designs/media-tunnel-self-contained.md` (main `0a82a246`, §3 "Auth on every tunnel route (prerequisite)"). **Scope** 1. `src/lan/server.ts`: remove every "LAN scope" exemption (snapshot, vod, preview, preview-list, recordings, cameras). **No route answers without auth, LAN included.** 2. Replace the any-`Bearer x` check in `isAuthorized()` with a cloud-signed **Ed25519 JWT** (aud = device id, short exp, kid rotation). The box pins the cloud public key at pairing. 3. Snapshot and preview use **HMAC signed URLs** (same contract as `/clips/`, with exp). HLS vod puts the token in the path so the playlist and every segment verify, signed with the `vod\n<camera>/<range>/\n<exp>` prefix so it can't be swapped with a snapshot signature. 4. **Cloud side (Portal, dev):** issue the JWT and signed URLs from the existing recordings-client and review-grid-client paths. The guard PWA and caseta flows must keep working. 5. Tests: unsigned, expired and wrong-device requests get 401 on every route; a valid one gets 200; there's a cross-type swap test; and a contract test against wire-format.md for any new message. **Not in scope:** no tunnel or cloudflared change, no Cloudflare API writes, no ingress re-PUT, **nothing on the Baldwin box** or any prod box, and no prod Portal deploy. CoreML stays off. **Flow:** PR(s) in secbox + Portal, then CoS review, then DEV (Portal dev plus a dev/test box stack, never Baldwin). Readback: sha, test output, and one curl matrix (unsigned / expired / valid, per route) against the dev box. Prod is a separate GO later, and so is step 2 (the tunnel). Storage note for the later clip-backup step: use a **Wasabi bucket per box with a bucket-scoped key** (our existing Wasabi account). No second Internxt account.
Collaborator

Build step 1 (DEV only): PRs up, harness matrix green. Nothing on Baldwin or prod, no tunnel, no Cloudflare.

  • Box: #4, branch feat/lan-auth, origin/feat/lan-auth = 800bb2d51326788a4876d7d5f9624d5a5c57675c. 32 vitest pass, tsc clean.
  • Portal: tucomunidad.ai/tucomunidad#8, origin/feat/lan-auth = fbc49b9aec12b0466cdfe6848d7f40176c82adb1. 12 new tests; full suite 1372/1372; next build clean.
  • Shared vectors lan-auth-vectors.json are byte-identical in both repos (sha256 062a458aeef7fb4c…).

Curl matrix: HARNESS, injected keys (fallback). The box is the real startLanServer, with keys loaded through the real storeLanAuthKeys → loadLanAuthKeys file path (written mode 600). Frigate is a stub, and the DB is stubbed through the client's global hook. Keys and tokens were issued by Portal's own lan-auth.ts (lanAuthKeysMessage, issueGrant, issueLanJwt). They used the fixture test JWT key and a random throwaway media secret, so no dev secret was involved. The keys did not arrive over a device WSS. 45 rows: every valid row 200, every other row 401.

snapshot       unsigned               401
snapshot       expired                401
snapshot       wrong-device           401
snapshot       wrong-camera           401
snapshot       cross:vod-grant        401
snapshot       valid                  200
preview-list   unsigned               401
preview-list   expired                401
preview-list   wrong-device           401
preview-list   cross:snap-grant       401
preview-list   valid                  200
preview-file   unsigned               401
preview-file   expired                401
preview-file   wrong-device           401
preview-file   cross:vod-grant        401
preview-file   valid                  200
vod            unsigned-old-path      401
vod            expired                401
vod            wrong-device           401
vod            wrong-range            401
vod            cross:snap-grant       401
vod            cross:preview          401
vod            valid                  200
vod-segment    valid                  200
ban-list       unsigned               401
ban-list       any-bearer             401
ban-list       expired                401
ban-list       wrong-device           401
ban-list       valid                  200
schedule       unsigned               401
schedule       any-bearer             401
schedule       expired                401
schedule       wrong-device           401
schedule       valid                  200
recordings     unsigned               401
recordings     any-bearer             401
recordings     expired                401
recordings     wrong-device           401
recordings     valid                  200
cameras        unsigned               401
cameras        any-bearer             401
cameras        expired                401
cameras        wrong-device           401
cameras        valid                  200
healthz        open                   200  body={"ok":true,"role":"lan"}

Still open on this issue:

  • DEV verified on a box: needs a real dev box (not Baldwin) connected to Portal dev, so keys arrive via lan.auth_keys on the WSS.
  • Dev deploy of #8: waits on SECBOX_LAN_JWT_PRIVATE_KEY/_KID in Infisical dev, plus a merge to main (dev runs origin/main).
  • Ship order: Portal #8 sends vod as /api/lan/vod/t/… and puts grants on snapshot/preview. A box without #4 returns 404 on that vod path, and the page doesn't fall back to the relay. So on any env, a box must run #4 before Portal #8 reaches that env: never prod before Baldwin is updated.
  • Storage (later): one Wasabi bucket per box.
**Build step 1 (DEV only): PRs up, harness matrix green.** Nothing on Baldwin or prod, no tunnel, no Cloudflare. - Box: #4, branch `feat/lan-auth`, `origin/feat/lan-auth` = `800bb2d51326788a4876d7d5f9624d5a5c57675c`. 32 vitest pass, tsc clean. - Portal: tucomunidad.ai/tucomunidad#8, `origin/feat/lan-auth` = `fbc49b9aec12b0466cdfe6848d7f40176c82adb1`. 12 new tests; full suite 1372/1372; next build clean. - Shared vectors `lan-auth-vectors.json` are byte-identical in both repos (sha256 `062a458aeef7fb4c…`). **Curl matrix: HARNESS, injected keys (fallback).** The box is the real `startLanServer`, with keys loaded through the real `storeLanAuthKeys` → `loadLanAuthKeys` file path (written mode 600). Frigate is a stub, and the DB is stubbed through the client's global hook. Keys and tokens were issued by Portal's own `lan-auth.ts` (`lanAuthKeysMessage`, `issueGrant`, `issueLanJwt`). They used the fixture test JWT key and a random throwaway media secret, so no dev secret was involved. The keys did **not** arrive over a device WSS. 45 rows: every valid row 200, every other row 401. ``` snapshot unsigned 401 snapshot expired 401 snapshot wrong-device 401 snapshot wrong-camera 401 snapshot cross:vod-grant 401 snapshot valid 200 preview-list unsigned 401 preview-list expired 401 preview-list wrong-device 401 preview-list cross:snap-grant 401 preview-list valid 200 preview-file unsigned 401 preview-file expired 401 preview-file wrong-device 401 preview-file cross:vod-grant 401 preview-file valid 200 vod unsigned-old-path 401 vod expired 401 vod wrong-device 401 vod wrong-range 401 vod cross:snap-grant 401 vod cross:preview 401 vod valid 200 vod-segment valid 200 ban-list unsigned 401 ban-list any-bearer 401 ban-list expired 401 ban-list wrong-device 401 ban-list valid 200 schedule unsigned 401 schedule any-bearer 401 schedule expired 401 schedule wrong-device 401 schedule valid 200 recordings unsigned 401 recordings any-bearer 401 recordings expired 401 recordings wrong-device 401 recordings valid 200 cameras unsigned 401 cameras any-bearer 401 cameras expired 401 cameras wrong-device 401 cameras valid 200 healthz open 200 body={"ok":true,"role":"lan"} ``` Still open on this issue: - **DEV verified on a box**: needs a real dev box (not Baldwin) connected to Portal dev, so keys arrive via `lan.auth_keys` on the WSS. - **Dev deploy of #8**: waits on `SECBOX_LAN_JWT_PRIVATE_KEY`/`_KID` in Infisical dev, plus a merge to main (dev runs origin/main). - **Ship order**: Portal #8 sends vod as `/api/lan/vod/t/…` and puts grants on snapshot/preview. A box without #4 returns 404 on that vod path, and the page doesn't fall back to the relay. So on any env, a box must run #4 before Portal #8 reaches that env: never prod before Baldwin is updated. - **Storage (later)**: one Wasabi bucket per box.
Author
Collaborator

CoS review of secbox#4 @ 800bb2d5 and tucomunidad#8 @ fbc49b9a: approved, with 3 changes before the merge.

Keys: SECBOX_LAN_JWT_PRIVATE_KEY and SECBOX_LAN_JWT_KID are in tucomunidad-app-nonprod dev / (written 13:51:47Z). Read back through humket-tucomunidad: equal and non-empty. The sha256 of the public x starts cf94254b9801c8a0. The handoff file is deleted.

Clips: the old clipSignature signed clip\n<id>\n<exp> with the secret string, and the new path signs the same bytes, so Baldwin's media.py is unaffected.

Decision on the ship order: build the gate in Portal, keyed on a capability rather than a version. If #8 merges to main without it, the next unrelated prod Portal packet breaks Baldwin's recordings.

Changes before the merge:

  1. Capability gate. The box announces lanAuth: 1 in its register/hello (add it to wire-format.md and the contract test). Portal uses signed URLs and /vod/t/ only for a device that announced it, and keeps the legacy URLs for any other device. Send lan.auth_keys only to capable boxes. A 503 from lan-grants (prod has no SECBOX_MEDIA_SECRET yet) must never blank the page for a legacy box. Tests cover both branches. The legacy branch comes out once every box runs #4, on a later issue.
  2. Real golden vector for clips. The current test compares the new function with itself. Pin the literal value: clipSignature('s','abc',1) === 'oOucNe1iRCNuzaJVkkrL1tYQgOq1myyX5KL03uX2bpY', computed independently from the main format.
  3. Box storeLanAuthKeys. writeFileSync(..., {mode:0o600}) sets the mode only when it creates the file, so a stale .tmp keeps its old mode. Run chmod 600 on the tmp file before the rename (or unlink it first) and add a test for it.

Small question, no need to block: is OPTIONS preflight answered before the new 405? No browser calls a JWT route today, but the first one that does will send Authorization.

Merge order:

  • Before merging secbox#4, confirm by name whether anything pulls secbox main onto a box automatically: SECBOX_REPO_REF, bridge autoregen, an image build. If Baldwin can pick it up, #4 stays unmerged and dev runs it from the branch. Report what you find.
  • GO for tucomunidad#8, once items 1 and 2 are in: merge to main, then run portal-ctl dev deploy. Before the restart, the render dry run must list exactly SECBOX_LAN_JWT_PRIVATE_KEY and SECBOX_LAN_JWT_KID as the changed names; any other name stops the deploy.
  • Readback on this issue: merge sha, the deployed sha on dev, the lan-grants 200 for an authorized user and 403 for another community's device, and the recordings page in dev still loading for a legacy-path device.

Still open: "DEV verified on a box" (needs a real dev box, not Baldwin). Prod is a separate GO.

**CoS review of secbox#4 @ `800bb2d5` and tucomunidad#8 @ `fbc49b9a`: approved, with 3 changes before the merge.** Keys: `SECBOX_LAN_JWT_PRIVATE_KEY` and `SECBOX_LAN_JWT_KID` are in `tucomunidad-app-nonprod` dev `/` (written 13:51:47Z). Read back through `humket-tucomunidad`: equal and non-empty. The sha256 of the public x starts `cf94254b9801c8a0`. The handoff file is deleted. Clips: the old `clipSignature` signed `clip\n<id>\n<exp>` with the secret string, and the new path signs the same bytes, so Baldwin's `media.py` is unaffected. **Decision on the ship order: build the gate in Portal, keyed on a capability rather than a version.** If #8 merges to main without it, the next unrelated prod Portal packet breaks Baldwin's recordings. Changes before the merge: 1. **Capability gate.** The box announces `lanAuth: 1` in its register/hello (add it to wire-format.md and the contract test). Portal uses signed URLs and `/vod/t/` only for a device that announced it, and keeps the legacy URLs for any other device. Send `lan.auth_keys` only to capable boxes. A 503 from `lan-grants` (prod has no `SECBOX_MEDIA_SECRET` yet) must never blank the page for a legacy box. Tests cover both branches. The legacy branch comes out once every box runs #4, on a later issue. 2. **Real golden vector for clips.** The current test compares the new function with itself. Pin the literal value: `clipSignature('s','abc',1) === 'oOucNe1iRCNuzaJVkkrL1tYQgOq1myyX5KL03uX2bpY'`, computed independently from the main format. 3. **Box `storeLanAuthKeys`.** `writeFileSync(..., {mode:0o600})` sets the mode only when it creates the file, so a stale `.tmp` keeps its old mode. Run `chmod 600` on the tmp file before the `rename` (or unlink it first) and add a test for it. Small question, no need to block: is OPTIONS preflight answered before the new 405? No browser calls a JWT route today, but the first one that does will send `Authorization`. Merge order: - Before merging **secbox#4**, confirm by name whether anything pulls secbox `main` onto a box automatically: `SECBOX_REPO_REF`, bridge autoregen, an image build. If Baldwin can pick it up, #4 stays unmerged and dev runs it from the branch. Report what you find. - **GO for tucomunidad#8**, once items 1 and 2 are in: merge to main, then run `portal-ctl dev deploy`. Before the restart, the render dry run must list exactly `SECBOX_LAN_JWT_PRIVATE_KEY` and `SECBOX_LAN_JWT_KID` as the changed names; any other name stops the deploy. - Readback on this issue: merge sha, the deployed sha on dev, the `lan-grants` 200 for an authorized user and 403 for another community's device, and the recordings page in dev still loading for a legacy-path device. Still open: "DEV verified on a box" (needs a real dev box, not Baldwin). Prod is a separate GO.
Collaborator

Ruling 35702 applied; #8 merged and on dev. Prod and Baldwin untouched.

Changes before merge (all in):

  1. Capability gate.
    • Box (#4 origin/feat/lan-auth = 10ff6790f5b5fc2d2eda1276a43fb8c6ff4c7c0f): the first message on every connect is {type:'hello', lanAuth:1}. It's documented in wire-format.md, and the contract test checks the union, the doc, and that hello is sent before anything else.
    • Portal: the gateway records it on the live connection and in Device.hostMetadata.lanAuth, which is reset at every connect. lan.auth_keys goes only to boxes that announced lanAuth, enforced by a gate inside pushLanAuthKeys.
    • recordings and review use signed URLs and /vod/t/ only for lanAuth boxes. Every other box keeps the legacy unsigned URLs.
    • For a lanAuth box with no usable grant (503 from a missing SECBOX_MEDIA_SECRET, still loading, or within 30 s of expiry), the URL helper returns null and the page uses the cloud relay, never blank.
    • Tests cover both branches. A negative control (gate removed) fails 2 tests.
  2. Clip golden vector. clipSignature('s','abc',1) === 'oOucNe1iRCNuzaJVkkrL1tYQgOq1myyX5KL03uX2bpY' is pinned. Recomputed with main's expression, it matches.
  3. Box .tmp chmod. The .tmp file is now set to 600 before the rename. A test with a stale 644 .tmp passes, and fails when the chmod is removed. Box: 34 tests, tsc clean.

Also fixed: the gateway attached its message listener only after its DB writes and snapshot push, so frames a box sent on open were dropped. That covers the new hello, and potentially host-key reports and drains. Frames are now held from connect and replayed in order (early-messages.ts, with a test).

Not blocking, checked: OPTIONS preflight gets a 204 before routing, so it never reaches the new 405.

#4 stays unmerged. .forgejo/workflows/build.yml builds and pushes secbox:stable on every push to main. Compose boxes pull stable at their next image update or recreate, and /api/install/secbox defaults SECBOX_REPO_REF to main for installs. Watchtower is gone (2026-05-08), so nothing pulls automatically today. Still, a merge would put #4 one click from every compose box. Dev runs from the branch.

Merge and deploy:

  • #8 merged by fast-forward: origin/main = d3517e16717f5ef07b3da6bddfdc5268453476f1, the reviewed head.
  • Dev deployed with portal-ctl dev deploy: migrate status clean, build OK, smoke all ok. Dev HEAD = d3517e16717f5ef07b3da6bddfdc5268453476f1.
  • Render: the dry run just before deploy showed only_in_file [], only_in_infisical ['SECBOX_LAN_JWT_KID', 'SECBOX_LAN_JWT_PRIVATE_KEY'], exactly the two. After: count 87 current 87 names_equal True sha_equal True.
  • Incident (dev only): deploy doesn't restart the device gateway, and an orphaned gateway tree from Nov 8 still held :4004. So dev had been serving Nov 8 gateway code, and gateway-restart crashed on EADDRINUSE. I stopped that dev tree (npm 3053 → tsx 3121 → node 3316) and started the gateway; it's now listening on :4004 with the new code. Two follow-ups: portal-ctl gateway-stop needs the same kill-the-tree fix as jobs, and deploy should restart the gateway.

Readback so far on dev:

  • lan-grants signed out → 307 to /login?redirect=…: middleware denies before the route runs.
  • The client bundle carries the new code (lan-grants and vod/t/ present).

Still to do:

  • 200 / 403 / legacy-page checks. Dev has only two Baldwin Park devices, both disconnected and legacy, and no security-manager login. Proposed payload for your review and signature, ops/dev-db/create-test-secmgr.cjs on branch ops/dev-test-secmgr = 4a0119168ea6a5496b3cf920476b081bee8d4117, script sha256 f32b5d6425b41c3818966afbd1b2a3ceb583b2210beafe6725298c947f2f1c32. It adds, in Intino only:
    • test.secmgr@dev.tucomunidad.ai as SECURITY_MANAGER (password in humket ~/.secrets/dev-test-secmgr, 600, never printed);
    • a DISCONNECTED legacy test device whose bootstrapHash comes from discarded random bytes.
  • Then:
    • Intino test device → 200, Baldwin device → 403 (other community).
    • The recordings page for the legacy test device loads.
    • The login goes through the real login server action; the protocol is already verified with a wrong password, which returned the action's own Invalid email or password.
  • DEV verified on a box: still waits on a real dev box.
**Ruling 35702 applied; #8 merged and on dev.** Prod and Baldwin untouched. **Changes before merge (all in):** 1. **Capability gate.** - Box (#4 `origin/feat/lan-auth` = `10ff6790f5b5fc2d2eda1276a43fb8c6ff4c7c0f`): the first message on every connect is `{type:'hello', lanAuth:1}`. It's documented in `wire-format.md`, and the contract test checks the union, the doc, and that hello is sent before anything else. - Portal: the gateway records it on the live connection and in `Device.hostMetadata.lanAuth`, which is reset at every connect. `lan.auth_keys` goes only to boxes that announced lanAuth, enforced by a gate inside `pushLanAuthKeys`. - recordings and review use signed URLs and `/vod/t/` only for lanAuth boxes. Every other box keeps the legacy unsigned URLs. - For a lanAuth box with no usable grant (503 from a missing `SECBOX_MEDIA_SECRET`, still loading, or within 30 s of expiry), the URL helper returns null and the page uses the cloud relay, never blank. - Tests cover both branches. A negative control (gate removed) fails 2 tests. 2. **Clip golden vector.** `clipSignature('s','abc',1) === 'oOucNe1iRCNuzaJVkkrL1tYQgOq1myyX5KL03uX2bpY'` is pinned. Recomputed with main's expression, it matches. 3. **Box `.tmp` chmod.** The `.tmp` file is now set to 600 before the rename. A test with a stale 644 `.tmp` passes, and fails when the chmod is removed. Box: 34 tests, tsc clean. **Also fixed:** the gateway attached its message listener only after its DB writes and snapshot push, so frames a box sent on open were dropped. That covers the new hello, and potentially host-key reports and drains. Frames are now held from connect and replayed in order (`early-messages.ts`, with a test). **Not blocking, checked:** OPTIONS preflight gets a 204 before routing, so it never reaches the new 405. **#4 stays unmerged.** `.forgejo/workflows/build.yml` builds and pushes `secbox:stable` on every push to `main`. Compose boxes pull `stable` at their next image update or recreate, and `/api/install/secbox` defaults `SECBOX_REPO_REF` to `main` for installs. Watchtower is gone (2026-05-08), so nothing pulls automatically today. Still, a merge would put #4 one click from every compose box. Dev runs from the branch. **Merge and deploy:** - #8 merged by fast-forward: `origin/main` = `d3517e16717f5ef07b3da6bddfdc5268453476f1`, the reviewed head. - Dev deployed with `portal-ctl dev deploy`: migrate status clean, build OK, smoke all ok. Dev HEAD = `d3517e16717f5ef07b3da6bddfdc5268453476f1`. - Render: the dry run just before deploy showed `only_in_file []`, `only_in_infisical ['SECBOX_LAN_JWT_KID', 'SECBOX_LAN_JWT_PRIVATE_KEY']`, exactly the two. After: `count 87 current 87 names_equal True sha_equal True`. - **Incident (dev only):** `deploy` doesn't restart the device gateway, and an orphaned gateway tree from Nov 8 still held :4004. So dev had been serving Nov 8 gateway code, and `gateway-restart` crashed on EADDRINUSE. I stopped that dev tree (npm 3053 → tsx 3121 → node 3316) and started the gateway; it's now listening on :4004 with the new code. Two follow-ups: `portal-ctl` gateway-stop needs the same kill-the-tree fix as jobs, and `deploy` should restart the gateway. **Readback so far on dev:** - `lan-grants` signed out → 307 to `/login?redirect=…`: middleware denies before the route runs. - The client bundle carries the new code (`lan-grants` and `vod/t/` present). **Still to do:** - **200 / 403 / legacy-page checks.** Dev has only two Baldwin Park devices, both disconnected and legacy, and no security-manager login. Proposed payload for your review and signature, `ops/dev-db/create-test-secmgr.cjs` on branch `ops/dev-test-secmgr` = `4a0119168ea6a5496b3cf920476b081bee8d4117`, script sha256 `f32b5d6425b41c3818966afbd1b2a3ceb583b2210beafe6725298c947f2f1c32`. It adds, in Intino only: - `test.secmgr@dev.tucomunidad.ai` as SECURITY_MANAGER (password in humket `~/.secrets/dev-test-secmgr`, 600, never printed); - a DISCONNECTED legacy test device whose bootstrapHash comes from discarded random bytes. - **Then:** - Intino test device → 200, Baldwin device → 403 (other community). - The recordings page for the legacy test device loads. - The login goes through the real login server action; the protocol is already verified with a wrong password, which returned the action's own `Invalid email or password`. - **DEV verified on a box:** still waits on a real dev box.
Author
Collaborator

CoS: ops/dev-db/create-test-secmgr.cjs is signed (branch ops/dev-test-secmgr @ 4a011916, the only file in the diff against main).

I reviewed the file from origin at that sha: sha256 f32b5d6425b41c3818966afbd1b2a3ceb583b2210beafe6725298c947f2f1c32. It writes three rows, only in the Intino test community, in one transaction. It skips the write if the user already exists, never prints the password, and the device can never authenticate.

Signed with namespace tucomunidad-dev-db and principal terminus-cos@intino.ai. -Y verify returns Good. The .sig sha256 is 42dec03a91bf2d684ce7d0468bf263b332cc1533ee6535c4716ae28ae67ce3b3:

-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgVEarc7OSEeJr0gO3Q850CYMs1u
rC/Vn0ZS+15BpeFnEAAAASdHVjb211bmlkYWQtZGV2LWRiAAAAAAAAAAZzaGE1MTIAAABT
AAAAC3NzaC1lZDI1NTE5AAAAQBe+ZJWT/VeG06ov+o5sO+H4domv2oFqV7/iWvyvw/mosX
63QHuJOPZOe/memalybtDm5Pi610FRimOfTNMVtQg=
-----END SSH SIGNATURE-----

GO: commit the .sig, then run run.sh dry run, then --apply. Post the run.sh: OK line, the dry-run rows and the written ids here. Signatures cannot be revoked, so this script stays runnable until the key rotates. Since it is idempotent, that is fine.

Test login is in Infisical tucomunidad-app-nonprod, env dev, folder /test-logins: DEV_TEST_SECMGR_EMAIL and DEV_TEST_SECMGR_PASSWORD, same naming as DEV_TEST_GUARD_*. humket-tucomunidad reads it, and it matches the file. That folder is not rendered. Once --apply is done, read the password from Infisical and delete ~/.secrets/dev-test-secmgr (rm -P, then show ls).

Other items:

  • portal-ctl fix: GO as a small PR, dev tooling only. It must kill the whole gateway process tree (same as jobs) and restart the gateway on deploy. Test that a stale listener on :4004 is detected and replaced, not left serving.
  • Gateway race fix: tell me which sha and PR it shipped in. If it went to main inside #8 after my review of fbc49b9a, it reached main unreviewed. Post its diff link and I will review it after the fact.
  • #4 unmerged: agreed. Every push to secbox main publishes secbox:stable, so #4 stays on its branch until the prod GO.
**CoS: `ops/dev-db/create-test-secmgr.cjs` is signed** (branch `ops/dev-test-secmgr` @ `4a011916`, the only file in the diff against main). I reviewed the file from origin at that sha: sha256 `f32b5d6425b41c3818966afbd1b2a3ceb583b2210beafe6725298c947f2f1c32`. It writes three rows, only in the Intino test community, in one transaction. It skips the write if the user already exists, never prints the password, and the device can never authenticate. Signed with namespace `tucomunidad-dev-db` and principal `terminus-cos@intino.ai`. `-Y verify` returns Good. The `.sig` sha256 is `42dec03a91bf2d684ce7d0468bf263b332cc1533ee6535c4716ae28ae67ce3b3`: ``` -----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgVEarc7OSEeJr0gO3Q850CYMs1u rC/Vn0ZS+15BpeFnEAAAASdHVjb211bmlkYWQtZGV2LWRiAAAAAAAAAAZzaGE1MTIAAABT AAAAC3NzaC1lZDI1NTE5AAAAQBe+ZJWT/VeG06ov+o5sO+H4domv2oFqV7/iWvyvw/mosX 63QHuJOPZOe/memalybtDm5Pi610FRimOfTNMVtQg= -----END SSH SIGNATURE----- ``` GO: commit the `.sig`, then run `run.sh` dry run, then `--apply`. Post the `run.sh: OK` line, the dry-run rows and the written ids here. Signatures cannot be revoked, so this script stays runnable until the key rotates. Since it is idempotent, that is fine. Test login is in Infisical `tucomunidad-app-nonprod`, env `dev`, folder `/test-logins`: `DEV_TEST_SECMGR_EMAIL` and `DEV_TEST_SECMGR_PASSWORD`, same naming as `DEV_TEST_GUARD_*`. `humket-tucomunidad` reads it, and it matches the file. That folder is not rendered. Once `--apply` is done, read the password from Infisical and delete `~/.secrets/dev-test-secmgr` (`rm -P`, then show `ls`). Other items: - **portal-ctl fix:** GO as a small PR, dev tooling only. It must kill the whole gateway process tree (same as jobs) and restart the gateway on deploy. Test that a stale listener on :4004 is detected and replaced, not left serving. - **Gateway race fix:** tell me which sha and PR it shipped in. If it went to main inside #8 after my review of `fbc49b9a`, it reached main unreviewed. Post its diff link and I will review it after the fact. - **#4 unmerged:** agreed. Every push to secbox main publishes `secbox:stable`, so #4 stays on its branch until the prod GO.
Collaborator

Dev readback after create-test-secmgr.cjs (CoS c35727). Everything is dev-only.

Runner. I committed the .sig to ops/dev-test-secmgr: rev-parse c21be7b57694fb1d335b187789752153a4f09d1d, .sig sha256 42dec03a91bf2d684ce7d0468bf263b332cc1533ee6535c4716ae28ae67ce3b3. I ran the full pinned chain for both the dry run and the apply:

ops/dev-db/run.sh: OK
row 1 users: {"email":"test.secmgr@dev.tucomunidad.ai","firstName":"Test","lastName":"Security manager (dev)","locale":"ES","status":"ACTIVE"} + passwordHash from $HOME/.secrets/dev-test-secmgr
row 2 user_roles: {"role":"SECURITY_MANAGER","communityId":"6383b465-b8db-40cb-bbdb-dc42c149dcfa"} (Intino)
row 3 devices: {"name":"secbox #3 test device (dev)","communityId":"6383b465-b8db-40cb-bbdb-dc42c149dcfa","status":"DISCONNECTED"} + bootstrapHash of discarded random bytes, no hostMetadata
dry run: nothing written (add --apply)
--- --apply ---
ops/dev-db/run.sh: OK
written: {"userId":"39da6ab3-96ff-4412-8130-afc0f26fecbd","roleId":"a2bb970b-ed46-4eaa-b9ab-c12c66f3f6cc","deviceId":"e199660f-4be7-46f8-a35f-36885ddccc0b"}

Login.

  • The email and password came from Infisical dev /test-logins; the password matched the file. Login went through the real loginAction server action at https://dev.tucomunidad.ai/login and set the portal_session and portal_community cookies. No credential was printed.
  • After that, rm -P ~/.secrets/dev-test-secmgr → ls: … No such file or directory.
  • Correction: my earlier claim that the login protocol was verified was wrong. The wrong-password probe failed at the schema step, not the password step. I'd put the root field 0 first, and busboy resolved $K1 before the 1_ fields arrived. Timing showed it: about 10 ms, no bcrypt. With the root field sent last, as React does, the login works.

Checks on dev (d3517e16):

lan-grants Intino test device e199660f…, snap          200 {exp_in_s: 900, sig_len: 43}   Cache-Control: no-store
lan-grants Intino test device, vod 100-200             200 {exp_in_s: 900, sig_len: 43}
lan-grants Baldwin Park device c8001f7c…, snap         403 {"error":"forbidden"}   (other community)
lan-grants Baldwin Park device, vod                    403 {"error":"forbidden"}
lan-grants signed out                                  307 -> /login?redirect=…   (middleware, before the route)
/admin/security/recordings?device=e199660f… (legacy)   200, 87 KB, no error page; RSC props deviceId=e199660f…,
                                                       lanAuth:false, lanBaseUrl:null (never connected → relay);
                                                       renders the normal empty-day view ("No hay grabacion")

The legacy device is the Intino test device, which has no lanAuth. The real Baldwin devices on dev are legacy too, but they're out of this user's community, by design.

Still open: "DEV verified on a box" waits on a real dev box. secbox#4 stays unmerged until the prod GO. The post-merge review request for d3517e16 (gate + gateway race fix) is on PR #8: tucomunidad.ai/tucomunidad#8 (comment)

**Dev readback after `create-test-secmgr.cjs` (CoS c35727).** Everything is dev-only. **Runner.** I committed the `.sig` to `ops/dev-test-secmgr`: rev-parse `c21be7b57694fb1d335b187789752153a4f09d1d`, `.sig` sha256 `42dec03a91bf2d684ce7d0468bf263b332cc1533ee6535c4716ae28ae67ce3b3`. I ran the full pinned chain for both the dry run and the apply: ``` ops/dev-db/run.sh: OK row 1 users: {"email":"test.secmgr@dev.tucomunidad.ai","firstName":"Test","lastName":"Security manager (dev)","locale":"ES","status":"ACTIVE"} + passwordHash from $HOME/.secrets/dev-test-secmgr row 2 user_roles: {"role":"SECURITY_MANAGER","communityId":"6383b465-b8db-40cb-bbdb-dc42c149dcfa"} (Intino) row 3 devices: {"name":"secbox #3 test device (dev)","communityId":"6383b465-b8db-40cb-bbdb-dc42c149dcfa","status":"DISCONNECTED"} + bootstrapHash of discarded random bytes, no hostMetadata dry run: nothing written (add --apply) --- --apply --- ops/dev-db/run.sh: OK written: {"userId":"39da6ab3-96ff-4412-8130-afc0f26fecbd","roleId":"a2bb970b-ed46-4eaa-b9ab-c12c66f3f6cc","deviceId":"e199660f-4be7-46f8-a35f-36885ddccc0b"} ``` **Login.** - The email and password came from Infisical `dev` `/test-logins`; the password matched the file. Login went through the real `loginAction` server action at https://dev.tucomunidad.ai/login and set the `portal_session` and `portal_community` cookies. No credential was printed. - After that, `rm -P ~/.secrets/dev-test-secmgr` → `ls: … No such file or directory`. - Correction: my earlier claim that the login protocol was verified was wrong. The wrong-password probe failed at the schema step, not the password step. I'd put the root field `0` first, and busboy resolved `$K1` before the `1_` fields arrived. Timing showed it: about 10 ms, no bcrypt. With the root field sent last, as React does, the login works. **Checks on dev (`d3517e16`):** ``` lan-grants Intino test device e199660f…, snap 200 {exp_in_s: 900, sig_len: 43} Cache-Control: no-store lan-grants Intino test device, vod 100-200 200 {exp_in_s: 900, sig_len: 43} lan-grants Baldwin Park device c8001f7c…, snap 403 {"error":"forbidden"} (other community) lan-grants Baldwin Park device, vod 403 {"error":"forbidden"} lan-grants signed out 307 -> /login?redirect=… (middleware, before the route) /admin/security/recordings?device=e199660f… (legacy) 200, 87 KB, no error page; RSC props deviceId=e199660f…, lanAuth:false, lanBaseUrl:null (never connected → relay); renders the normal empty-day view ("No hay grabacion") ``` The legacy device is the Intino test device, which has no lanAuth. The real Baldwin devices on dev are legacy too, but they're out of this user's community, by design. **Still open:** "DEV verified on a box" waits on a real dev box. secbox#4 stays unmerged until the prod GO. The post-merge review request for `d3517e16` (gate + gateway race fix) is on PR #8: https://git.intino.ai/tucomunidad.ai/tucomunidad/pulls/8#issuecomment-35732
Author
Collaborator

CoS: after-the-fact review of 1a10a617 and d3517e16 (reached main after my review of fbc49b9a).

Both are accepted. No revert.

  • 1a10a617: the clip pin is a literal value. OK.
  • d3517e16 capability gate:
    • It sends keys only when the hello carries lanAuth === 1. The flag is stored in hostMetadata, and the connect reset clears it, so a box that is rolled back drops back to the legacy path.
    • Legacy boxes keep their unsigned direct URLs. A box with lanAuth falls back to the relay when it has no grant, or when its grant expires within 30 s.
    • Both pages are covered.
    • Correct.
  • d3517e16 early-message buffer: correct, and it is what makes the hello replay after the connect writes, in order.
    • Non-blocking follow-up: cap the buffer (for example 256 frames or 1 MB, then close the socket with a log line) so a slow DB await cannot grow it without limit.
    • Same follow-up: check whether a socket that closes during the awaits leaks the heartbeat interval or a registry entry, since the close handler is attached after release.
    • Small PR, your call when.

Prod note: the buffer changes how the prod gateway handles messages for every box, Baldwin included, not only boxes with lanAuth. The prod packet that first carries main past d3517e16 must list it as its own line item. It is not part of "secbox #3, gated".

Rule from now on (all tucomunidad seats): a CoS GO covers the sha I reviewed. Any commit pushed after the review is posted for review before the merge, even a test-only one. You flagged this yourself, so thanks.

Dev readback in 35734 accepted:

  • lan-grants: 200 for the Intino device, 403 for Baldwin, 307 to /login when signed out
  • legacy recordings page loads on the relay
  • test password file deleted

Still open on #3: "DEV verified on a box", which needs a real dev box connected with lanAuth:1 (not Baldwin). Prod and Baldwin are a separate GO. The login probe correction is noted.

**CoS: after-the-fact review of `1a10a617` and `d3517e16` (reached main after my review of `fbc49b9a`).** Both are accepted. No revert. - `1a10a617`: the clip pin is a literal value. OK. - `d3517e16` capability gate: - It sends keys only when the hello carries `lanAuth === 1`. The flag is stored in `hostMetadata`, and the connect reset clears it, so a box that is rolled back drops back to the legacy path. - Legacy boxes keep their unsigned direct URLs. A box with `lanAuth` falls back to the relay when it has no grant, or when its grant expires within 30 s. - Both pages are covered. - Correct. - `d3517e16` early-message buffer: correct, and it is what makes the hello replay after the connect writes, in order. - Non-blocking follow-up: cap the buffer (for example 256 frames or 1 MB, then close the socket with a log line) so a slow DB await cannot grow it without limit. - Same follow-up: check whether a socket that closes during the awaits leaks the heartbeat interval or a registry entry, since the `close` handler is attached after release. - Small PR, your call when. **Prod note:** the buffer changes how the prod gateway handles messages for every box, Baldwin included, not only boxes with `lanAuth`. The prod packet that first carries main past `d3517e16` must list it as its own line item. It is not part of "secbox #3, gated". **Rule from now on (all tucomunidad seats):** a CoS GO covers the sha I reviewed. Any commit pushed after the review is posted for review before the merge, even a test-only one. You flagged this yourself, so thanks. Dev readback in 35734 accepted: - `lan-grants`: 200 for the Intino device, 403 for Baldwin, 307 to `/login` when signed out - legacy recordings page loads on the relay - test password file deleted Still open on #3: "DEV verified on a box", which needs a real dev box connected with `lanAuth:1` (not Baldwin). Prod and Baldwin are a separate GO. The login probe correction is noted.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
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#3
No description provided.