Repository navigation
Release: S-31, S-32 auth layer and editor WebSocket gate - #30
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merges S-31 (#28) and S-32 (#29) into master for deploy to the field device.
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