Skip to content

Add Ed25519 Keypair Generation to GUI login & Account Key Auth for room commands#67

Merged
alicup29 merged 8 commits intomainfrom
amick/gui-account-key
Mar 17, 2026
Merged

Add Ed25519 Keypair Generation to GUI login & Account Key Auth for room commands#67
alicup29 merged 8 commits intomainfrom
amick/gui-account-key

Conversation

@alicup29
Copy link
Copy Markdown
Collaborator

Summary

The CLI login (sleap-rtc login) generates an Ed25519 keypair and registers the public key with the signaling server for P2P data channel authentication. The GUI login (api.login()) did not — it only saved the JWT. This meant GUI users couldn't authenticate on WebRTC data channels when connecting to workers.

This PR closes that gap and makes several related improvements:

  • api.login() now generates Ed25519 keypairs — the same way the CLI does, via a shared _ensure_keypair_registered() helper
  • Room commands accept account keys — all 6 room CLI commands (list, create, info, delete, invite, join) now use _key_request() instead of requiring a JWT, so headless workers with only an account key can manage rooms
  • Default room promptroom create and room join now prompt the user to set the room as their default, simplifying worker startup (no --room flag needed)
  • WorkerSetupDialog updated — the "No Workers Available" popup now shows current account key setup instructions instead of legacy token-based ones

Changes

sleap_rtc/api.py

  • Add _ensure_keypair_registered(auth_token, device_name) helper — generates Ed25519 keypair if missing, registers public key with server, tracks registration state via public_key_registered flag
  • Wire helper into login() (non-fatal: silently retries on next login if registration fails)

sleap_rtc/auth/credentials.py

  • Add get_public_key_registered() / set_public_key_registered() for tracking server registration state
  • save_private_key_b64() now resets public_key_registered = False when a new key is saved

sleap_rtc/cli.py

  • Refactor CLI login to use shared _ensure_keypair_registered() instead of inline keypair logic
  • Switch 6 room commands from get_jwt() + requests.get/post/delete to _key_request() (account key with JWT fallback)
  • Add default room prompt after room create and room join
  • Update room create "Next steps" text to reflect account key workflow

sleap_rtc/gui/widgets.py

  • Update WorkerSetupDialog quickstart: account key setup via Dashboard or CLI, mount registration, worker command with --account-key

Tests

  • tests/auth/test_credentials.py — 6 tests for public_key_registered flag (default, roundtrip, reset on new key, preserves other creds)
  • tests/test_api.py — 7 tests for _ensure_keypair_registered() + 2 tests for login integration (calls helper, succeeds even if registration fails)

Test plan

  • All 816 tests pass (uv run pytest tests/ -v --timeout=30 -x)
  • E2E test: GUI login flow generates keypair, registers public key, widget shows correct auth state (6-phase script with Qt screenshot capture)
  • Manual: sleap-rtc login from CLI still generates keypair and registers
  • Manual: sleap-rtc room list works with account key (no JWT needed)
  • Manual: room create prompts to set default room

🤖 Generated with Claude Code

alicup29 and others added 8 commits March 16, 2026 15:12
Add get_public_key_registered() and set_public_key_registered() to track
whether the local Ed25519 public key has been registered with the signaling
server. Also update save_private_key_b64() to reset the flag when a new
key is saved, since the new key needs registration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds an idempotent helper that generates an Ed25519 keypair if none
exists locally and registers the public key with the signaling server.
Safe to call on every login; does not raise on failure so registration
is retried on the next login attempt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire the Ed25519 keypair registration helper into login() so that after
saving the JWT, the local keypair is ensured and registered with the
server. The call is non-fatal: if registration fails, login still
succeeds and registration will retry on next login.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace inline Ed25519 keypair generation and registration logic in the
CLI login command with a call to the shared _ensure_keypair_registered()
helper from sleap_rtc.api. This deduplicates the keypair management code
between the GUI API and CLI paths while preserving identical behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace direct get_jwt() + requests calls with the shared _key_request()
helper in all room subcommands (list, create, info, delete, invite, join).
This allows users with only an account key (no JWT) to use room commands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After creating or joining a room, the user is prompted to set it as
their default room. Workers use the default room when --room is not
specified, simplifying the workflow for account-key-only setups.

Also updates room create "Next steps" text to reflect current account
key workflow instead of legacy token-based instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix black formatting in cli.py (line length)
- Replace Ed25519 mention with "encrypted end-to-end" in account keys warning
- Update Workers Modal empty state to show account-key command with room ID
- Update dashboard "About" section: token references → account key commands
- Update CLI reference: token create → key create --save

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alicup29 alicup29 merged commit 786750e into main Mar 17, 2026
8 checks passed
@alicup29 alicup29 changed the title Add Ed25519 keypair generation to GUI login + account key auth for room commands Add Ed25519 Keypair Generation to GUI login & Account Key Auth for room commands Mar 17, 2026
@alicup29 alicup29 deleted the amick/gui-account-key branch March 17, 2026 17:24
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