Skip to content

fix(tunnel): accept ?token= query param on /.tunnel for browser WS auth#529

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-528-tunnel-token-query
May 26, 2026
Merged

fix(tunnel): accept ?token= query param on /.tunnel for browser WS auth#529
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-528-tunnel-token-query

Conversation

@melvincarvalho
Copy link
Copy Markdown
Contributor

Closes #528.

Browser WebSockets can't set an Authorization header, so a browser-based tunnel client currently can't authenticate to /.tunnel (it gets Authentication required and the socket closes). Only Node clients work today.

This mirrors what /.webrtc already does: if a ?token= query param is present and there's no Authorization header, inject it as a Bearer token before the WebID check.

const queryToken = request.query?.token;
if (queryToken && !request.headers.authorization) {
  request.headers.authorization = `Bearer ${queryToken}`;
}

Test

  1. Get a WebID-bound JWT (POST /.pods).
  2. Browser: new WebSocket("wss://<host>/.tunnel?token=<jwt>"), send {type:"register", name:"demo"}.
  3. Expect {type:"registered", url:"/tunnel/demo/"}; https://<host>/tunnel/demo/ proxies to the client.

Notes

@melvincarvalho melvincarvalho merged commit 9b8e77e into gh-pages May 26, 2026
1 check passed
@melvincarvalho melvincarvalho deleted the issue-528-tunnel-token-query branch May 26, 2026 06:33
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.

Tunnel WS endpoint (/.tunnel) should accept a ?token= query param like /.webrtc, so browser clients can authenticate

1 participant