Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Pre-Connection Authentication using HTTP Authentication Headers #29

Closed
amydevs opened this issue Oct 23, 2023 · 2 comments · Fixed by #30
Closed

Enable Pre-Connection Authentication using HTTP Authentication Headers #29

amydevs opened this issue Oct 23, 2023 · 2 comments · Fixed by #30
Assignees
Labels
development Standard development r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices

Comments

@amydevs
Copy link
Contributor

amydevs commented Oct 23, 2023

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
@amydevs amydevs added the development Standard development label Oct 23, 2023
@CMCDragonkai
Copy link
Member

I guess we would use server headers to set the session token if the connection authentication succeeded.

But this would be separate from rpc request. We also need to figure out what would happen for both RPC auth and connection auth?

I wonder if PK switches to connection auth, the RPC auth is redundant. We need to explore this architectural change.

@CMCDragonkai CMCDragonkai changed the title HTTP 1.1 Basic Authentication Support for Verify Callback Enable the Pre-Connection Authentication using HTTP Authentication Headers Oct 23, 2023
@CMCDragonkai CMCDragonkai changed the title Enable the Pre-Connection Authentication using HTTP Authentication Headers Enable Pre-Connection Authentication using HTTP Authentication Headers Oct 23, 2023
@CMCDragonkai
Copy link
Member

RPC auth and transport-level auth is 2 different levels of auth.

I think PK can swap to using transport-level auth for client service, while agent service is already MTLS and "public" anyway.

This actually means that RPC auth can be removed - and made optional, we can abstract it into js-rpc.

@CMCDragonkai CMCDragonkai added the r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices
Development

Successfully merging a pull request may close this issue.

2 participants