Skip to content

feat: LAN mode with rotating single-use 30s invite tokens#32

Merged
Blaise1030 merged 1 commit into
mainfrom
feat/lan-rotating-invite-token
Jun 17, 2026
Merged

feat: LAN mode with rotating single-use 30s invite tokens#32
Blaise1030 merged 1 commit into
mainfrom
feat/lan-rotating-invite-token

Conversation

@Blaise1030

Copy link
Copy Markdown
Owner

This PR implements secure LAN access using a rotating single-use invite token (30s lifetime).

Changes

Rotating Invite Tokens

  • New logic in lan.Manager generates a cryptographically secure random token that rotates every 30 seconds.
  • Token is single-use: immediately invalidated on successful /auth/local consumption.
  • Old tokens are void after their 30s window.

QR Code + Invite Flow

  • QR in Settings → Network now encodes http://LAN-IP:port/?invite=TOKEN
  • Frontend detects ?invite (or ?token) param on load, passes it to ensureLocalAuth.
  • URL is cleaned after successful validation (history.replaceState).
  • Live polling refreshes the invite URL/QR while on the settings page.

Auth Hardening for LAN

  • /auth/local now accepts optional { \"token\": \"...\" } body.
  • With valid token → authenticated (and token consumed).
  • Without token → only strict loopback (127.0.0.1 etc.) is allowed.
  • Private LAN IPs no longer auto-authenticate; an invite token is required.

LAN Binding

  • --lan / --expose flag binds to 0.0.0.0 and advertises discovered private IPs.
  • NetworkSettings response now includes lanMode, lanUrls, lanIps, and inviteUrl.

Mobile UI Improvements

  • On ≤ 768px: sidebar defaults collapsed (uses existing Sheet).
  • Split aux panels (explorer/git) are hidden in favor of full-page router views.
  • Uses h-dvh and responsive logic for better small-screen experience.

How to Test

pnpm build
cd apps/server-go
go run ./cmd/workbench-cli --lan --http -y
  1. Open app → Settings → Network → observe rotating invite link + QR.
  2. Copy/scan the invite URL from another device or incognito tab on same LAN.
  3. Verify auth succeeds and token is one-time use.

Desktop localhost flow remains unchanged for convenience.

Related

  • Addresses original request for LAN mode + mobile friendliness.
  • Invite token mechanism requested to move beyond pure IP-based trust.

…s (30s)

- Tokens rotate every 30 seconds and are immediately invalidated after use
- QR code now encodes invite URL with current token (?invite=...)
- Non-loopback LAN clients must present a valid unconsumed token to authenticate
- Desktop localhost access remains tokenless for convenience
- Settings > Network now shows current invite link + live-updating QR
- Frontend auto-detects token from URL, sends it on auth, cleans URL after use
- Polling keeps the invite QR fresh while viewing settings

Also includes earlier LAN binding (0.0.0.0) and mobile UI responsiveness improvements (sidebar collapse, aux panels via page layout on small screens).

Tested: pnpm build succeeds, Go builds and basic flows verified.
@Blaise1030 Blaise1030 merged commit 813d324 into main Jun 17, 2026
13 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