Skip to content

Commit

Permalink
Do not prompt for hardware MFA using tsh on Windows (#9081) (#9198)
Browse files Browse the repository at this point in the history
`tsh` doesn't support MFA logins on Windows; we make that explicit by warning
users when necessary, instead of directing them to a hopeless workflow.

Example attempt:

```shell
$ tsh login
> Enter password for Teleport user codingllama: <password>
> ERROR: hardware device MFA not supported by your platform, please register an OTP device
>
> exit status 1
```
  • Loading branch information
codingllama authored Dec 3, 2021
1 parent ede24a0 commit 66bbd05
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/auth/webauthncli/platform_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2021 Gravitational, Inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !windows
// +build !windows

package webauthncli

// HasPlatformSupport returns true if the platform supports client-side
// WebAuthn-compatible logins.
func HasPlatformSupport() bool {
return true
}
21 changes: 21 additions & 0 deletions lib/auth/webauthncli/platform_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2021 Gravitational, Inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package webauthncli

// HasPlatformSupport returns true if the platform supports client-side
// WebAuthn-compatible logins.
func HasPlatformSupport() bool {
return false
}
10 changes: 10 additions & 0 deletions lib/client/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ func PromptMFAChallenge(ctx context.Context, proxyAddr string, c *proto.MFAAuthe
// either Webauthn (preferred) or U2F.
hasTOTP := c.TOTP != nil
hasNonTOTP := len(c.U2F) > 0 || c.WebauthnChallenge != nil

// Does the current platform support hardware MFA? Adjust accordingly.
switch {
case !hasTOTP && !wancli.HasPlatformSupport():
return nil, trace.BadParameter("hardware device MFA not supported by your platform, please register an OTP device")
case !wancli.HasPlatformSupport():
// Do not prompt for hardware devices, it won't work.
hasNonTOTP = false
}

var numGoroutines int
if hasTOTP && hasNonTOTP {
numGoroutines = 2
Expand Down

0 comments on commit 66bbd05

Please sign in to comment.