Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/tunnel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export async function tunnelPlugin(fastify, options = {}) {
fastify.get(wsPath, { websocket: true }, async (connection, request) => {
const socket = connection.socket;

// Browser WebSockets can't set an Authorization header, so accept the
// bearer token as a ?token= query param too — mirrors the /.webrtc
// endpoint. Lets browser-based tunnel clients authenticate. (#528)
const queryToken = request.query?.token;
if (queryToken && !request.headers.authorization) {
request.headers.authorization = `Bearer ${queryToken}`;
}

// Authenticate
const { webId } = await getWebIdFromRequestAsync(request);
if (!webId) {
Expand Down