fix: take auth header from initial request too
This commit is contained in:
parent
d7a1b5852c
commit
5548fe2bb7
@ -1011,7 +1011,7 @@ export abstract class Server {
|
||||
await Promise.all(deletes);
|
||||
|
||||
debug(
|
||||
'updating storage manifest to version=%j for=%j',
|
||||
'updating storage manifest to version=%d for=%j',
|
||||
manifest.version,
|
||||
device.debugId,
|
||||
);
|
||||
|
||||
@ -1015,8 +1015,10 @@ export class Connection extends Service {
|
||||
}
|
||||
|
||||
if (path === '/v1/websocket/') {
|
||||
await this.handleAuthHeaders(this.request.headers);
|
||||
return;
|
||||
}
|
||||
|
||||
debug('websocket connection has unexpected URL %s', url);
|
||||
}
|
||||
|
||||
@ -1080,11 +1082,21 @@ export class Connection extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.handleAuthHeaders(headers);
|
||||
}
|
||||
|
||||
private async handleAuthHeaders(
|
||||
headers: Record<string, string | Array<string> | undefined>,
|
||||
) {
|
||||
const authHeaders = headers.authorization;
|
||||
if (!authHeaders) {
|
||||
if (authHeaders === undefined) {
|
||||
debug('Websocket connection does not include Authorization header');
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(authHeaders)) {
|
||||
debug('Websocket connection includes multiple Authorization headers');
|
||||
return;
|
||||
}
|
||||
const { error, username, password } = parseAuthHeader(authHeaders, {
|
||||
allowEmptyPassword: true,
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user