Skip to content

Support Astation device authentication v2 - #15

Merged
guohai merged 8 commits into
mainfrom
feat/device-auth-v2
Jul 22, 2026
Merged

Support Astation device authentication v2#15
guohai merged 8 commits into
mainfrom
feat/device-auth-v2

Conversation

@guohai

@guohai guohai commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What changed

  • answer Astation v2 challenges with matching HMAC-SHA256 proofs for loopback, LAN, and identity-relay connections
  • require a well-formed v2 challenge and refuse bearer-session downgrade
  • bind pairing and reconnect requests to the stable atem_id, with invalid sessions falling back to pairing on the same socket
  • complete first-time remote pairing with a reusable identity-relay device session before reporting success
  • honor the local --save choice even when an older Astation always reports session-only credentials
  • bound authentication handshakes and cancel owned WebSocket tasks on failure or client drop
  • keep automatic TUI reconnects proof-only; interactive approval runs only through atem pair
  • fail pairing when the reusable device session cannot be persisted securely
  • persist session files as 0600 under a 0700 config directory and refuse symlink-backed secret files
  • automatically learn and reload the authenticated Astation identity for live relay fallback
  • replace stale session, connection-priority, universal-session, and relay documents with the v2 contract and current security status

Practical coverage

  • shared Swift/Rust HMAC protocol vector
  • local bootstrap acceptance at 0600 and rejection at 0644
  • private session write, permission migration, ownership, and symlink refusal
  • real loopback WebSocket pairing/denial path
  • downgrade rejection without sending credentials
  • bounded authentication when a challenged peer becomes silent
  • proof-only background reconnect with no pairing message or terminal output
  • pairing failure propagation when secure session persistence is unavailable
  • existing identity, session, serialization, and connection coverage

Verification

  • cargo test -- --test-threads=1 --format terse (699 passed)
  • git diff --check

The suite is run serially because four existing agent_visualize tests share ~/.agent/diagrams and can race under the default parallel runner. Repository-wide cargo fmt --check also has pre-existing formatting drift outside this change.

Coordinated rollout

Requires Agora-Build/Astation#13. Merge both repositories before releasing either client; Astation v2 intentionally rejects legacy session-ID-only authentication.

Remote first-time pairing now has two explicit approvals: the short relay-room code connects the peers, then the 8-digit device code authorizes and stores the durable identity-relay session.

Security status

Direct LAN remains plaintext ws://. Proofs improve device authentication but do not encrypt initial pairing or application traffic. WSS certificate pinning is still required before treating direct LAN as production-ready.

Generated with SMT smt@agora.build

Generate matching HMAC proofs for loopback, LAN, and relay connections, persist the learned relay target, secure session storage, add permission tests, and replace stale connection documentation.

🤖 Built with SMT <smt@agora.build>
guohai added 7 commits July 22, 2026 00:01
Secure existing session files before reading, refuse symbolic links and wrong ownership, and cover the v2 pairing path with a real WebSocket test.\n\n🤖 Built with SMT <smt@agora.build>
🤖 Built with SMT <smt@agora.build>
🤖 Built with SMT <smt@agora.build>
🤖 Built with SMT <smt@agora.build>
🤖 Built with SMT <smt@agora.build>
🤖 Built with SMT <smt@agora.build>
🤖 Built with SMT <smt@agora.build>
@guohai

guohai commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Manual review completed at exact head d45e972651784cdf19c78bf4255c5c279bc232a2.

Resolved during review:

  • bounded all post-challenge authentication waits and completed reusable remote session pairing;
  • refreshed learned relay identity in the running TUI;
  • aborted failed authentication transports and kept background reconnects proof-only;
  • made first-time credential persistence fatal while keeping existing authenticated reconnects alive when only activity metadata cannot be refreshed;
  • isolated session and relay-code test state from the developer config, while preserving direct-to-relay identity learning.

Validation:

  • cargo test -- --test-threads=1 --format terse: 700 passed, 0 failed;
  • all 6 practical WebSocket authentication tests passed;
  • git diff --check passed;
  • final exact-commit Codex review: no actionable regressions.

No critical or high-severity findings remain. Repository-wide formatting drift and the documented LAN-WSS / relay-owner-auth production blockers predate this final follow-up and remain explicitly documented. GitHub Claude/Codex jobs are currently skipped by their workflow conditions; local Claude review was unavailable because that CLI is not logged in.

@guohai
guohai merged commit 7b42d54 into main Jul 22, 2026
3 checks passed
@guohai
guohai deleted the feat/device-auth-v2 branch July 22, 2026 17:28
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