Skip to content
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
7 changes: 1 addition & 6 deletions lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2833,12 +2833,7 @@ func (tc *TeleportClient) ConnectToCluster(ctx context.Context) (*ClusterClient,
cluster = connected
}

cltConfig := pclt.ClientConfig(ctx, cluster)
cltConfig.DialOpts = append(cltConfig.DialOpts,
grpc.WithStreamInterceptor(utils.GRPCClientStreamErrorInterceptor),
grpc.WithUnaryInterceptor(utils.GRPCClientUnaryErrorInterceptor),
)
aclt, err := auth.NewClient(cltConfig)
aclt, err := auth.NewClient(pclt.ClientConfig(ctx, cluster))
if err != nil {
return nil, trace.NewAggregate(err, pclt.Close())
}
Expand Down
10 changes: 6 additions & 4 deletions lib/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

"github.com/gravitational/trace"
"github.com/gravitational/trace/trail"
"github.com/moby/term"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/propagation"
Expand Down Expand Up @@ -566,11 +567,12 @@ func (proxy *ProxyClient) IssueUserCertsWithMFA(ctx context.Context, params Reis
Init: initReq,
}})
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}

resp, err := stream.Recv()
if err != nil {
err = trail.FromGRPC(err)
// Older versions will NOT reply with a MFARequired response in the
// challenge and will terminate the stream with an auth.ErrNoMFADevices error.
// In this case for all protocols other than SSH fall back to reissuing
Expand All @@ -589,16 +591,16 @@ func (proxy *ProxyClient) IssueUserCertsWithMFA(ctx context.Context, params Reis
}
mfaResp, err := promptMFAChallenge(ctx, proxy.teleportClient.WebProxyAddr, mfaChal)
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}
err = stream.Send(&proto.UserSingleUseCertsRequest{Request: &proto.UserSingleUseCertsRequest_MFAResponse{MFAResponse: mfaResp}})
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}

resp, err = stream.Recv()
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}
certResp := resp.GetCert()
if certResp == nil {
Expand Down
19 changes: 6 additions & 13 deletions lib/client/cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ import (
"context"

"github.com/gravitational/trace"
"github.com/gravitational/trace/trail"
"go.opentelemetry.io/otel/attribute"
oteltrace "go.opentelemetry.io/otel/trace"
"golang.org/x/crypto/ssh"
"google.golang.org/grpc"

"github.com/gravitational/teleport/api/client/proto"
proxyclient "github.com/gravitational/teleport/api/client/proxy"
"github.com/gravitational/teleport/api/utils/keys"
"github.com/gravitational/teleport/lib/auth"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/utils"
)

// ClusterClient facilitates communicating with both the
Expand Down Expand Up @@ -87,13 +86,7 @@ func (c *ClusterClient) SessionSSHConfig(ctx context.Context, user string, targe

mfaClt := c
if target.Cluster != rootClusterName {
cltConfig := c.ProxyClient.ClientConfig(ctx, rootClusterName)
cltConfig.DialOpts = append(cltConfig.DialOpts,
grpc.WithStreamInterceptor(utils.GRPCClientStreamErrorInterceptor),
grpc.WithUnaryInterceptor(utils.GRPCClientUnaryErrorInterceptor),
)

aclt, err := auth.NewClient(cltConfig)
aclt, err := auth.NewClient(c.ProxyClient.ClientConfig(ctx, rootClusterName))
if err != nil {
return nil, trace.Wrap(MFARequiredUnknown(err))
}
Expand Down Expand Up @@ -277,12 +270,12 @@ func (c *ClusterClient) performMFACeremony(ctx context.Context, clt *ClusterClie
Init: initReq,
}})
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}

resp, err := stream.Recv()
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}
mfaChal := resp.GetMFAChallenge()
if mfaChal == nil {
Expand Down Expand Up @@ -312,12 +305,12 @@ func (c *ClusterClient) performMFACeremony(ctx context.Context, clt *ClusterClie
}
err = stream.Send(&proto.UserSingleUseCertsRequest{Request: &proto.UserSingleUseCertsRequest_MFAResponse{MFAResponse: mfaResp}})
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}

resp, err = stream.Recv()
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(trail.FromGRPC(err))
}
certResp := resp.GetCert()
if certResp == nil {
Expand Down