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

Add labels to Windows Desktop Service, add endpoint for searching them #16436

Merged
merged 12 commits into from
Sep 23, 2022

Conversation

ryanclark
Copy link
Contributor

As part of the server access flow in Discover, we generate a JoinToken which has an id (the token used to authenticate with the auth server) and an internalResourceId.

The node-install.sh script creates a Teleport config, adding ssh_service.labels['teleport.internal/resource-id'] that is equal to the internalResourceId of the token.

ssh_service:
  enabled: yes
  labels:
    teleport.internal/resource-id: 308fd103-6ee2-4180-aa0d-61ed1e9a80ae

Currently, there isn't the same functionality for windows_desktop_service.

This means that we can't poll for the WindowsDesktopService that joins once the user has started Teleport (after configuring it with the output of the configure AD script).

In order to be able to ping WindowsDesktopServices by the teleport.internal/resource-id label, I've added windows_desktop_service.labels. The configure AD script should add this property in the config it outputs to the console.

This also adds an endpoint for the frontend to be able to query them - v1/webapi/sites/:site/desktopservices.

@@ -2767,6 +2767,8 @@ func (c *Client) ListResources(ctx context.Context, req proto.ListResourcesReque
resources[i] = respResource.GetKubeService()
case types.KindWindowsDesktop:
resources[i] = respResource.GetWindowsDesktop()
case types.KindWindowsDesktopService:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would check with Lisa on this. I don't remember the details but there is some reason why ListResources isn't supported for desktops.

@@ -1958,6 +1958,8 @@ func (set RoleSet) checkAccess(r AccessCheckable, mfa AccessMFAParams, matchers
case types.KindWindowsDesktop:
getRoleLabels = types.Role.GetWindowsDesktopLabels
additionalDeniedMessage = "Confirm Windows user."
case types.KindWindowsDesktopService:
getRoleLabels = types.Role.GetWindowsDesktopLabels
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm is this right? This looks like it only applies to the actual resources, not the Teleport agents that report them.

@ryanclark ryanclark force-pushed the ryan/add-list-desktop-services branch from ac10933 to 423f0e1 Compare September 16, 2022 23:47

# Labels to attach to the Windows Desktop Service. This is used internally,
# any custom labels added won't affect the Windows hosts.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the "This is used internally" sentence means. Since this field is only used internally, when would someone want to set a custom value for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They shouldn't, but I didn't know if we allowed for config properties that are only used internally to go undocumented on the config reference page.

@ryanclark ryanclark force-pushed the ryan/add-list-desktop-services branch from 30b2c1f to d03de75 Compare September 22, 2022 17:18
@ryanclark ryanclark force-pushed the ryan/add-list-desktop-services branch 2 times, most recently from 377f7dc to 8beb245 Compare September 23, 2022 14:29
@ryanclark ryanclark force-pushed the ryan/add-list-desktop-services branch from 8beb245 to 090973d Compare September 23, 2022 19:27
This allows us to add labels to the `windows_desktop_service` section of
the config and store them inside `WindowsDesktopServiceV3`.
During the Desktop Discover flow, we need to be able to search for any
`WindowsDesktopServices` that have joined with the label generated in
the config.

This adds an endpoint that works the same as fetching `WindowsDesktop`
resources, and shares the permissions of the `desktop` resource.
@ryanclark ryanclark force-pushed the ryan/add-list-desktop-services branch from 331a6fb to 493e03c Compare September 23, 2022 21:46
@ryanclark ryanclark merged commit 9f9461d into master Sep 23, 2022
@ryanclark ryanclark deleted the ryan/add-list-desktop-services branch September 23, 2022 22:08
@github-actions
Copy link

@ryanclark See the table below for backport results.

Branch Result
branch/v10 Failed

@zmb3 zmb3 mentioned this pull request Sep 23, 2022
r0mant added a commit that referenced this pull request Sep 24, 2022
* Init an uploader service for Windows Desktop Service

This will result in multiple uploader services running if there are
other Teleport services running in the same process, but that will
be fixed by #14521.

Updates #12549

* buddy: Fix incorrect use of loop variables (#16306)

* Fix incorrect use of loop variables

This commit fixes a few occurrences of loop variables being
incorrectly used in the context of Go-routines or (most frequently)
parallel tests. To fix the issues, we create a local copy of the range
variables before the parallel tests (or Go-routine), as suggested in
the documentation of the `testing` package:

https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks

Issues were found using the `loopvarcapture` linter.

Signed-off-by: Roman Tkachenko <[email protected]>

* fix TestTraceProvider/spans_exported_with_gRPC+TLS

* run TestSSH serially

* operator: Conserve 'created_by' data in user spec

Signed-off-by: Roman Tkachenko <[email protected]>
Co-authored-by: Renato Costa <[email protected]>
Co-authored-by: Tim Ross <[email protected]>
Co-authored-by: Hugo Hervieux <[email protected]>

* Correctly set the end time when completing an upload

The upload completer would set the session end time based on the last
known event in the session, but it left the timestamp in the event's
metadata blank, which caused it to default to the time the upload was
completed.

Fixes #16555

* Speed up TestTerminalPing (#16481)

This test takes between 10-20 seconds to run, because it waits for
a websocket ping message and pings run on a 10s timer by default.

It turns out, we allow specifying the keepalive interval in the
terminal request, but due to a bug we would always overwrite that
value with what's in the cluster networking config.

Fix the bug and speed up the test by overriding the keepalive interval
to something shorter for this test.

Before:

    ➜ go test -run TestTerminalPing -race ./lib/web -count=1
    ok      github.com/gravitational/teleport/lib/web       13.122s

After:

    ➜ go test -run TestTerminalPing -race ./lib/web -count=1
    ok      github.com/gravitational/teleport/lib/web       3.394s

* Add labels to Windows Desktop Service, add endpoint for searching them (#16436)

* export GetResourcesByResourceIDs

* add WithCluserClientProvider

* Improve unit tests in CI (#16698)

- Increase timeout
- Detect whether operator, CI, Rust, or Helm tests are necessary

* Update `webassets` ref to latest `teleport-v10`

Signed-off-by: Roman Tkachenko <[email protected]>
Co-authored-by: Roman Tkachenko <[email protected]>
Co-authored-by: Renato Costa <[email protected]>
Co-authored-by: Tim Ross <[email protected]>
Co-authored-by: Hugo Hervieux <[email protected]>
Co-authored-by: Ryan Clark <[email protected]>
Co-authored-by: Nic Klaassen <[email protected]>
Co-authored-by: Ryan Clark <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants