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

Clear terminal when auth server is in FIPS mode #10095

Merged
merged 10 commits into from
Feb 17, 2022
1,099 changes: 571 additions & 528 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/client/proto/authservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ message PingResponse {
Features ServerFeatures = 3 [ (gogoproto.jsontag) = "server_features" ];
// ProxyPublicAddr is the server's public proxy address.
string ProxyPublicAddr = 4 [ (gogoproto.jsontag) = "proxy_public_addr" ];
// IsBoring signals whether or not the server was compiled with BoringCrypto.
bool IsBoring = 5 [ (gogoproto.jsontag) = "is_boring" ];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not exposed on the public unauth /ping endpoint right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. This is only exposed on auth's grpc server.

}

// Features are auth server features.
Expand Down
4 changes: 1 addition & 3 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3262,9 +3262,7 @@ func testAuditOff(t *testing.T, suite *integrationTestSuite) {
}

// audit log should have the fact that the session occurred recorded in it
sessions, err = site.GetSessions(apidefaults.Namespace)
require.NoError(t, err)
require.Len(t, sessions, 1)
// but the session could have been garbage collected at this point.
timothyb89 marked this conversation as resolved.
Show resolved Hide resolved

// however, attempts to read the actual sessions should fail because it was
// not actually recorded
Expand Down
1 change: 1 addition & 0 deletions lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ func (a *ServerWithRoles) Ping(ctx context.Context) (proto.PingResponse, error)
ServerVersion: teleport.Version,
ServerFeatures: modules.GetModules().Features().ToProto(),
ProxyPublicAddr: a.getProxyPublicAddr(),
IsBoring: modules.GetModules().IsBoringBinary(),
}, nil
}

Expand Down
10 changes: 10 additions & 0 deletions lib/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ func (proxy *ProxyClient) NewWatcher(ctx context.Context, watch types.Watch) (ty
return watcher, nil
}

// isAuthBoring checks whether or not the auth server for the current cluster was compiled with BoringCrypto.
func (proxy *ProxyClient) isAuthBoring(ctx context.Context) (bool, error) {
site, err := proxy.ConnectToCurrentCluster(ctx, false)
if err != nil {
return false, trace.Wrap(err)
}
resp, err := site.Ping(ctx)
return resp.IsBoring, trace.Wrap(err)
}

// FindServersByLabels returns list of the nodes which have labels exactly matching
// the given label set.
//
Expand Down
12 changes: 11 additions & 1 deletion lib/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ func newSession(client *NodeClient,
defer ns.closeWait.Done()

<-ns.closer.C
if isFIPS() {

if isFIPS() || isAuthServerBoring(client) {
atburke marked this conversation as resolved.
Show resolved Hide resolved
if err := ns.terminal.Clear(); err != nil {
log.Warnf("Failed to clear screen: %v.", err)
}
Expand All @@ -160,6 +161,15 @@ func newSession(client *NodeClient,
return ns, nil
}

func isAuthServerBoring(client *NodeClient) bool {
boring, err := client.Proxy.isAuthBoring(context.Background())
if err != nil {
log.Errorf("Failed to ping auth server: %v.", err)
return false
}
return boring
}

func (ns *NodeSession) NodeClient() *NodeClient {
return ns.nodeClient
}
Expand Down