Camera permission and review fixes (openpanel C3, C4)

C4: a device's `viewers` (superusers by default, or members) covers the
image and video messages its ports publish. Anyone else gets none of their
values on the socket, in the catalogue or a flow's state, 403 for their
history, for the frames they hold (the last 8 included) and for TURN
credentials, no bytes when asking for them, and `bye: forbidden` for a live
view. A device credential stays bounded by its dashboards. The device page
sets it in its Camera section, and a tile the viewer may not see says
"No access to this camera" and asks the camera for nothing.

C3:
- A volatile upload is held to MAX_FRAME_BYTES (4 MiB, 413 above it, read
  without extra copies), and so is a frame on a device's socket.
- A frame the engine holds in memory is written to the ring directory
  before a local worker is handed it, so load_artifact finds it.
- A socket the bus dropped events for catches up with a snapshot, demand
  included, and a device's credential is checked again per frame, cached by
  the flow store revision and its nonce, so a lost event never keeps an
  unpaired device's frames coming.
- A report is at most 64 KB once its named config_schemas are put in place.
- A device away for 60 s has its true bool messages set to false.
- Refused frames are logged by fixed keys, a frame is named after its
  message, `fluksio serve` waits 5 s for open connections, a tile with a
  stream URL creates no demand, the 8-name cap keeps the newest names.
- Every container's log rotates (json-file, 3 x 10 MB).
This commit is contained in:
Melvin Strobl
2026-10-17 09:20:04 +02:00
parent 6a98dcd23f
commit 72c1d73e96
36 changed files with 1268 additions and 152 deletions
+14 -7
View File
@@ -172,19 +172,21 @@ class LiveSessions:
person: str,
device: str,
devices: Any,
superuser: bool = False,
) -> None:
"""One signalling message from a socket.
``person`` is the id of the account holding the socket and ``device``
the device whose credential does, one of them "". Any person may watch
any device, camera privacy being deferred. A device speaks only for
the sessions it was asked to serve on this socket.
the device whose credential does, one of them "". A person watches a
device whose ``viewers`` are members, or any as a ``superuser``. A
device speaks only for the sessions it was asked to serve on this
socket.
"""
session_id = str(message.get("session") or "")
if not _SESSION.match(session_id):
return
if message.get("type") == "live" and person:
self._from_viewer(message, session_id, endpoint, person, devices)
self._from_viewer(message, session_id, endpoint, person, devices, superuser)
elif message.get("type") == "signal" and device:
self._from_device(message, session_id, endpoint, device)
@@ -197,6 +199,7 @@ class LiveSessions:
endpoint: Endpoint,
who: str,
devices: Any,
superuser: bool,
) -> None:
device_id = str(message.get("device") or "")
action = message.get("action")
@@ -205,7 +208,7 @@ class LiveSessions:
if session is not None:
# Said twice, or somebody else's id: neither gets a second one.
return
reason = self._refusal(device_id, devices)
reason = self._refusal(device_id, devices, superuser)
if reason:
endpoint.deliver(
_viewer_message(device_id, session_id, "bye", reason=reason)
@@ -289,8 +292,12 @@ class LiveSessions:
if not session.viewer.deliver(sent):
self._end(session, "overflow", tell_viewer=False)
def _refusal(self, device_id: str, devices: Any) -> str:
"""Why this device cannot serve a live view now, or ""."""
def _refusal(self, device_id: str, devices: Any, superuser: bool) -> str:
"""Why this device cannot serve this viewer a live view now, or ""."""
if not superuser:
found = devices.find(device_id) if devices is not None else None
if found is None or found.viewers != "members":
return "forbidden"
if not self._devices.get(device_id):
return "offline"
reported = devices.reported_ports(device_id) if devices is not None else None