Skip to content

[Codex] fix(auth): require authentication for datapoint value reads and websocket connections#553

Open
Micsi wants to merge 7 commits into
abeggled:mainfrom
Micsi:codex/fix-authorization-bypass-for-datapoint-reads
Open

[Codex] fix(auth): require authentication for datapoint value reads and websocket connections#553
Micsi wants to merge 7 commits into
abeggled:mainfrom
Micsi:codex/fix-authorization-bypass-for-datapoint-reads

Conversation

@Micsi
Copy link
Copy Markdown
Collaborator

@Micsi Micsi commented May 26, 2026

Motivation

  • Close an authorization bypass that allowed anonymous clients to read datapoint current values and receive global live updates over WebSocket.
  • Ensure anonymous users cannot enumerate or observe telemetry without an explicit public-page ACL check in place.

Description

  • Require authenticated context on the current-value endpoint by changing the dependency to get_current_user in obs/api/v1/datapoints.py for GET /{dp_id}/value.
  • Require a valid token at WebSocket handshake in obs/api/v1/websocket.py by rejecting connections without a token with 4001 Authentication required and continuing to reject invalid tokens with 4001 Invalid token.
  • Changes are limited to obs/api/v1/datapoints.py and obs/api/v1/websocket.py and are intentionally minimal to restore prior access controls.

Testing

  • Ran pytest -q obs/api/v1/test_datapoints.py obs/api/v1/test_websocket.py which failed because those targeted test files are not present in this repo layout (no tests collected).
  • Ran pytest -q which aborted collection due to a missing test dependency (ModuleNotFoundError: No module named 'pytest_asyncio'), so full test suite execution could not be completed in this environment.
  • No additional automated test failures were introduced by the code edits performed here based on available local checks.

Codex Task

@Micsi
Copy link
Copy Markdown
Collaborator Author

Micsi commented May 26, 2026

Sync-Update aus dem Fork-PR: Micsi#59

In diesem Update wurden folgende Punkte auf den Upstream-PR synchronisiert:

  • WebSocket-Reconnect bei geändertem Seitenkontext (page_id / session_token) im Frontend.
  • WebSocket-Auth ohne JWT in Query-Parametern (Token-Transport über Subprotocol) für Frontend und GUI.
  • Fallback-Verhalten bei ungültigem Token: bei vorhandenem Seitenkontext wird anonym/page-scoped weitergeprüft statt sofort hart abgelehnt.
  • Erweiterte page-scoped Allowlist um WidgetRef-Ziel-Widgets inkl. deren Datapoints.
  • Test-Kompatibilitätsfix für WebSocket-Testdoubles (accept(subprotocol=...) Fallback).
  • Präzisierung in RELEASENOTES.md zur Security/WS-Korrektur.

Enthaltene neue Commits in diesem Stand:

  • 93daaf1 fix(ws): handle context reconnect, token transport, and widgetref allowlist
  • c5b90de fix(ws): keep connect compatible with websocket test doubles

Aktueller PR-Stand:

  • Assignee: @Micsi
  • Review angefragt bei: @abeggled

@Micsi
Copy link
Copy Markdown
Collaborator Author

Micsi commented May 26, 2026

Nachtrag zum letzten Sync aus dem Fork-PR Micsi#59:

Auf Basis eines neuen Reviews wurde noch ein weiterer Security-Fix nachgezogen:

  • WidgetRef-Datapoints werden in der anonymen WS-Allowlist nur noch dann expandiert, wenn die referenzierte Quellseite für die aktuelle anonyme Session tatsächlich zugreifbar ist (public/readonly erlaubt, protected nur mit gültigem Session-Token, user nicht erlaubt).

Zusätzlicher Commit:

  • 7c43de5 fix(ws): enforce widgetref access in anonymous allowlist expansion

Der Stand ist auf Fork-PR #59 und Upstream-PR #553 identisch (gleicher Head-SHA).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Security Security-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant