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

Move WebConfig from lib/web/ui to api/client/webclient #11690

Merged
merged 4 commits into from
Apr 5, 2022

Conversation

ravicious
Copy link
Member

Web config was shared with the Web UI through the dynamically generated /web/config.js file available on the cluster. With the addition of Teleport Terminal (RFD 63), the Electron app needs to get a hold of this config as well.

However, unlike the Web UI which directly loads the file and injects the config this way, any communication between the cluster and Teleport Terminal is done through the tsh daemon (RFD 63). The tsh daemon needs to essentially pipe this config from /web/config.js to the gRPC response it gives to Teleport Terminal.

To achieve this, a GetWebConfig function was added to TeleportClient which loads the file and unmarshals the JS object to the WebConfig struct. Unfortunately, this breaks the build on Windows as lib/web (where WebConfig resides) includes code which is not meant to be run on Windows.

Since we need to share the web config with another frontend application, it only makes sense to move it to the webclient package. We already have types shared between the server and the client there, for example the PingResponse struct.


Another way to solve this would be to avoid parsing the JS object inside tsh daemon and instead pass the JS object to the frontend code directly, similar to how the web UI does this. In the case of Teleport Terminal however, by sharing the type between the server and the client any breaking changes will be detected during the compilation step, much earlier than if a raw JS object was passed around.

@ravicious ravicious enabled auto-merge (squash) April 4, 2022 12:34
@github-actions github-actions bot requested review from atburke and nklaassen April 4, 2022 12:34
@ravicious
Copy link
Member Author

The continuous-integration/drone/tag pipeline failed because I pushed to a tag without changing the version in Makefile, I suppose.

@ravicious ravicious force-pushed the ravicious/move-webconfig-to-webclient branch 2 times, most recently from c6e5c54 to 7591488 Compare April 4, 2022 15:10
Web config was shared with the Web UI through the dynamically generated
/web/config.js file available on the cluster. With the addition of
Teleport Terminal (RFD 63), the Electron app needs to get a hold of this
config as well.

However, unlike the Web UI which directly loads the file and injects
the config this way, any communication between the cluster and Teleport
Terminal is done through the tsh daemon (RFD 63). The tsh daemon needs
to essentially pipe this config from /web/config.js to the gRPC response
it gives to Teleport Terminal.

To achieve this, a GetWebConfig function was added to TeleportClient.
Unfortunately, this breaks the build on Windows as lib/web (where WebConfig
resides) includes code which is not meant to be compiled or run on Windows.

Since we need to share the web config with another frontend application,
it only makes sense to move it to the webclient package. We already have
types shared between the server and the client there, for example the
PingResponse struct.
@ravicious ravicious force-pushed the ravicious/move-webconfig-to-webclient branch from 7591488 to 17adf6c Compare April 4, 2022 16:21
Copy link
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

api/client/webclient/webconfig.go Outdated Show resolved Hide resolved
wadells and others added 2 commits April 4, 2022 17:55

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Nic Klaassen <[email protected]>
@wadells wadells disabled auto-merge April 5, 2022 00:57
@wadells wadells enabled auto-merge (squash) April 5, 2022 00:58

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@wadells wadells merged commit ef2ae6f into master Apr 5, 2022
@wadells wadells deleted the ravicious/move-webconfig-to-webclient branch April 5, 2022 08:47
ravicious added a commit that referenced this pull request Apr 25, 2022
* Move WebConfig from lib/web/ui to api/client/webclient

Web config was shared with the Web UI through the dynamically generated
/web/config.js file available on the cluster. With the addition of
Teleport Terminal (RFD 63), the Electron app needs to get a hold of this
config as well.

However, unlike the Web UI which directly loads the file and injects
the config this way, any communication between the cluster and Teleport
Terminal is done through the tsh daemon (RFD 63). The tsh daemon needs
to essentially pipe this config from /web/config.js to the gRPC response
it gives to Teleport Terminal.

To achieve this, a GetWebConfig function was added to TeleportClient.
Unfortunately, this breaks the build on Windows as lib/web (where WebConfig
resides) includes code which is not meant to be compiled or run on Windows.

Since we need to share the web config with another frontend application,
it only makes sense to move it to the webclient package. We already have
types shared between the server and the client there, for example the
PingResponse struct.
ravicious added a commit that referenced this pull request Apr 27, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
* teleterm (alpha)

* Add grpc-teleterm Makefile target

The grpc-tools package is needed to generate gRPC files for JavaScript.
However, at the moment it can't be installed on M1 MacBooks because of
missing prebuilt binaries for arm64. [1]

One of them, protoc, is already installed in our buildbox. We still need
to compile grpc_node_plugin from source though. This adds significant
overhead as we need to pull in cmake, build-essential and then about
300 MB of git repos from protocolbuffers/protobuf.

Initially, those Teleterm gRPC were generated within `make grpc` with other
files. M1 users who don't work on Teleterm would not be happy about incurring
that additional overhead, hence I extracted everything into separate target
and Dockerfile.

Teleterm proto files don't depend on any other proto files. Once grpc-tools
adds support for arm64, we'll be able to essentially almost revert this
commit and generate Teleterm gRPC files within `make grpc`.

[1] grpc/grpc-node#1405

* Use oneof for LoginRequest params

The login is either local or SSO but not both.

* Use db name for URI in Teleterm rather than db server host ID

The previous version of the code used GetHostId return value for the URI.
That caused problems as a single host can run multiple database servers.
This in turn resulted in stuff like Teleterm not listing all databases.

There's `Database.GetURI` function which I decided not to use, because it's
an URI on its own which might include stuff like port numbers and what not.
I wanted to avoid a situation in which the database URI creates some potential
conflicts with the Teleterm URIs.

I noticed that the Web UI code runs `DeduplicateDatabases` already and it
uses `Database.GetName` underneath, so I deemed it a good candidate to be
a part of a database URI in Teleterm.

Fixes gravitational/webapps.e#127

* Remove PAM build tag from tsh target in Makefile (#11666)

The PAM tag is not needed when building tsh. Moreover, it was causing
the push-build-windows-amd64 pipeline to fail since lib/teleterm imports
lib/srv/alpnproxy which in turn indirectly depends on lib/pam.

* Move WebConfig from lib/web/ui to api/client/webclient (#11690)

* Move WebConfig from lib/web/ui to api/client/webclient

Web config was shared with the Web UI through the dynamically generated
/web/config.js file available on the cluster. With the addition of
Teleport Terminal (RFD 63), the Electron app needs to get a hold of this
config as well.

However, unlike the Web UI which directly loads the file and injects
the config this way, any communication between the cluster and Teleport
Terminal is done through the tsh daemon (RFD 63). The tsh daemon needs
to essentially pipe this config from /web/config.js to the gRPC response
it gives to Teleport Terminal.

To achieve this, a GetWebConfig function was added to TeleportClient.
Unfortunately, this breaks the build on Windows as lib/web (where WebConfig
resides) includes code which is not meant to be compiled or run on Windows.

Since we need to share the web config with another frontend application,
it only makes sense to move it to the webclient package. We already have
types shared between the server and the client there, for example the
PingResponse struct.

Co-authored-by: Alexey Kontsevoy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants