Skip to content

Commit

Permalink
mfa: handle older servers during IsMFARequired RPC from tsh (#6039)
Browse files Browse the repository at this point in the history
tsh should gracefully fall back to the old code path if the server is
pre-6.0 and doesn't implement IsMFARequired.
  • Loading branch information
Andrew Lytvynov committed Mar 25, 2021
1 parent 853ff9c commit 5d74465
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ func (proxy *ProxyClient) IssueUserCertsWithMFA(ctx context.Context, params Reis
defer clt.Close()
requiredCheck, err := clt.IsMFARequired(ctx, params.isMFARequiredRequest(proxy.hostLogin))
if err != nil {
if status.Code(err) == codes.Unimplemented {
// Probably talking to an older server, use the old non-MFA endpoint.
log.WithError(err).Debug("Auth server does not implement IsMFARequired.")
// SSH certs can be used without reissuing.
if params.usage() == proto.UserCertsRequest_SSH {
return key, nil
}
return proxy.reissueUserCerts(ctx, params)
}
return nil, trace.Wrap(err)
}
if !requiredCheck.Required {
Expand Down

0 comments on commit 5d74465

Please sign in to comment.