Skip to content

Release: S-31, S-32 auth layer and editor WebSocket gate - #30

Merged
TurkerMertkan merged 2 commits into
masterfrom
develop
Nov 21, 2026
Merged

TurkerMertkan merged 2 commits into
masterfrom
develop

Conversation

@TurkerMertkan

Copy link
Copy Markdown
Collaborator

Merges S-31 (#28) and S-32 (#29) into master for deploy to the field device.

  • S-31: every HTTP write route behind the auth layer (R-2).
  • S-32: /live, /api/rows, /live/sedonaState gated by bearer/cookie + Origin (R-52).

With auth off (field default) both gates pass every request; behavior unchanged. The editor side (S-32b) is merged in sedonaWebEditor trkrDevelop.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC

TurkerMertkan and others added 2 commits November 20, 2026 21:47
Add rest::require_auth(router, auth_state) and use it for every
state-changing HTTP route on the 8085 app. Routers are split into a
public read part and a protected write part, then merged.

Inside the auth layer (new): SOX component edits (/api/sox/comp*,
/api/sox/link), PUT /file/*, PUT/DELETE /api/tags*, PUT
/api/alerts/config, POST/DELETE /api/alerts/recipients*, POST
/api/alerts/test, POST /api/cluster/query, GET /api/sim/outputs (drains
recorded writes), POST /api/sim/inject, POST /api/sim/scenario.
Inside (unchanged, now via require_auth): Haystack write ops, drivers.
Outside: all GET reads, GET /file/*, /library/, /tags, /api/cluster/status,
/api/sim/state; WebSockets /live, /api/rows and /roxwarp (need their own
auth design, R-52/S-32); the 7443 cluster listener (mTLS, R-54).

check_bearer now compares in constant time and an empty configured
token never matches.

Behavior: unchanged while auth is not configured (the field default);
check_auth passes every request through. With auth on, the routes
above return 401 without a valid bearer token.

Tests: new tests/auth_layer.rs (route inventory, 6 tests; fails on the
old code for SOX, PUT /file, tags, alerts and cluster/query). Gates:
fmt, clippy, hal OK; test 27 suites, 2878 passed, 0 failed. sim tests
(not built in CI) 11/11 with simulator-hal.

docs: OVERVIEW §3 route table updated. HARDCODED_LIMITS, research/18
and research/19 gerekmedi, çünkü: the only new constant is a test
token; the driver change is only the auth mechanism; the tags auth
wrapper does not change dynamic slot behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
…2, S-32)

Browsers cannot send an Authorization header on a WebSocket upgrade, so
/live, /api/rows and /live/sedonaState sat outside the auth layer while
carrying the same component writes as /api/sox/*.

- New check_upgrade_auth / require_upgrade_auth (rest/mod.rs), run
  before the upgrade. Accepts `Authorization: Bearer <token|session>`
  or the `sandstar_session` cookie (every same-name cookie is tried).
  With auth on, a browser Origin that is not the same host and not in
  --ws-allowed-origins gets 403; no or bad credential gets 401.
- POST /api/auth sets `sandstar_session` (HttpOnly, SameSite=Strict,
  Path=/) on SCRAM success. The JSON response is unchanged. No Secure
  flag: the device serves plain HTTP (R-14).
- /api/ws: a SCRAM-only setup no longer marks every connection as
  authenticated (was `(None, _) => true`). Origin check added; bearer
  comparisons are constant time. `?token=` still works for the legacy
  bearer only and logs a deprecation warning.
- New CLI/env --ws-allowed-origins / SANDSTAR_WS_ALLOWED_ORIGINS
  (default empty = same host only).

Routes: /live, /live/sedonaState, /api/rows now inside the upgrade auth
gate; /api/ws keeps its in-socket auth plus the new pre-auth; /api/auth
stays public; /roxwarp stays outside (R-54).

Behavior: unchanged while auth is not configured (field default). With
auth on, the Vue editor cannot connect until it logs in (S-32b).

Tests: tests/auth_layer.rs now 14 tests (401/403/101 matrix, cookie
attributes, SCRAM-only /api/ws); 5 of the new tests fail on the old
code. Gates: fmt, clippy, hal OK; test 27 suites, 2886 passed, 0 failed.

docs: OVERVIEW §3 route/auth table and HARDCODED_LIMITS (session
cookie, allowed origins) updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
@TurkerMertkan
TurkerMertkan merged commit f980db7 into master Nov 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant