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

Converts AuthenticatedWebsocket into drop-in replacement for WebSocket #37699

Merged

Conversation

ibeckermayer
Copy link
Contributor

that automatically goes through Teleport's custom authentication process before facilitating any caller-defined communication.

This also reverts previous-WebSocket users to their original state (sans the code for passing the bearer token in the query string), swapping in AuthenticatedWebsocket in place of WebSocket.

…cket`

that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebsocket` in place of `WebSocket`.
@ibeckermayer ibeckermayer added the no-changelog Indicates that a PR does not require a changelog entry label Feb 2, 2024
@ibeckermayer ibeckermayer merged commit ecd06eb into lxea/websocket-bearer-token Feb 5, 2024
30 of 32 checks passed
@ibeckermayer ibeckermayer deleted the isaiah/websocket-bearer-token branch February 5, 2024 18:43
lxea pushed a commit that referenced this pull request Feb 7, 2024
…cket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.
github-merge-queue bot pushed a commit that referenced this pull request Feb 8, 2024
…eter (#37520)

* Read the bearer token over WS endpoints

use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

* update connectToHost

* linter

* read errors from websocket

* missing /ws on ttyWsAddr and fix wrong onmessage

* fix race in test

* lint

* skip TestTerminal as it takes 11 seconds to run

* dont skip the test

* resolve apiserver comments

* Add an AuthenticatedWebSocket class

* convert other clients to use AuthenticatedWebSocket

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

* Create a single authnWsUpgrader with a comment justifying why we turn off CORS

* recieving to receiving

* resolve comments

---------

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
github-actions bot pushed a commit that referenced this pull request Feb 8, 2024
…cket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.
lxea added a commit that referenced this pull request Feb 8, 2024
use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

update connectToHost

linter

read errors from websocket

missing /ws on ttyWsAddr and fix wrong onmessage

fix race in test

lint

skip TestTerminal as it takes 11 seconds to run

dont skip the test

resolve apiserver comments

Add an AuthenticatedWebSocket class

convert other clients to use AuthenticatedWebSocket

Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

Create a single authnWsUpgrader with a comment justifying why we turn off CORS

recieving to receiving

resolve comments
lxea added a commit that referenced this pull request Feb 8, 2024
use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

update connectToHost

linter

read errors from websocket

missing /ws on ttyWsAddr and fix wrong onmessage

fix race in test

lint

skip TestTerminal as it takes 11 seconds to run

dont skip the test

resolve apiserver comments

Add an AuthenticatedWebSocket class

convert other clients to use AuthenticatedWebSocket

Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

Create a single authnWsUpgrader with a comment justifying why we turn off CORS

recieving to receiving

resolve comments
lxea added a commit that referenced this pull request Feb 8, 2024
use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

update connectToHost

linter

read errors from websocket

missing /ws on ttyWsAddr and fix wrong onmessage

fix race in test

lint

skip TestTerminal as it takes 11 seconds to run

dont skip the test

resolve apiserver comments

Add an AuthenticatedWebSocket class

convert other clients to use AuthenticatedWebSocket

Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

Create a single authnWsUpgrader with a comment justifying why we turn off CORS

recieving to receiving

resolve comments
ibeckermayer added a commit that referenced this pull request Feb 9, 2024
…eter (#37520)

* Read the bearer token over WS endpoints

use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

* update connectToHost

* linter

* read errors from websocket

* missing /ws on ttyWsAddr and fix wrong onmessage

* fix race in test

* lint

* skip TestTerminal as it takes 11 seconds to run

* dont skip the test

* resolve apiserver comments

* Add an AuthenticatedWebSocket class

* convert other clients to use AuthenticatedWebSocket

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

* Create a single authnWsUpgrader with a comment justifying why we turn off CORS

* recieving to receiving

* resolve comments

---------

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2024
* Read the bearer token over websocket endpoints instead of query parameter (#37520)

* Read the bearer token over WS endpoints

use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

* update connectToHost

* linter

* read errors from websocket

* missing /ws on ttyWsAddr and fix wrong onmessage

* fix race in test

* lint

* skip TestTerminal as it takes 11 seconds to run

* dont skip the test

* resolve apiserver comments

* Add an AuthenticatedWebSocket class

* convert other clients to use AuthenticatedWebSocket

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

* Create a single authnWsUpgrader with a comment justifying why we turn off CORS

* recieving to receiving

* resolve comments

---------

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>

* Updates `desktopPlaybackHandle` to new ws paradigm (#37981)

* Updates `desktopPlaybackHandle` to new ws paradigm

This was mistakenly left out of #37520.
This commit also refactors `WithClusterAuthWebSocket` slightly for easier
comprehension, and updates the vite config to facilitate the new websocket
endpoints in development mode.

* Update lib/web/apiserver.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

---------

Co-authored-by: Alex McGrath <alex.mcgrath@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
ibeckermayer added a commit that referenced this pull request Feb 10, 2024
…eter (#37520)

* Read the bearer token over WS endpoints

use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

* update connectToHost

* linter

* read errors from websocket

* missing /ws on ttyWsAddr and fix wrong onmessage

* fix race in test

* lint

* skip TestTerminal as it takes 11 seconds to run

* dont skip the test

* resolve apiserver comments

* Add an AuthenticatedWebSocket class

* convert other clients to use AuthenticatedWebSocket

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

* Create a single authnWsUpgrader with a comment justifying why we turn off CORS

* recieving to receiving

* resolve comments

---------

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
lxea added a commit that referenced this pull request Feb 13, 2024
…eter (#37520)

* Read the bearer token over WS endpoints

use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

* update connectToHost

* linter

* read errors from websocket

* missing /ws on ttyWsAddr and fix wrong onmessage

* fix race in test

* lint

* skip TestTerminal as it takes 11 seconds to run

* dont skip the test

* resolve apiserver comments

* Add an AuthenticatedWebSocket class

* convert other clients to use AuthenticatedWebSocket

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

* Create a single authnWsUpgrader with a comment justifying why we turn off CORS

* recieving to receiving

* resolve comments

---------

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2024
* Introduce a new streaming player API (#31754)

This new API can be used to play back sessions of any type.
The player accepts a session ID and a streamer, and provides
the caller with an API for playback controls (speed, play/pause,
seek, etc) as well as a channel that receives events with the
proper timing delay applied.

The design for this change is discussed in RFD 91.

Updates #10578
Updates #10579
Updates gravitational/teleport-private#665
Updates gravitational/teleport-private#1024

* Convert the desktop sesssion player to the new player API (#34070)

This makes a few changes to the player API to ensure that errors
are correctly propagated.

* Switch desktop playback to gorilla/websocket (#36405)

We use gorilla/websocket throughout the app, but desktop playback
leveraged x/net/websocket instead. Convert to gorilla so that we
are consistent and use the same library everywhere websockets are
used.

* Read the bearer token over websocket endpoints instead of query parameter (#37520)

* Read the bearer token over WS endpoints

use the request context, not session

Dont pass websocket by context

lint

resolve some comments

Add TestWSAuthenticateRequest

Close ws in handler

deprecation notices, doc

resolve comments

resolve comments

give a longer read/write deadline

dont set write deadline, ws endpoints never did before and it breaks things

convert frontend to use ws access token

Resolove comments, move to using an explicit state

fix ci

reset read deadline

prettier

* update connectToHost

* linter

* read errors from websocket

* missing /ws on ttyWsAddr and fix wrong onmessage

* fix race in test

* lint

* skip TestTerminal as it takes 11 seconds to run

* dont skip the test

* resolve apiserver comments

* Add an AuthenticatedWebSocket class

* convert other clients to use AuthenticatedWebSocket

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket` (#37699)

* Converts `AuthenticatedWebSocket` into drop-in replacement for `WebSocket`
that automatically goes through Teleport's custom authentication process
before facilitating any caller-defined communication.

This also reverts previous-`WebSocket` users to their original state
(sans the code for passing the bearer token in the query string),
swapping in `AuthenticatedWebSocket` in place of `WebSocket`.

* Create a single authnWsUpgrader with a comment justifying why we turn off CORS

* recieving to receiving

* resolve comments

---------

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>

* Updates `desktopPlaybackHandle` to new ws paradigm (#37981)

* Updates `desktopPlaybackHandle` to new ws paradigm

This was mistakenly left out of #37520.
This commit also refactors `WithClusterAuthWebSocket` slightly for easier
comprehension, and updates the vite config to facilitate the new websocket
endpoints in development mode.

* Update lib/web/apiserver.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* polishing off merge errors

* fixes Path in makeTerminal to reflect new /ws suffix

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Co-authored-by: Alex McGrath <alex.mcgrath@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/md ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants