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

[v9] Add hostlogin to proxy config for windows desktop #12781

Merged
merged 2 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/auth/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func (a *Middleware) WrapContextWithUser(ctx context.Context, conn *tls.Conn) (c
// Perform the handshake if it hasn't been already. Before the handshake we
// won't have client certs available.
if !conn.ConnectionState().HandshakeComplete {
if err := conn.Handshake(); err != nil {
if err := conn.HandshakeContext(ctx); err != nil {
return nil, trace.ConvertSystemError(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/tlsdial.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TLSDial(ctx context.Context, dial DialWithContextFunc, network, addr string
conn := tls.Client(plainConn, tlsConfig)
errC := make(chan error, 1)
go func() {
err := conn.Handshake()
err := conn.HandshakeContext(ctx)
errC <- err
}()

Expand Down
12 changes: 9 additions & 3 deletions lib/web/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (h *Handler) createDesktopConnection(
WriteBufferSize: 1024,
}

pc, err := proxyClient(r.Context(), ctx, h.ProxyHostPort())
pc, err := proxyClient(r.Context(), ctx, h.ProxyHostPort(), username)
if err != nil {
return trace.Wrap(err)
}
Expand All @@ -164,7 +164,7 @@ func (h *Handler) createDesktopConnection(
}
serviceConnTLS := tls.Client(serviceConn, tlsConfig)

if err := serviceConnTLS.Handshake(); err != nil {
if err := serviceConnTLS.HandshakeContext(r.Context()); err != nil {
return trace.NewAggregate(err, sendTDPError(ws, err))
}
log.Debug("Connected to windows_desktop_service")
Expand All @@ -185,11 +185,17 @@ func (h *Handler) createDesktopConnection(
return nil
}

func proxyClient(ctx context.Context, sessCtx *SessionContext, addr string) (*client.ProxyClient, error) {
func proxyClient(ctx context.Context, sessCtx *SessionContext, addr, windowsUser string) (*client.ProxyClient, error) {
cfg, err := makeTeleportClientConfig(ctx, sessCtx)
if err != nil {
return nil, trace.Wrap(err)
}

// Set HostLogin to avoid the default behavior of looking up the
// Unix user Teleport is running as (which doesn't work in containerized
// environments where we're running as an arbitrary UID)
cfg.HostLogin = windowsUser

if err := cfg.ParseProxyHost(addr); err != nil {
return nil, trace.Wrap(err)
}
Expand Down