Skip to content

Enable Pre-Connection Authentication using HTTP Authentication Headers #29

Closed
@amydevs

Description

@amydevs

Specification

It should also be possible for TLS Verification to be done via the HTTP 1.1 Basic Authentication (via the Authentication header).

To achieve this, the VerifyCallback should be expanded to also expose the headers of the incoming request:

type TLSVerifyCallback = (
  certs: Array<Uint8Array>,
  ca: Array<Uint8Array>,
  headers: IncomingHttpHeaders
) => PromiseLike<void>;

As the callers of the TLSVerifyCallbacks always have context of the IncomingMessage http request, we can pass the IncomingMessage.headers into the verifyCallback as the third param.

There will also need to be some API in the WebSocketConfig to be able to set headers for outgoing messages.

ws provides different APIs for setting headers for clients and servers:

  • servers use the headers event on WebSocketServer to modify the headers before they are sent
  • clients use the finishRequest callback to customize headers on the OutgoingMessage before it is sent

Additional context

Tasks

  1. Expand TLSVerifyCallback to support passing of headers
  2. Allow user to provide headers in WebSocketConfig
  3. Pass provided headers to ws library

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions