Skip to content

refactor(web): secure Pico websocket access behind launcher auth - #2545

Merged
imguoguo merged 3 commits into
sipeed:mainfrom
wj-xiao:refactor/pico-channel-token
Apr 20, 2026
Merged

refactor(web): secure Pico websocket access behind launcher auth#2545
imguoguo merged 3 commits into
sipeed:mainfrom
wj-xiao:refactor/pico-channel-token

Conversation

@wj-xiao

@wj-xiao wj-xiao commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

📝 Description

This change hardens the Pico launcher integration so the browser no longer receives the raw Pico WebSocket token.

It adds a non-secret /api/pico/info endpoint for launcher UI metadata, proxies /pico/ws through the launcher with dashboard auth and same-origin checks, and injects the upstream Pico WebSocket subprotocol server-side. The frontend chat flow is updated to connect to the launcher proxy directly, and the related docs/tests are refreshed.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

N/A

📚 Technical Context (Skip for Docs)

  • Reference URL: N/A
  • Reasoning: The launcher UI previously exposed the raw Pico WebSocket token to the browser and relied on the client to replay it in the WebSocket subprotocol. This change keeps the token server-side, returns only non-secret Pico metadata to the frontend, and requires launcher auth plus same-origin validation before proxying /pico/ws upstream.

🧪 Test Environment

  • Hardware: Apple Silicon MacBook Pro
  • OS: macOS 26.4.1
  • Model/Provider: Not exercised (launcher dashboard and Pico gateway path only)
  • Channels: Pico

📸 Evidence (Optional)

Click to view Logs/Screenshots
go test ./web/backend/api ./web/backend/middleware
ok  	github.com/sipeed/picoclaw/web/backend/api	(cached)
ok  	github.com/sipeed/picoclaw/web/backend/middleware	(cached)

pnpm lint
pnpm build

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

@CLAassistant

CLAassistant commented Apr 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@wj-xiao
wj-xiao marked this pull request as ready for review April 16, 2026 08:57
@sipeed-bot sipeed-bot Bot added type: bug Something isn't working domain: channel go Pull requests that update go code labels Apr 16, 2026
wj-xiao added 3 commits April 20, 2026 10:11
- stop exposing the raw Pico token to the frontend
- add /api/pico/info for non-secret Pico connection metadata
- proxy /pico/ws through the launcher with same-origin and dashboard auth checks
- inject the upstream Pico websocket protocol server-side
- update frontend chat connection flow and Vite websocket proxy path
- refresh related docs and tests
- read client scheme from X-Forwarded-Proto and RFC 7239 Forwarded
- derive client-visible ports from forwarded host information
- add coverage for HTTPS origins without explicit ports
- verify behavior when proxies omit forwarded protocol headers
- remove request-origin seeding from `EnsurePicoChannel`
- keep `allow_origins` empty by default for auto-configured Pico channels
- relax launcher Pico WebSocket proxy origin validation
- update Pico backend tests for the new setup and proxy behavior
@wj-xiao
wj-xiao force-pushed the refactor/pico-channel-token branch from 2906b7a to f8190f0 Compare April 20, 2026 02:12
@imguoguo
imguoguo merged commit 74c98a5 into sipeed:main Apr 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: channel go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants