Skip to content

Commit

Permalink
Include an optional screen size in the WindowsDesktop spec (#38307)
Browse files Browse the repository at this point in the history
By default this should remain unspecified, which preserves the
behavior we have today (Teleport uses the size of the user's
browser window).

These new fields allow cluster administrators to configure desktops
in such a way that they always use a particular screen size, ignoring
the size passed from the browser client. This is necessary to
accommodate some applications which require a very specific screen resolution in
order to render correctly.
  • Loading branch information
zmb3 authored Feb 27, 2024
1 parent 4c8cd9a commit 1437d02
Show file tree
Hide file tree
Showing 7 changed files with 2,007 additions and 1,704 deletions.
9 changes: 9 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4995,6 +4995,15 @@ message WindowsDesktopSpecV3 {
// NonAD marks this desktop as a standalone host that is
// not joined to an Active Directory domain.
bool NonAD = 4 [(gogoproto.jsontag) = "non_ad"];
// ScreenSize specifies the size of the screen to use for sessions
// on this host. In most cases this should be unspecified, in which
// case Teleport will fill the browser window.
Resolution ScreenSize = 5 [(gogoproto.jsontag) = "screen_size,omitempty"];
}

message Resolution {
uint32 Width = 1 [(gogoproto.jsontag) = "width,omitempty"];
uint32 Height = 2 [(gogoproto.jsontag) = "height,omitempty"];
}

// RegisterUsingTokenRequest is a request to register with the auth server using
Expand Down
24 changes: 24 additions & 0 deletions api/types/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import (
"github.com/gravitational/teleport/api/utils"
)

const (
MaxRDPScreenWidth = 8192
MaxRDPScreenHeight = 8192
)

// WindowsDesktopService represents a Windows desktop service instance.
type WindowsDesktopService interface {
// ResourceWithLabels provides common resource methods.
Expand Down Expand Up @@ -132,6 +137,10 @@ type WindowsDesktop interface {
// NonAD checks whether this is a standalone host that
// is not joined to an Active Directory domain.
NonAD() bool
// GetScreenSize returns the desired size of the screen to use for sessions
// to this host. Returns (0, 0) if no screen size is set, which means to
// use the size passed by the client over TDP.
GetScreenSize() (width, height uint32)
// Copy returns a copy of this windows desktop
Copy() *WindowsDesktopV3
// CloneResource returns a copy of the WindowDesktop as a ResourceWithLabels
Expand Down Expand Up @@ -179,9 +188,24 @@ func (d *WindowsDesktopV3) CheckAndSetDefaults() error {
if err := d.ResourceHeader.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}

if d.Spec.ScreenSize != nil {
if d.Spec.ScreenSize.Width > MaxRDPScreenWidth || d.Spec.ScreenSize.Height > MaxRDPScreenHeight {
return trace.BadParameter("invalid screen size %dx%d (maximum %dx%d)",
d.Spec.ScreenSize.Width, d.Spec.ScreenSize.Height, MaxRDPScreenWidth, MaxRDPScreenHeight)
}
}

return nil
}

func (d *WindowsDesktopV3) GetScreenSize() (width, height uint32) {
if d.Spec.ScreenSize == nil {
return 0, 0
}
return d.Spec.ScreenSize.Width, d.Spec.ScreenSize.Height
}

// NonAD checks whether host is part of Active Directory
func (d *WindowsDesktopV3) NonAD() bool {
return d.Spec.NonAD
Expand Down
Loading

0 comments on commit 1437d02

Please sign in to comment.