From 700bdada2a2c25f651a222319379bbcfb56fca57 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Thu, 20 Aug 2026 13:40:46 +0000 Subject: [PATCH] Make Linux desktop requestable (#397) Export-Source-Commit: 696335b5bef921b09d1790256dac2f0fbff34fd0 --- api/client/client.go | 2 ++ api/types/constants.go | 1 + lib/auth/auth_with_roles.go | 1 + lib/cache/cache.go | 18 ++++++++++++++++++ lib/services/local/presence.go | 14 ++++++++++++++ .../components/AccessRequests/Shared/utils.ts | 1 + 6 files changed, 37 insertions(+) diff --git a/api/client/client.go b/api/client/client.go index 804a1de7726..78319c05c51 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -4776,6 +4776,8 @@ func (c *Client) ListResources(ctx context.Context, req proto.ListResourcesReque resources[i] = respResource.GetAppServer() case types.KindNode: resources[i] = respResource.GetNode() + case types.KindLinuxDesktop: + resources[i] = proto.UnpackLinuxDesktop(respResource.GetLinuxDesktop()) case types.KindWindowsDesktop: resources[i] = respResource.GetWindowsDesktop() case types.KindWindowsDesktopService: diff --git a/api/types/constants.go b/api/types/constants.go index d857ec2489c..cdefbde5c3a 100644 --- a/api/types/constants.go +++ b/api/types/constants.go @@ -1614,6 +1614,7 @@ var RequestableResourceKinds = []string{ KindDatabase, KindApp, KindWindowsDesktop, + KindLinuxDesktop, KindUserGroup, KindSAMLIdPServiceProvider, KindIdentityCenterAccount, diff --git a/lib/auth/auth_with_roles.go b/lib/auth/auth_with_roles.go index 73c073db150..344a3ed2e3a 100644 --- a/lib/auth/auth_with_roles.go +++ b/lib/auth/auth_with_roles.go @@ -2518,6 +2518,7 @@ func (a *ServerWithRoles) ListResources(ctx context.Context, req proto.ListResou types.KindAppServer, types.KindKubeServer, types.KindWindowsDesktop, + types.KindLinuxDesktop, types.KindWindowsDesktopService, types.KindUserGroup, types.KindSAMLIdPServiceProvider, diff --git a/lib/cache/cache.go b/lib/cache/cache.go index d50b2a0f307..e82b2e7a9a0 100644 --- a/lib/cache/cache.go +++ b/lib/cache/cache.go @@ -39,6 +39,7 @@ import ( authproto "github.com/gravitational/teleport/api/client/proto" apidefaults "github.com/gravitational/teleport/api/defaults" identitycenterv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/identitycenter/v1" + linuxdesktopv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/linuxdesktop/v1" scopesv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/scopes/v1" "github.com/gravitational/teleport/api/internalutils/stream" apitracing "github.com/gravitational/teleport/api/observability/tracing" @@ -1813,6 +1814,23 @@ func (c *Cache) listResources(ctx context.Context, req authproto.ListResourcesRe }, ) return resp, trace.Wrap(err) + case types.KindLinuxDesktop: + resp, err := buildListResourcesResponse( + func(yield func(types.ResourceWithLabels) bool) { + for desktop := range c.collections.linuxDesktops.store.resources(linuxDesktopNameIndex, req.StartKey, "") { + if !yield(types.Resource153ToResourceWithLabels(desktop)) { + return + } + } + }, + limit, + filter, + func(r types.ResourceWithLabels) types.ResourceWithLabels { + unwrapper := r.(types.Resource153UnwrapperT[*linuxdesktopv1.LinuxDesktop]) + return types.Resource153ToResourceWithLabels(proto.CloneOf(unwrapper.UnwrapT())) + }, + ) + return resp, trace.Wrap(err) case types.KindKubeServer: resp, err := buildListResourcesResponse( c.collections.kubeServers.store.resources(kubeServerNameIndex, req.StartKey, ""), diff --git a/lib/services/local/presence.go b/lib/services/local/presence.go index 782aa402d72..9ce2fdc1e70 100644 --- a/lib/services/local/presence.go +++ b/lib/services/local/presence.go @@ -1628,6 +1628,9 @@ func (s *PresenceService) listResources(ctx context.Context, req proto.ListResou case types.KindWindowsDesktop: keyPrefix = []string{windowsDesktopsPrefix} unmarshalItemFunc = backendItemToWindowsDesktop + case types.KindLinuxDesktop: + keyPrefix = []string{linuxDesktopKey} + unmarshalItemFunc = backendItemToLinuxDesktop case types.KindKubeServer: return s.listKubeServers(ctx, req) case types.KindUserGroup: @@ -2119,6 +2122,17 @@ func backendItemToWindowsDesktop(item backend.Item) (types.ResourceWithLabels, e ) } +// backendItemToLinuxDesktop unmarshals `backend.Item` into a +// `LinuxDesktops`, returning it as a `types.ResourceWithLabels`. +func backendItemToLinuxDesktop(item backend.Item) (types.ResourceWithLabels, error) { + linuxDesktop, err := services.UnmarshalLinuxDesktop( + item.Value, + services.WithExpires(item.Expires), + services.WithRevision(item.Revision), + ) + return types.Resource153ToResourceWithLabels(linuxDesktop), err +} + // backendItemToWindowsDesktopService unmarshals `backend.Item` into a // `types.WindowsDesktopService`, returning it as a `types.ResourceWithLabels`. func backendItemToWindowsDesktopService(item backend.Item) (types.ResourceWithLabels, error) { diff --git a/web/packages/shared/components/AccessRequests/Shared/utils.ts b/web/packages/shared/components/AccessRequests/Shared/utils.ts index d25648a73ea..9608cefd0a6 100644 --- a/web/packages/shared/components/AccessRequests/Shared/utils.ts +++ b/web/packages/shared/components/AccessRequests/Shared/utils.ts @@ -47,6 +47,7 @@ export function getNumAddedResources(addedResources: ResourceMap) { Object.keys(addedResources.kube_cluster).length + Object.keys(addedResources.user_group).length + Object.keys(addedResources.windows_desktop).length + + Object.keys(addedResources.linux_desktop).length + Object.keys(addedResources.saml_idp_service_provider).length + Object.keys(addedResources.namespace).length + Object.keys(addedResources.aws_ic_account_assignment).length